qcg.pilotjob.api.job module¶
-
class
qcg.pilotjob.api.job.
Jobs
¶ Bases:
object
Group of job descriptions to submit
-
_list
¶ map with added job descriptions
Type: dict(str,dict)
-
_job_idx
¶ counter which is used to return ordered lists
Type: int
Initialize instance.
-
add
(job_attrs=None, **kw_attrs)¶ Add a new, simple job description to the group.
If both arguments are present, they are merged and processed as a single dictionary. The following job attributes are currenlty supported:
name
(str, optional): the job nameexec
(str, optional): path to the executable programscript
(str, optional): bash script contentargs
(str or list(str), optional): executable program argumentsstdin
(str, optional): path to file which content should be passed to the standard input streamstdout
(str, optional): path to the file where standard output stream should be savedstderr
(str, optional): path to the file where standard error stream should be savedwd
(str, optional): path to the working directory where job should be startedmodules
(str or list(str), optional): list of modules that should be loaded before job startvenv
(str, optional): path to the virtual environment that should be initialized before job startmodel
(str, optional): model of executionmodel_opts
(dict, optional): model optionsnumCores
(int or dict, optional): number of required cores specificationnumNodes
(int or dict, optional): number of required nodes specificationwt
(str, optional): job’s maximum wall timeiteration
(int, dict or list, optional): iterations definitionafter
(str or list(str), optional): name of the job’s that must finish successfully before current one start
The attributes
exec
(with optionalargs
) are mutually exclusive withscript
.The
numCores
andnumNodes
atrributes may contain dictionary with following keys:min
(int, optional): minimum number of resourcesmax
(int, optional): maximum number of resourcesexact
(int, optional): exact number of resourcesscheduler
(str, optional): name of iteration resource scheduler
The
min
,max
attributes are mutually exclusive withexact
. The description of iteration resource schedulers can be found in documentation.The
iteration
argument may contain either:- dictionary with following keys:
start
(int, optional): iterations start indexstop
(int, optional): iterations stop index
values
list with following iteration names
The total number of iterations will be:
stop - start
(the last iteration index will bestop - 1
) for boundary definition- length of
values
list
Parameters: - job_attrs (dict) – job description attributes in a simple format
- kw_attrs (dict) – job description attributes as a named arguments in a simple format
Raises: InvalidJobDescriptionError
– in case of non-unique job name or invalid job description
-
add_std
(job_attrs=None, **kw_attrs)¶ Add a new, standard job description (acceptable by the QCG PJM) to the group.
If both arguments are present, they are merged and processed as a single dictionary.
Parameters: - job_attrs (dict) – job description attributes in a standard format
- kw_attrs (dict) – job description attributes as a named arguments in a standard format
Raises: InvalidJobDescriptionError
– in case of non-unique job name or invalid job description
-
remove
(name)¶ Remote a job from the group.
Parameters: name (str) – name of the job to remove Raises: JobNotDefinedError
– in case of missing job in a group with given name
-
clear
()¶ Remove all jobs from the group.
Returns: number of removed elements Return type: int
-
job_names
()¶ Return a list with job names in group.
Returns: job names in group Return type: list(str)
-
ordered_job_names
()¶ Return a list with job names in group in order they were appended.
Returns: ordered job names Return type: list(str)
-
jobs
()¶ Return job descriptions in format acceptable by the QCG-PJM
Returns: a list of jobs in the format acceptable by the QCG PJM (standard format) Return type: list(dict)
-
ordered_jobs
()¶ Return job descriptions in format acceptable by the QCG-PJM in order they were appended.
Returns: a list of jobs in the format acceptable by the QCG PJM (standard format) Return type: list(dict)
-
load_from_file
(file_path)¶ Read job’s descriptions from JSON file in format acceptable (StdJob) by the QCG-PJM
Parameters: file_path (str) – path to the file with jobs descriptions in a standard format Raises: InvalidJobDescriptionError
– in case of invalid job description
-
save_to_file
(file_path)¶ Save job list to JSON file in a standard format.
Parameters: file_path (str) – path to the destination file Raises: FileError
– in case of problems with opening / writing output file.
-