HPS-MC
 
Loading...
Searching...
No Matches
Job Class Reference

Primary class to run HPS jobs from a Python script. More...

Inheritance diagram for Job:

Public Member Functions

 __init__ (self, args=sys.argv, **kwargs)
 
 add (self, component)
 Public method for adding components to the job.
 
 set_parameters (self, params)
 Add parameters to the job, overriding values if they exist already.
 
 parse_args (self)
 Configure the job from command line arguments.
 
 run (self)
 This is the primary execution method for running the job.
 
 ptag (self, tag, filename)
 Map a key to an output file name so a user can reference it in their job params.
 
 resolve_output_src (self, src)
 

Static Public Member Functions

 is_ptag (src)
 
 get_ptag_from_src (src)
 

Public Attributes

 hpsmc_dir
 
 args
 (passed) job arguments
 
 job_config
 Job configuration.
 
 description
 short description of job, should be overridden by the job script
 
 job_id
 job ID
 
 param_file
 path to parameter file
 
 components
 list of components in job
 
 rundir
 rundir is current working directory
 
 params
 dict of parameters
 
 output_dir
 output_dir is current working directory
 
 input_files
 dict of input files
 
 output_files
 dict of output files
 
 ptags
 dict with keys to output filenames
 
 component_out
 output for component printouts
 
 component_err
 output for component error messages
 
 script
 script containing component initializations
 
 job_steps
 job steps
 
 hps_fieldmaps_dir
 fieldmaps dir
 
 enable_copy_output_files
 These attributes can all be set in the config file.
 
 enable_copy_input_files
 
 delete_existing
 
 delete_rundir
 
 dry_run
 
 ignore_return_codes
 
 check_output_files
 
 check_commands
 
 enable_file_chaining
 
 enable_env_config
 
 out
 
 err
 

Static Public Attributes

str PTAG_PREFIX = 'ptag:'
 

Protected Member Functions

 _load_params (self, params)
 Load the job parameters from JSON data.
 
 _set_input_files (self)
 Prepare dictionary of input files.
 
 _initialize (self)
 Perform basic initialization before the job script is loaded.
 
 _configure (self)
 Configure job class and components.
 
 _load_script (self)
 Load the job script.
 
 _execute (self)
 Execute all components in job.
 
 _setup (self)
 Necessary setup before job can be executed.
 
 _config_file_pipeline (self)
 Pipe component outputs to inputs automatically.
 
 _set_parameters (self)
 Push JSON job parameters to components.
 
 _cleanup (self)
 Perform post-job cleanup.
 
 _copy_output_files (self)
 Copy output files to output directory, handling ptags if necessary.
 
 _copy_output_file (self, src, dest)
 Copy an output file from src to dest.
 
 _copy_input_files (self)
 Copy input files to the run dir.
 
 _symlink_input_files (self)
 Symlink input files.
 
 _config_fieldmap_dir (self)
 Set fieldmap dir to install location if not provided in config.
 
 _symlink_fieldmap_dir (self)
 Symlink to the fieldmap directory.
 

Detailed Description

Primary class to run HPS jobs from a Python script.

Jobs are run by executing a series of components which are configured using a config file with parameters provided by a JSON job file.

Definition at line 160 of file job.py.

Constructor & Destructor Documentation

◆ __init__()

__init__ (   self,
  args = sys.argv,
**  kwargs 
)

Definition at line 186 of file job.py.

Member Function Documentation

◆ _cleanup()

_cleanup (   self)
protected

Perform post-job cleanup.

Definition at line 635 of file job.py.

◆ _config_fieldmap_dir()

_config_fieldmap_dir (   self)
protected

Set fieldmap dir to install location if not provided in config.

Definition at line 782 of file job.py.

◆ _config_file_pipeline()

_config_file_pipeline (   self)
protected

Pipe component outputs to inputs automatically.

Definition at line 610 of file job.py.

◆ _configure()

_configure (   self)
protected

Configure job class and components.

Definition at line 404 of file job.py.

◆ _copy_input_files()

_copy_input_files (   self)
protected

Copy input files to the run dir.

Definition at line 723 of file job.py.

◆ _copy_output_file()

_copy_output_file (   self,
  src,
  dest 
)
protected

Copy an output file from src to dest.

Definition at line 684 of file job.py.

◆ _copy_output_files()

_copy_output_files (   self)
protected

Copy output files to output directory, handling ptags if necessary.

Definition at line 664 of file job.py.

◆ _execute()

_execute (   self)
protected

Execute all components in job.

If dry_run is set to True, the components will not be exectuted, list of components will be put out instead.

Definition at line 538 of file job.py.

◆ _initialize()

_initialize (   self)
protected

Perform basic initialization before the job script is loaded.

Definition at line 383 of file job.py.

◆ _load_params()

_load_params (   self,
  params 
)
protected

Load the job parameters from JSON data.

Definition at line 341 of file job.py.

