modelrunner.run.job module
Provides functions for submitting models as jobs
- submit_job(script, output=None, name='job', parameters=None, config=None, *, log_folder=None, method='auto', use_modelrunner=True, template=None, overwrite_strategy='error', **kwargs)[source]
submit a script to the cluster queue
- Parameters:
script (str of
Path
) – Path to the script file, which contains the modeloutput (str of
Path
) – Path to the output file, where all the results are savedname (str) – Name of the job
parameters (str or dict) – Parameters for the script, either as a python dictionary or a string containing a JSON-encoded dictionary.
config (str or dict) – Configuration for the job, which determines how the job is run. Can be either a python dictionary or a string containing a JSON-encoded dictionary.
log_folder (str of
Path
) – Path to the logging folder. If omitted, the default of the template is used, which typically sends data to stdout for local scripts (which is thus captured and returned by this function) or writes log files to the current working directory for remote jobs.method (str) – Specifies the submission method. Currently background, foreground, ‘srun’, and qsub are supported. The special value auto reads the method from the config argument.
use_modelrunner (bool) – If True, script is envoked with the modelrunner library, e.g. by calling python -m modelrunner {script}.
template (str of
Path
) – Jinja template file for submission script. If omitted, a standard template is chosen based on the submission method.overwrite_strategy (str) – Determines what to do when files already exist. Possible options include error, warn_skip, silent_skip, overwrite, and silent_overwrite.
- Returns:
- The result (stdout, stderr) of the submission call. These two strings
can contain the output from the actual scripts that is run when log_folder is None.
- Return type:
- submit_jobs(script, output_folder, name_base='job', parameters=None, config=None, *, output_format='hdf', list_params=None, **kwargs)[source]
submit many jobs of the same script with different parameters to the cluster
- Parameters:
script (str of
Path
) – Path to the script file, which contains the modeloutput_folder (str of
Path
) – Path to the output folder, where all the results are savedname_base (str) – Base name of the job. An automatic name is generated on this basis.
parameters (str or dict) – Parameters for the script, either as a python dictionary or a string containing a JSON-encoded dictionary. All combinations of parameter values that are iterable and not strings and not part of keep_list are submitted as separate jobs.
config (str or dict) – Configuration for the job, which determines how the job is run. Can be either a python dictionary or a string containing a JSON-encoded dictionary.
output_format (str) – File extension determining the output format
list_params (list) – List of parameters that are meant to be lists. They will be submitted as individual parameters and not iterated over to produce multiple jobs.
**kwargs – All additional parameters are forwarded to
submit_job()
.
- Returns:
The number of jobs that have been submitted
- Return type: