-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathqtl-xtrain
More file actions
executable file
·92 lines (78 loc) · 2.5 KB
/
qtl-xtrain
File metadata and controls
executable file
·92 lines (78 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env ruby
require 'set'
unless ARGV.length == 2
puts """
Verify that a directory of a train's skim files has the same list of
run numbers as a directory of DST-file run directories.
USAGE: qtl xtrain [TRAIN_DIR(S)] [DST_DIR]
Both directories must be on /mss or /cache; the /mss dir is checked
(even if the argument is /cache)
Use globs to specify multiple TRAIN_DIRS (surround in quotes)
"""
exit 2
end
train_dirs, dst_dir = ARGV
num_failures = 0
# loop over train directories glob
Dir.glob(train_dirs).select{|d|File.directory? d}.each do |train_dir|
# function to get a set of run numbers from one of the argument dirs
def get_runnums(path, type)
runnums = Set.new
path = path.sub /^\/cache\//, '/mss/' if path.match? /^\/cache\//
raise "#{type} dir `#{path}` does not exist" unless Dir.exist? path
# get list of files/directories within
files = []
case type
when :train
files = Dir.glob File.join(path, '*.hipo')
when :DST
files = Dir.glob File.join(path, '*/')
else
raise 'bad type'
end
raise "no #{type} files found in #{type} dir `#{path}`" if files.empty?
# extract their run numbers
files.each do |file|
nums = File.basename(file).scan(/\d+/).map &:to_i
raise "failed to get run number from #{type} object `#{file}`" if nums.empty?
runnums << nums[-1]
end
raise "failed to get run numbers from #{type} dir `#{path}`" if runnums.empty?
runnums
end
# get runnum lists
train_runs = get_runnums train_dir, :train
dst_runs = get_runnums dst_dir, :DST
puts """
==================================================================================
train dir: #{train_dir}
run list: #{train_runs}
-----
DST dir: #{dst_dir}
run list: #{dst_runs}
=================================================================================="""
# compare runnum sets
only_in_trains = train_runs - dst_runs
only_in_dsts = dst_runs - train_runs
# print results
$stdout.flush
$stderr.flush
code = 0
unless only_in_trains.empty?
$stderr.puts "ERROR: there are runs with skim files, but no corresponding DST-file directories:"
$stderr.puts only_in_trains
code = 1
end
unless only_in_dsts.empty?
$stderr.puts "ERROR: there are runs with DST-file directories, but no corresponding skim files:"
$stderr.puts only_in_dsts
code = 1
end
# handle exit code
if code == 0
puts "All good"
else
num_failures += 1
end
end
exit num_failures > 0 ? 1 : 0