◆ _load_script()

_load_script (   self)
protected

Load the job script.

Definition at line 432 of file job.py.

◆ _set_input_files()

_set_input_files (   self)
protected

Prepare dictionary of input files.

If a link to a download location is given as input, the file is downloaded into the run directory before the file name is added to the input_files dict. If a regular file is provided, it is added to the dict without any additional action.

Definition at line 365 of file job.py.

◆ _set_parameters()

_set_parameters (   self)
protected

Push JSON job parameters to components.

Definition at line 628 of file job.py.

◆ _setup()

_setup (   self)
protected

Necessary setup before job can be executed.

Definition at line 581 of file job.py.

◆ _symlink_fieldmap_dir()

_symlink_fieldmap_dir (   self)
protected

Symlink to the fieldmap directory.

Definition at line 794 of file job.py.

◆ _symlink_input_files()

_symlink_input_files (   self)
protected

Symlink input files.

Definition at line 743 of file job.py.

◆ add()

add (   self,
  component 
)

Public method for adding components to the job.

Definition at line 239 of file job.py.

◆ get_ptag_from_src()

get_ptag_from_src (   src)
static

Definition at line 770 of file job.py.

◆ is_ptag()

is_ptag (   src)
static

Definition at line 766 of file job.py.

◆ parse_args()

parse_args (   self)

Configure the job from command line arguments.

Definition at line 260 of file job.py.

◆ ptag()

ptag (   self,
  tag,
  filename 
)

Map a key to an output file name so a user can reference it in their job params.

Definition at line 755 of file job.py.

◆ resolve_output_src()

resolve_output_src (   self,
  src 
)

Definition at line 776 of file job.py.

◆ run()

run (   self)

This is the primary execution method for running the job.

Definition at line 461 of file job.py.

◆ set_parameters()

set_parameters (   self,
  params 
)

Add parameters to the job, overriding values if they exist already.

This method can be used in job scripts to define default values.

Definition at line 248 of file job.py.

Member Data Documentation

◆ args

args

(passed) job arguments

Definition at line 193 of file job.py.

◆ check_commands

check_commands

Definition at line 235 of file job.py.

◆ check_output_files

check_output_files

Definition at line 234 of file job.py.

◆ component_err

component_err

output for component error messages

Definition at line 219 of file job.py.

◆ component_out

component_out

output for component printouts

Definition at line 217 of file job.py.

◆ components

components

list of components in job

Definition at line 203 of file job.py.

◆ delete_existing

delete_existing

Definition at line 230 of file job.py.

◆ delete_rundir

delete_rundir

Definition at line 231 of file job.py.

◆ description

description

short description of job, should be overridden by the job script

Todo:
: combine these methods

Definition at line 197 of file job.py.

◆ dry_run

dry_run

Definition at line 232 of file job.py.

◆ enable_copy_input_files

enable_copy_input_files

Definition at line 229 of file job.py.

◆ enable_copy_output_files

enable_copy_output_files

These attributes can all be set in the config file.

Definition at line 228 of file job.py.

◆ enable_env_config

enable_env_config

Definition at line 237 of file job.py.

◆ enable_file_chaining

enable_file_chaining

Definition at line 236 of file job.py.

◆ err

err

Definition at line 304 of file job.py.

◆ hps_fieldmaps_dir

hps_fieldmaps_dir

fieldmaps dir

Definition at line 225 of file job.py.

◆ hpsmc_dir

hpsmc_dir

Definition at line 190 of file job.py.

◆ ignore_return_codes

ignore_return_codes

Definition at line 233 of file job.py.

◆ input_files

input_files

dict of input files

Definition at line 211 of file job.py.

◆ job_config

job_config

Job configuration.

Definition at line 195 of file job.py.

◆ job_id

job_id

job ID

Definition at line 199 of file job.py.

◆ job_steps

job_steps

job steps

Definition at line 223 of file job.py.

◆ out

out

Definition at line 296 of file job.py.

◆ output_dir

output_dir

output_dir is current working directory

Definition at line 209 of file job.py.

◆ output_files

output_files

dict of output files

Definition at line 213 of file job.py.

◆ param_file

param_file

path to parameter file

Definition at line 201 of file job.py.

◆ params

params

dict of parameters

Definition at line 207 of file job.py.

◆ PTAG_PREFIX

str PTAG_PREFIX = 'ptag:'
static
Todo:
is this still needed? List of config names to be read for the Job class (all optional).

Definition at line 184 of file job.py.

◆ ptags

ptags

dict with keys to output filenames

Definition at line 215 of file job.py.

◆ rundir

rundir

rundir is current working directory

Todo:
FIXME: Could try and convert to abspath here. raise Exception("The input source file '%s' is not an absolute path." % src)

Definition at line 205 of file job.py.

◆ script

script

script containing component initializations

name of or path to script

Definition at line 221 of file job.py.


The documentation for this class was generated from the following file: