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: ...@@ -63,7 +63,8 @@ class OpalRunner:
self._slurm_time = slurm_time self._slurm_time = slurm_time
self._slurm_ram = slurm_ram 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. Enqueues OPAL simulations for the given design variables.
...@@ -77,7 +78,14 @@ class OpalRunner: ...@@ -77,7 +78,14 @@ class OpalRunner:
A DataFrame containing the input variables. A DataFrame containing the input variables.
Each row is a configuration. The column names are the names of the Each row is a configuration. The column names are the names of the
design values as they would be put in the .data file. 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 Returns
======= =======
list of str list of str
...@@ -119,18 +127,20 @@ class OpalRunner: ...@@ -119,18 +127,20 @@ class OpalRunner:
os.environ['SLURM_RAM'] = self._slurm_ram os.environ['SLURM_RAM'] = self._slurm_ram
# commands to execute before running OPAL # commands to execute before running OPAL
pre_cmd = [ if pre_command is None:
'module use /afs/psi.ch/project/amas/modulefiles', pre_command = [
'module load opal-toolchain/master', '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 # commands to execute after running OPAL
post_cmd = [ if post_command is None:
f'rm {output_path}/*.lbal', post_command = [
f'rm {output_path}/*.h5', 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. # Queue the simulation.
sim = Simulation(parameters) sim = Simulation(parameters)
...@@ -140,8 +150,8 @@ class OpalRunner: ...@@ -140,8 +150,8 @@ class OpalRunner:
do_test, do_keep, do_no_batch, do_optimise, do_test, do_keep, do_no_batch, do_optimise,
info, self._partition, self._hyperthreading, info, self._partition, self._hyperthreading,
self._quiet, self._quiet,
preCommand=pre_cmd, preCommand=pre_command,
postCommand=post_cmd) postCommand=post_command)
launched_jobs.append(job_ID) launched_jobs.append(job_ID)
return launched_jobs 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