Commit 0fd0100d authored by bellotti_r's avatar bellotti_r
Browse files

Added pre- and post-commands to the constructor of OpalRunner

parent f10627b7
......@@ -63,7 +63,8 @@ class OpalRunner:
self._slurm_time = slurm_time
self._slurm_ram = slurm_ram
def run_configurations(self, design_variables):
def run_configurations(self, design_variables,
pre_command=None, post_command=None):
'''
Enqueues OPAL simulations for the given design variables.
......@@ -77,7 +78,14 @@ class OpalRunner:
A DataFrame containing the input variables.
Each row is a configuration. The column names are the names of the
design values as they would be put in the .data file.
pre_command: str (optional)
Command to execute before launching OPAL.
If None, execute the common pre-commands to launch on Merlin6.
Default: None
post_command: str (optional)
Command to execute before launching OPAL.
If None, execute the common pre-commands to launch on Merlin6.
Default: None
Returns
=======
list of str
......@@ -119,18 +127,20 @@ class OpalRunner:
os.environ['SLURM_RAM'] = self._slurm_ram
# commands to execute before running OPAL
pre_cmd = [
if pre_command is None:
pre_command = [
'module use /afs/psi.ch/project/amas/modulefiles',
'module load opal-toolchain/master',
]
pre_cmd = '\n'.join(pre_cmd)
pre_command = '\n'.join(pre_command)
# commands to execute after running OPAL
post_cmd = [
if post_command is None:
post_command = [
f'rm {output_path}/*.lbal',
f'rm {output_path}/*.h5',
]
post_cmd = '\n'.join(post_cmd)
post_command = '\n'.join(post_command)
# Queue the simulation.
sim = Simulation(parameters)
......@@ -140,8 +150,8 @@ class OpalRunner:
do_test, do_keep, do_no_batch, do_optimise,
info, self._partition, self._hyperthreading,
self._quiet,
preCommand=pre_cmd,
postCommand=post_cmd)
preCommand=pre_command,
postCommand=post_command)
launched_jobs.append(job_ID)
return launched_jobs
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment