@@ -17,7 +17,7 @@ SLURM_LOG=/farm_out/%u/%x-%A_%a
1717# default options
1818dataset=test_v0
1919declare -A modes
20- for key in findhipo rundir eachdir flatdir single series submit check-cache swifjob focus-detectors focus-physics help ; do
20+ for key in findhipo rundir eachdir flatdir single series submit check-cache fast-ls swifjob focus-detectors focus-physics help ; do
2121 modes[$key ]=false
2222done
2323outputDir=" "
@@ -81,8 +81,9 @@ usageVerbose() {
8181 directory tree, e.g., runs grouped by target
8282
8383 --rundir assume each specified [RUN_DIRECTORY] contains
84- subdirectories named as just run numbers; it is not
85- recommended to use wildcards for this option
84+ subdirectories named as just run numbers;
85+ - it is not recommended to use wildcards for this option
86+ - see also the \` --fast-ls\` option
8687 **this is the DEFAULT option**
8788
8889 --eachdir assume each specified [RUN_DIRECTORY] is a single
@@ -121,6 +122,15 @@ usageVerbose() {
121122
122123 --focus-physics run histogramming for physics QA timelines
123124
125+ *** MISCELLANEOUS OPTIONS
126+
127+ --fast-ls use \` jasmine list-files\` to get lists of files, rather
128+ than commands such as \` find\` or \` ls\` , since \` jasmine\`
129+ may be much faster than the latter commands for tape dirs.
130+ - WARNING: assumes you already tested \` --check-cache\` ,
131+ since \` jasmine\` uses \` /mss\` stub files
132+ - useful for options such as \` --rundir\` for DST files
133+
124134 $sep
125135
126136 EXAMPLES:
@@ -300,7 +310,7 @@ declare -A runnumHash # `rdirs` element -> run number
300310for rdir in ${rdirs[@]} ; do
301311 # get the run number, either from `rdir` basename (fast), or from `RUN::config` (slow)
302312 [[ ! -e $rdir ]] && printError " the run file/directory '$rdir ' does not exist" && continue
303- runnum=$( basename $rdir | grep -m1 -o -E " [0-9]+" || echo ' ' ) # first, try from run directory (or file) basename
313+ runnum=$( basename $rdir | grep -m1 -o -E " [0-9]+" | tail -n1 | | echo ' ' ) # first, try from run directory (or file) basename
304314 if [ -z " $runnum " ] || ${modes['swifjob']} ; then # otherwise, use RUN::config from a HIPO file (NOTE: assumes all HIPO files have the same run number)
305315 if ${modes['flatdir']} ; then
306316 $TIMELINESRC /libexec/hipo-check.sh $rdir
@@ -313,7 +323,8 @@ for rdir in ${rdirs[@]}; do
313323 runnum=$( $TIMELINESRC /libexec/run-groovy-timeline.sh $TIMELINESRC /libexec/get-run-number.groovy $firstHipo | tail -n1 | grep -m1 -o -E " [0-9]+" || echo ' ' )
314324 fi
315325 fi
316- [ -z " $runnum " -o $runnum -eq 0 ] && printError " unknown run number for '$rdir '; ignoring it!" && continue
326+ [ -z " $runnum " ] && printError " unknown run number for '$rdir '; ignoring it!" && continue
327+ [ $runnum -eq 0 ] && printError " unknown run number for '$rdir '; ignoring it!" && continue
317328 runnum=$(( 10 #$runnum ))
318329 runnumHash[$rdir ]=$runnum
319330done
@@ -366,7 +377,18 @@ for rdir in ${rdirs[@]}; do
366377 realpath $rdir > $inputListFile
367378 else
368379 [[ " $( realpath $rdir ) " =~ /mss/ ]] && swifPrefix=" mss:" || swifPrefix=" file:"
369- realpath $rdir /* .hipo | sed " s;^;$swifPrefix ;" > $inputListFile
380+ if ${modes['fast-ls']} ; then
381+ rdir_mss=$( realpath $rdir | sed ' s;^.*/cache/;/mss/;' )
382+ rdir_cache=$( realpath $rdir )
383+ # fast-ls mode will use `jasmine list-files`, but requires the stub files on `mss` to exist; if a cook is ongoing,
384+ # it's possible the `/mss` directory won't be populated yet, although files are already on `/cache`; for that case,
385+ # fall back to "slow" ls (i.e., the command that runs when not using `--fast-ls`)
386+ jasmine list-files -display json -under $rdir_mss | jq -r ' .[].mss' | xargs -n1 basename | sed " s;^;${swifPrefix}${rdir_cache} /;" > $inputListFile \
387+ || { printWarning " falling back to slow ls..." ; realpath $rdir /* .hipo | sed " s;^;$swifPrefix ;" > $inputListFile ; }
388+ else
389+ echo " (use \` --fast-ls\` if this seems too slow)"
390+ realpath $rdir /* .hipo | sed " s;^;$swifPrefix ;" > $inputListFile
391+ fi
370392 fi
371393
372394 # generate job scripts
0 commit comments