Skip to content

Commit ccee3f5

Browse files
authored
feat: add CLARA test (#878)
* add new YAML file * use stock schema in yamls * .gitignore clara installation * run clara test * disable validation workflows * add denoising engine * disable validatin * disable validation * reactivate * schema dir in yaml * set memory limit * keep memory contiguous * benchmark * fail fast * let it be null, no waiting * configure threads * fall back to $HOME * add test * single-threaded * reduce verbosity * add gitlab clara test * fix ci test * remove benchmarks * fix file name * asdf * Revert "asdf" This reverts commit f648034. * yes * fix * needs cvmfs for ccdb
1 parent 7cd6bb1 commit ccee3f5

File tree

8 files changed

+157
-14
lines changed

8 files changed

+157
-14
lines changed

.github-ci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.github/workflows/ci.yml

.github/workflows/ci.yml

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ jobs:
3939
id: cache
4040
with:
4141
key: raw_test_data # fixed key will always hit; clear cache to trigger cache miss
42-
path: clas_005038.evio.00000
42+
path: |
43+
clas_005038.evio.00000
44+
clas_021559.evio.00001
4345
lookup-only: true
4446
- name: install xrootd-client
4547
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
@@ -50,6 +52,7 @@ jobs:
5052
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
5153
run: |
5254
xrdcp xroot://sci-xrootd.jlab.org///osgpool/hallb/clas12/validation/clas_005038.evio.00000 ./
55+
xrdcp xroot://sci-xrootd.jlab.org///osgpool/hallb/clas12/validation/raw/rg-l/clas_021559.evio.00001 ./
5356
5457
# build
5558
#############################################################################
@@ -86,14 +89,18 @@ jobs:
8689
if: ${{ github.ref_type == 'tag' }}
8790
run: libexec/version-bump.sh ${{ github.ref_name }}
8891
- name: build
89-
run: ./build-coatjava.sh --xrootd --no-progress -T${{ env.nthreads }}
92+
run: ./build-coatjava.sh --clara --xrootd --no-progress -T${{ env.nthreads }}
9093
- name: tar # tarball to preserve permissions
91-
run: tar czvf coatjava.tar.gz coatjava
94+
run: |
95+
tar czvf coatjava.tar.gz coatjava
96+
tar czvf clara.tar.gz clara
9297
- uses: actions/upload-artifact@v4
9398
with:
9499
name: build_${{ matrix.runner }}
95100
retention-days: 1
96-
path: coatjava.tar.gz
101+
path: |
102+
coatjava.tar.gz
103+
clara.tar.gz
97104
98105
# tests
99106
#############################################################################
@@ -147,13 +154,50 @@ jobs:
147154
- uses: actions/cache/restore@v4
148155
with:
149156
key: raw_test_data
150-
path: clas_005038.evio.00000
157+
path: |
158+
clas_005038.evio.00000
159+
clas_021559.evio.00001
151160
- name: untar build
152161
run: tar xzvf coatjava.tar.gz
153162
- name: run test
154163
run: |
164+
ls -lhtr
155165
./coatjava/bin/decoder -n 10000 -o dog.hipo ./clas_005038.evio.00000
156166
167+
test_clara:
168+
needs: [ build, download_test_data ]
169+
strategy:
170+
fail-fast: true
171+
runs-on: ubuntu-latest
172+
steps:
173+
- uses: actions/checkout@v5
174+
- name: Set up JDK
175+
uses: actions/setup-java@v5
176+
with:
177+
java-version: ${{ env.java_version }}
178+
distribution: ${{ env.java_distribution }}
179+
- name: setup cvmfs
180+
uses: cvmfs-contrib/github-action-cvmfs@v5
181+
with:
182+
cvmfs_repositories: 'oasis.opensciencegrid.org'
183+
- uses: actions/download-artifact@v5
184+
with:
185+
name: build_ubuntu-latest
186+
- uses: actions/cache/restore@v4
187+
with:
188+
key: raw_test_data
189+
path: |
190+
clas_005038.evio.00000
191+
clas_021559.evio.00001
192+
- name: untar build
193+
run: |
194+
tar xzvf clara.tar.gz
195+
- name: run test
196+
run: |
197+
ls -lhtr
198+
./clara/plugins/clas12/bin/run-clara -y ./etc/services/rgl-clarode.yml -t ${{ env.nthreads }} -n 200 -c ./clara -o ./tmp ./clas_021559.evio.00001
199+
ls -lhtr
200+
157201
test_coatjava:
158202
needs: [ build ]
159203
strategy:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# installed:
22
/coatjava
3+
/clara
34
target
45
/publish
56
/docs/javadoc/*

.gitlab-ci.yml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ stages:
2323
build:
2424
stage: build
2525
script:
26-
- ./build-coatjava.sh -T$JL_RUNNER_AVAIL_CPU --quiet --no-progress
26+
- ./build-coatjava.sh --clara -T$JL_RUNNER_AVAIL_CPU --quiet --no-progress
2727
- tar -czf coatjava.tar.gz coatjava
28+
- tar -czf clara.tar.gz clara
2829
artifacts:
2930
when: always
3031
expire_in: 1 day
3132
paths:
3233
- coatjava.tar.gz
34+
- clara.tar.gz
3335

3436
depana:
3537
allow_failure: true
@@ -38,6 +40,18 @@ depana:
3840
- libexec/dependency-tree.sh
3941
- libexec/dependency-analysis.sh
4042

43+
download:
44+
stage: build
45+
script:
46+
- xrdcp xroot://sci-xrootd.jlab.org///osgpool/hallb/clas12/validation/clas_005038.evio.00000 ./
47+
- xrdcp xroot://sci-xrootd.jlab.org///osgpool/hallb/clas12/validation/raw/rg-l/clas_021559.evio.00001 ./
48+
artifacts:
49+
when: always
50+
expire_in: 1 day
51+
paths:
52+
- clas_005038.evio.00000
53+
- clas_021559.evio.00000
54+
4155
spotbugs:
4256
stage: test
4357
needs: [build]
@@ -100,6 +114,18 @@ eb:
100114
- ARG: electronneutronC
101115
- ARG: electronFTpion
102116

117+
clara:
118+
allow_failure: true
119+
stage: test
120+
needs: [build]
121+
dependencies: [build]
122+
script:
123+
- >
124+
tar -xzf clara.tar.gz &&
125+
./clara/plugins/clas12/bin/run-clara -c ./clara
126+
-t $JL_RUNNER_AVAIL_CPU -y ./etc/services/rgl-clarode.yml
127+
-n 100 -o ./out clas_021*.hipo
128+
103129
profile:
104130
stage: test
105131
needs: [build]

bin/run-clara

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ done
7272
[ $(cat $CLARA_USER_DATA/filelist.txt | wc -l) -gt 0 ] || error "Found no input files"
7373

7474
# Set some JVM options:
75-
export JAVA_OPTS="$JAVA_OPTS -XX:+IgnoreUnrecognizedVMOptions"
75+
export JAVA_OPTS="$JAVA_OPTS -Xmx${threads}g -XX:+IgnoreUnrecognizedVMOptions"
7676
export JAVA_OPTS="$JAVA_OPTS -Djava.io.tmpdir=$CLARA_USER_DATA -Dorg.sqlite.tmpdir=$CLARA_USER_DATA"
7777
# Set verbosity:
7878
[ -z ${quiet+x} ] && stub=fine || stub=info

etc/services/rgl-clarode.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
mime-types:
2+
- binary/data-hipo
3+
configuration:
4+
global:
5+
variation: rge_spring2024
6+
timestamp: 10/08/2025-17:00:00
7+
io-services:
8+
writer:
9+
schema_dir: full
10+
services:
11+
MAGFIELDS:
12+
magfieldSolenoidMap: Symm_solenoid_r601_phi1_z1201_13June2018.dat
13+
magfieldTorusMap: Full_torus_r251_phi181_z251_25Jan2021.dat
14+
io-services:
15+
reader:
16+
class: org.jlab.io.clara.DecoderReader
17+
name: DecoderReader
18+
writer:
19+
class: org.jlab.io.clara.DecoderWriter
20+
name: DecoderWriter
21+
services:
22+
- class: org.jlab.service.ai.DCDenoiseEngine
23+
name: DCDN
24+
- class: org.jlab.clas.swimtools.MagFieldsEngine
25+
name: MAGFIELDS
26+
- class: org.jlab.rec.ft.cal.FTCALEngine
27+
name: FTCAL
28+
- class: org.jlab.rec.ft.hodo.FTHODOEngine
29+
name: FTHODO
30+
- class: org.jlab.rec.ft.FTEBEngine
31+
name: FTEB
32+
- class: org.jlab.service.dc.DCHBClustering
33+
name: DCCR
34+
- class: org.jlab.service.dc.DCHBPostClusterConv
35+
name: DCHB
36+
- class: org.jlab.service.ftof.FTOFHBEngine
37+
name: FTOFHB
38+
- class: org.jlab.service.ec.ECEngine
39+
name: EC
40+
- class: org.jlab.service.ctof.CTOFEngine
41+
name: CTOF
42+
- class: org.jlab.service.cnd.CNDCalibrationEngine
43+
name: CND
44+
- class: org.jlab.service.band.BANDEngine
45+
name: BAND
46+
- class: org.jlab.service.htcc.HTCCReconstructionService
47+
name: HTCC
48+
- class: org.jlab.service.ltcc.LTCCEngine
49+
name: LTCC
50+
- class: org.jlab.service.eb.EBHBEngine
51+
name: EBHB
52+
- class: org.jlab.service.dc.DCTBEngine
53+
name: DCTB
54+
- class: org.jlab.service.ftof.FTOFTBEngine
55+
name: FTOFTB
56+
- class: org.jlab.service.eb.EBTBEngine
57+
name: EBTB
58+
- class: org.jlab.rec.rich.RICHEBEngine
59+
name: RICH

install-clara

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function litter() {
3434
then
3535
echo -e "\nSee temporary build directory for more info:\n\t$tmp_dir"
3636
else
37-
rm -rf $tmp_dir && echo -e "\nRemoved temporary build directory:\n\t$tmp_dir"
37+
rm -rf $tmp_dir
3838
fi
3939
fi
4040
}
@@ -117,7 +117,6 @@ fi
117117
tmp_dir=$(mktemp -d tmp.install-clara.XXXXXX)
118118
[ $? -ne 0 ] && error "Cannot create temporary directory: $tmp_dir"
119119
tmp_dir=$(cd $tmp_dir && pwd)
120-
echo -e "\nCreating temporary build directory:\n\t$tmp_dir"
121120
cd $tmp_dir
122121

123122
# CLARA:

reconstruction/ai/src/main/java/org/jlab/service/ai/DCDenoiseEngine.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import ai.djl.translate.TranslateException;
1818
import java.io.IOException;
1919
import java.util.concurrent.BlockingQueue;
20-
import java.util.concurrent.LinkedBlockingQueue;
20+
import java.util.concurrent.ArrayBlockingQueue;
2121

2222
import org.jlab.clas.reco.ReconstructionEngine;
2323
import org.jlab.io.base.DataBank;
@@ -28,6 +28,7 @@ public class DCDenoiseEngine extends ReconstructionEngine {
2828

2929
final static String[] BANK_NAMES = {"DC::tot","DC::tdc"};
3030
final static String CONF_THRESHOLD = "threshold";
31+
final static String CONF_THREADS = "threads";
3132
final static int LAYERS = 36;
3233
final static int WIRES = 112;
3334

@@ -39,11 +40,11 @@ public class DCDenoiseEngine extends ReconstructionEngine {
3940
public static class PredictorPool {
4041
final BlockingQueue<Predictor> pool;
4142
public PredictorPool(int size, ZooModel model) {
42-
pool = new LinkedBlockingQueue<>(size);
43-
for (int i=0; i<size; i++) pool.offer(model.newPredictor());
43+
pool = new ArrayBlockingQueue<>(size);
44+
for (int i=0; i<size; i++) pool.add(model.newPredictor());
4445
}
4546
public Predictor get() throws InterruptedException {
46-
return pool.take();
47+
return pool.poll();
4748
}
4849
public void put(Predictor p) {
4950
if (p != null) pool.offer(p);
@@ -56,6 +57,9 @@ public DCDenoiseEngine() {
5657

5758
@Override
5859
public boolean init() {
60+
System.setProperty("ai.djl.pytorch.num_interop_threads", "1");
61+
System.setProperty("ai.djl.pytorch.num_threads", "1");
62+
System.setProperty("ai.djl.pytorch.graph_optimizer", "false");
5963
if (getEngineConfigString(CONF_THRESHOLD) != null)
6064
threshold = Float.parseFloat(getEngineConfigString(CONF_THRESHOLD));
6165
try {
@@ -67,14 +71,23 @@ public boolean init() {
6771
.optProgress(new ProgressBar())
6872
.build();
6973
model = criteria.loadModel();
70-
predictors = new PredictorPool(64, model);
74+
int threads = Integer.parseInt(getEngineConfigString(CONF_THREADS,"64"));
75+
predictors = new PredictorPool(threads, model);
7176
return true;
7277
} catch (NullPointerException | MalformedModelException | IOException | ModelNotFoundException ex) {
7378
System.getLogger(DCDenoiseEngine.class.getName()).log(System.Logger.Level.ERROR, (String) null, ex);
7479
return false;
7580
}
7681
}
7782

83+
public static void main(String args[]){
84+
DCDenoiseEngine dn = new DCDenoiseEngine();
85+
dn.init();
86+
for (int i=0; i<10000; i++) {
87+
dn.processFakeEvent();
88+
}
89+
}
90+
7891
@Override
7992
public boolean processDataEvent(DataEvent event) {
8093

0 commit comments

Comments
 (0)