Skip to content

Commit 4756364

Browse files
committed
feat: cross check run list from trains and DSTs
Differences in these runlists is a recurring issue; let's add it to the procedure.
1 parent af5da39 commit 4756364

3 files changed

Lines changed: 66 additions & 0 deletions

File tree

bin/qtl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ usage() {
1818
physics Generate and analyze physics QA timelines (Step 2)
1919
error Scan for errors in Slurm logs (for Step 1)
2020
reheat Reproduce a data file, e.g., to rerun postprocessing
21+
xtrain Cross check run list from trains and DSTs
2122
2223
OPTIONS: Each command has its own set of options; run a command with no
2324
additional options to see usage for that command.
@@ -41,6 +42,7 @@ case $cmd in
4142
ph*) exec $TIMELINESRC/bin/qtl-physics "$@" ;;
4243
er*) exec $TIMELINESRC/bin/qtl-error "$@" ;;
4344
re*) exec $TIMELINESRC/bin/qtl-reheat "$@" ;;
45+
xt*) exec $TIMELINESRC/bin/qtl-xtrain "$@" ;;
4446
-v|--version)
4547
echo $(mvn -q help:evaluate -Dexpression=project.version -DforceStdout -f $TIMELINESRC/pom.xml || echo "UNKNOWN")
4648
exit 0

bin/qtl-xtrain

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env ruby
2+
3+
require 'set'
4+
5+
unless ARGV.length == 2
6+
puts """
7+
Verify that a directory of a train's skim files has the same list of
8+
run numbers as a directory of DST-file run directories.
9+
10+
USAGE: #{$0} [TRAIN_DIR] [DST_DIR]"""
11+
exit 2
12+
end
13+
train_dir, dst_dir = ARGV
14+
15+
# function to get a set of run numbers from one of the argument dirs
16+
def get_runnums(path, type)
17+
runnums = Set.new
18+
raise "path '#{path}' does not exist" unless Dir.exist? path
19+
20+
# get list of files/directories within
21+
files = []
22+
case type
23+
when :train
24+
files = Dir.glob File.join(path, '*.hipo')
25+
when :dst
26+
files = Dir.glob File.join(path, '*/')
27+
else
28+
raise 'bad type'
29+
end
30+
31+
# extract their run numbers
32+
files.each do |file|
33+
nums = File.basename(file).scan(/\d+/).map &:to_i
34+
raise "failed to get runnum from '#{file}'" unless nums.length == 1
35+
runnums << nums[0]
36+
end
37+
runnums
38+
end
39+
40+
# compare runnum sets
41+
train_runs = get_runnums train_dir, :train
42+
dst_runs = get_runnums dst_dir, :dst
43+
only_in_trains = train_runs - dst_runs
44+
only_in_dsts = dst_runs - train_runs
45+
46+
# return results
47+
code = 0
48+
unless only_in_trains.empty?
49+
$stderr.puts "ERROR: there are runs with skim files, but no corresponding DST-file directories:"
50+
$stderr.puts only_in_trains
51+
code = 1
52+
end
53+
unless only_in_dsts.empty?
54+
$stderr.puts "ERROR: there are runs with DST-file directories, but no corresponding skim files:"
55+
$stderr.puts only_in_dsts
56+
code = 1
57+
end
58+
exit code

doc/qa.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ If you are performing a manual QA as part of a cross check, skip to the next sec
4949
- use the scripts in the [`prescaler/` directory](/qadb/prescaler)
5050
</details>
5151

52+
<details>
53+
<summary>- [ ] cross check run list from trains and from DSTs</summary>
54+
55+
- FIXME
56+
</details>
57+
5258
<details>
5359
<summary>- [ ] make sure all data are cached</summary>
5460

0 commit comments

Comments
 (0)