Skip to content

Commit

Permalink
Specify experiment binaries with rattests (#222)
Browse files Browse the repository at this point in the history
* Add in command line argument to specify which experiment binary should be used with the rattests.

* Specifying default for rattest experiment
  • Loading branch information
smnaugle authored Jan 17, 2025
1 parent a33eb88 commit acf82a1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 5 additions & 1 deletion python/rattest.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
action='store_false', dest='web', default=True,
help='Do not open web pages with plots.')

parser.add_argument('-e', '--experiment',
type=str, dest='experiment_bin', default=None,
help='Absolute path to experiment binary to run test with. Uses `rat` as default.')

parser.add_argument('--make-template', type=str, dest='template', default=None,
help='Write a template rattest to current directory for you to edit. '\
'Supplied name is used for .mac and .C files.')
Expand All @@ -52,7 +56,7 @@
for dirname in args.input:
for dirpath, _, filenames in os.walk(dirname):
if configname in filenames:
testcase = RatTest(os.path.join(dirpath, configname))
testcase = RatTest(os.path.join(dirpath, configname), rat_bin=args.experiment_bin)
if args.update:
testcase.update(regen_mc=args.regen_mc, regen_plots=args.regen_plots)
else:
Expand Down
12 changes: 8 additions & 4 deletions python/rattest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class RatTest:
Also compares and saves the histograms.
'''

def __init__(self, config_file):
def __init__(self, config_file, rat_bin=None):
self.config_file = config_file
self.testdir = os.path.abspath(os.path.dirname(config_file))
# Create default name out of bottom level dir name
Expand All @@ -106,7 +106,11 @@ def __init__(self, config_file):
self.rat_macro = os.path.abspath(os.path.join(self.testdir, self.rat_macro))
self.root_macro = os.path.abspath(os.path.join(self.testdir, self.root_macro))
self.rat_script = os.path.abspath(os.path.join(os.environ['RATROOT'], 'bin', 'rat'))
self.rat_bin = os.path.abspath(os.path.join(os.environ['RATROOT'], 'bin', 'rat'))
# Allow users to specify rat binary so tests can be ran with downstream experiments
if rat_bin is None:
self.rat_bin = os.path.abspath(os.path.join(os.environ['RATROOT'], 'bin', 'rat'))
else:
self.rat_bin = rat_bin

# Find name of file holding events from last macro
mac = self.rat_macro
Expand Down Expand Up @@ -163,9 +167,9 @@ def run_rat(self):
suffix = "_" + str(i) + ".mac"
mac = self.rat_macro.replace(".mac", suffix)
if self.seed == -1:
self.run_cmd_in_testdir('rat ' + os.path.basename(mac))
self.run_cmd_in_testdir(self.rat_bin + ' ' + os.path.basename(mac))
else:
self.run_cmd_in_testdir('rat -s ' + str(self.seed) + ' ' + os.path.basename(mac))
self.run_cmd_in_testdir(self.rat_bin + ' -s ' + str(self.seed) + ' ' + os.path.basename(mac))

def run_root(self):
'''
Expand Down

0 comments on commit acf82a1

Please sign in to comment.