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 name
  • exec (str, optional): path to the executable program
  • script (str, optional): bash script content
  • args (str or list(str), optional): executable program arguments
  • stdin (str, optional): path to file which content should be passed to the standard input stream
  • stdout (str, optional): path to the file where standard output stream should be saved
  • stderr (str, optional): path to the file where standard error stream should be saved
  • wd (str, optional): path to the working directory where job should be started
  • modules (str or list(str), optional): list of modules that should be loaded before job start
  • venv (str, optional): path to the virtual environment that should be initialized before job start
  • model (str, optional): model of execution
  • model_opts (dict, optional): model options
  • numCores (int or dict, optional): number of required cores specification
  • numNodes (int or dict, optional): number of required nodes specification
  • wt (str, optional): job’s maximum wall time
  • iteration (int, dict or list, optional): iterations definition
  • after (str or list(str), optional): name of the job’s that must finish successfully before current one start

The attributes exec (with optional args) are mutually exclusive with script.

The numCores and numNodes atrributes may contain dictionary with following keys:

  • min (int, optional): minimum number of resources
  • max (int, optional): maximum number of resources
  • exact (int, optional): exact number of resources
  • scheduler (str, optional): name of iteration resource scheduler

The min, max attributes are mutually exclusive with exact. 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 index
    • stop (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 be stop - 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.