HPS-MC
Job Class Reference

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

Inheritance diagram for Job:

Public Member Functions

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

Static Public Member Functions

def is_ptag (src)
 
def get_ptag_from_src (src)
 

Public Attributes

 hpsmc_dir
 
 args
 (passed) job arguments More...
 
 job_config
 Job configuration. More...
 
 description
 short description of job, should be overridden by the job script More...
 
 job_id
 job ID More...
 
 param_file
 path to parameter file More...
 
 components
 list of components in job More...
 
 rundir
 rundir is current working directory More...
 
 params
 dict of parameters More...
 
 output_dir
 output_dir is current working directory More...
 
 input_files
 dict of input files More...
 
 output_files
 dict of output files More...
 
 ptags
 dict with keys to output filenames More...
 
 component_out
 output for component printouts More...
 
 component_err
 output for component error messages More...
 
 script
 script containing component initializations More...
 
 job_steps
 job steps More...
 
 hps_fieldmaps_dir
 fieldmaps dir More...
 
 enable_copy_output_files
 These attributes can all be set in the config file. More...
 
 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

string PTAG_PREFIX = 'ptag:'
 

Private Member Functions

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

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__()

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

Definition at line 186 of file job.py.

Member Function Documentation

◆ _cleanup()

def _cleanup (   self)
private

Perform post-job cleanup.

Definition at line 635 of file job.py.

◆ _config_fieldmap_dir()

def _config_fieldmap_dir (   self)
private

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

Definition at line 782 of file job.py.

◆ _config_file_pipeline()

def _config_file_pipeline (   self)
private

Pipe component outputs to inputs automatically.

Definition at line 610 of file job.py.

◆ _configure()

def _configure (   self)
private

Configure job class and components.

Definition at line 404 of file job.py.

◆ _copy_input_files()

def _copy_input_files (   self)
private

Copy input files to the run dir.

Definition at line 723 of file job.py.

◆ _copy_output_file()

def _copy_output_file (   self,
  src,
  dest 
)
private

Copy an output file from src to dest.

Definition at line 684 of file job.py.

◆ _copy_output_files()

def _copy_output_files (   self)
private

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

Definition at line 664 of file job.py.

◆ _execute()

def _execute (   self)
private

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()

def _initialize (   self)
private

Perform basic initialization before the job script is loaded.

Definition at line 383 of file job.py.

◆ _load_params()

def _load_params (   self,
  params 
)
private

Load the job parameters from JSON data.

Definition at line 341 of file job.py.

◆ _load_script()

def _load_script (   self)
private

Load the job script.

Definition at line 432 of file job.py.

◆ _set_input_files()

def _set_input_files (   self)
private

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()

def _set_parameters (   self)
private

Push JSON job parameters to components.

Definition at line 628 of file job.py.

◆ _setup()

def _setup (   self)
private

Necessary setup before job can be executed.

Definition at line 581 of file job.py.

◆ _symlink_fieldmap_dir()

def _symlink_fieldmap_dir (   self)
private

Symlink to the fieldmap directory.

Definition at line 794 of file job.py.

◆ _symlink_input_files()

def _symlink_input_files (   self)
private

Symlink input files.

Definition at line 743 of file job.py.

◆ add()

def add (   self,
  component 
)

Public method for adding components to the job.

Definition at line 239 of file job.py.

◆ get_ptag_from_src()

def get_ptag_from_src (   src)
static

Definition at line 770 of file job.py.

◆ is_ptag()

def is_ptag (   src)
static

Definition at line 766 of file job.py.

◆ parse_args()

def parse_args (   self)

Configure the job from command line arguments.

Definition at line 260 of file job.py.

◆ ptag()

def 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()

def resolve_output_src (   self,
  src 
)

Definition at line 776 of file job.py.

◆ run()

def run (   self)

This is the primary execution method for running the job.

Definition at line 461 of file job.py.

◆ set_parameters()

def 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

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
Todo:
: CL option to disable automatic copying of ouput files.

The files should be symlinked if copying is disabled. parser.add_argument("--no-copy-output-files", help="Disable copying of output files") parser.add_argument('–feature', dest='feature', action='store_true') parser.add_argument('–no-feature', dest='feature', action='store_false') parser.set_defaults(feature=True)

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

string 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

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: