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

Base class for components in a job. More...

Inheritance diagram for Component:
hadd _DetectorEditor PEDE DummyComponent EventGenerator HPSTR JavaTool JobManager LCIODumpEvent LCIOTool LHECount MoveFiles SLIC StdHepCount StdHepTool TarFiles Unzip

Public Member Functions

 __init__ (self, name, command=None, nevents=None, seed=1, inputs=[], outputs=None, append_tok=None, output_ext=None, ignore_job_params=[], **kwargs)
 
 cmd_line_str (self)
 
 execute (self, log_out=sys.stdout, log_err=sys.stderr)
 Generic component execution method.
 
 cmd_exists (self)
 Check if the component's assigned command exists.
 
 cmd_args (self)
 Return the command arguments of this component.
 
 cmd_args_str (self)
 Return list of arguments, making sure they are all converted to strings.
 
 setup (self)
 Perform any necessary setup for this component to run such as making symlinks to required directories.
 
 cleanup (self)
 Perform post-job cleanup such as deleting temporary files.
 
 config_logging (self, parser)
 Configure the logging for a component.
 
 config (self, parser)
 Automatic configuration.
 
 set_parameters (self, params)
 Set class attributes for the component based on JSON parameters.
 
 required_parameters (self)
 Return a list of required parameters.
 
 optional_parameters (self)
 Return a list of optional parameters.
 
 required_config (self)
 Return a list of required configuration settings.
 
 check_config (self)
 Raise an exception on the first missing config setting for this component.
 
 input_files (self)
 Get a list of input files for this component.
 
 output_files (self)
 Return a list of output files created by this component.
 
 config_from_environ (self)
 Configure component from environment variables which are just upper case versions of the required config names set in the shell environment.
 

Public Attributes

 name
 
 command
 
 nevents
 
 seed
 
 inputs
 
 outputs
 
 append_tok
 
 output_ext
 
 ignore_job_params
 
 hpsmc_dir
 
 logger
 

Protected Member Functions

 _inputs_to_outputs (self)
 This is the default method for automatically transforming input file names to outputs when output file names are not explicitly provided.
 

Detailed Description

Base class for components in a job.

Do not perform any logging in the init method of Component subclasses, as this is not configured by the job manager until after the components are created.

Optional parameters are: nevents, seed

Parameters
namename of the component
commandcommand to execute
neventsnumber of events to process
seedrandom seed
inputslist of input files
outputslist of output files
append_toktoken to append to output file names
output_extextension to append to output file names; format is .ext
ignore_job_paramslist of parameters to ignore when setting parameters
kwargsadditional keyword arguments

Definition at line 15 of file component.py.

Constructor & Destructor Documentation

◆ __init__()

__init__ (   self,
  name,
  command = None,
  nevents = None,
  seed = 1,
  inputs = [],
  outputs = None,
  append_tok = None,
  output_ext = None,
  ignore_job_params = [],
**  kwargs 
)

Member Function Documentation

◆ _inputs_to_outputs()

_inputs_to_outputs (   self)
protected

This is the default method for automatically transforming input file names to outputs when output file names are not explicitly provided.

Definition at line 217 of file component.py.

◆ check_config()

check_config (   self)

Raise an exception on the first missing config setting for this component.

Definition at line 194 of file component.py.

◆ cleanup()

cleanup (   self)

Perform post-job cleanup such as deleting temporary files.

Reimplemented in PEDE.

Definition at line 107 of file component.py.

◆ cmd_args()

◆ cmd_args_str()

cmd_args_str (   self)

Return list of arguments, making sure they are all converted to strings.

Definition at line 97 of file component.py.

◆ cmd_exists()

cmd_exists (   self)

Check if the component's assigned command exists.

Reimplemented in LHECount, TarFiles, and MoveFiles.

Definition at line 88 of file component.py.

◆ cmd_line_str()

cmd_line_str (   self)

Reimplemented in ApplyPedeRes, and WriteMisalignedDet.

Definition at line 68 of file component.py.

◆ config()

config (   self,
  parser 
)

Automatic configuration.

Automatically load attributes from config by reading in values from the section with the same name as the class in the config file and assigning them to class attributes with the same name.

Parameters
parserconfig parser

Reimplemented in StdHepConverter, SLIC, JobManager, JavaTool, FilterBunches, LCIODumpEvent, and LCIOTool.

Definition at line 123 of file component.py.

◆ config_from_environ()

config_from_environ (   self)

Configure component from environment variables which are just upper case versions of the required config names set in the shell environment.

Definition at line 231 of file component.py.

◆ config_logging()

config_logging (   self,
  parser 
)

Configure the logging for a component.

Parameters
parserthe ConfigParser object passed from the job manager

Definition at line 111 of file component.py.

◆ execute()

execute (   self,
  log_out = sys.stdout,
  log_err = sys.stderr 
)

Generic component execution method.

Individual components may override this if specific behavior is required.

Parameters
log_outname of log file for output
log_errname of log file for error
Returns
error code

Reimplemented in ApplyPedeRes, EGS5, StdHepConverter, MG, MG4, MG5, SLIC, HPSTR, RandomSample, MergePoisson, StdHepCount, Unzip, LHECount, TarFiles, MoveFiles, DummyComponent, and WriteMisalignedDet.

Definition at line 73 of file component.py.

◆ input_files()

input_files (   self)

Get a list of input files for this component.

Definition at line 202 of file component.py.

◆ optional_parameters()

optional_parameters (   self)

Return a list of optional parameters.

Optional parameters are: nevents, seed

Reimplemented in hadd, _DetectorEditor, ApplyPedeRes, ConstructDetector, PEDE, EGS5, MG, SLIC, JobManager, HPSTR, BeamCoords, RandomSample, DisplaceTime, DisplaceUni, MergeFiles, EvioToLcio, FilterBunches, ExtractEventsWithHitAtHodoEcal, and LCIOCount.

Definition at line 178 of file component.py.

◆ output_files()

output_files (   self)

Return a list of output files created by this component.

By default, a series of transformations will be performed on inputs to transform them into outputs.

Reimplemented in EGS5, StdHepConverter, MG, HPSTR, and Unzip.

Definition at line 206 of file component.py.

◆ required_config()

required_config (   self)

Return a list of required configuration settings.

There are none by default.

Reimplemented in _DetectorEditor, WriteMisalignedDet, ConstructDetector, PEDE, SLIC, JobManager, HPSTR, JavaTool, FilterBunches, LCIODumpEvent, and LCIOTool.

Definition at line 186 of file component.py.

◆ required_parameters()

required_parameters (   self)

Return a list of required parameters.

The job will fail if these are not present in the JSON file.

Reimplemented in _DetectorEditor, WriteMisalignedDet, PEDE, EventGenerator, EGS5, MG, SLIC, JobManager, HPSTR, MergePoisson, MergeFiles, EvioToLcio, LCIODumpEvent, LCIOTool, and LCIOCount.

Definition at line 170 of file component.py.

◆ set_parameters()

set_parameters (   self,
  params 
)

Set class attributes for the component based on JSON parameters.

Components should not need to override this method.

Parameters
paramsparameters to setup component

Reimplemented in MG.

Definition at line 141 of file component.py.

◆ setup()

setup (   self)

Perform any necessary setup for this component to run such as making symlinks to required directories.

Reimplemented in ConstructDetector, PEDE, EGS5, StdHepConverter, MG, MG4, MG5, SLIC, JobManager, HPSTR, MergePoisson, EvioToLcio, LCIODumpEvent, and LHECount.

Definition at line 101 of file component.py.

Member Data Documentation

◆ append_tok

append_tok

Definition at line 55 of file component.py.

◆ command

command

Definition at line 50 of file component.py.

◆ hpsmc_dir

hpsmc_dir

Definition at line 61 of file component.py.

◆ ignore_job_params

ignore_job_params
Todo:
FIXME: This is hacky.

Definition at line 59 of file component.py.

◆ inputs

inputs

Definition at line 53 of file component.py.

◆ logger

logger

Definition at line 66 of file component.py.

◆ name

name

Definition at line 49 of file component.py.

◆ nevents

nevents

Definition at line 51 of file component.py.

◆ output_ext

output_ext

Definition at line 56 of file component.py.

◆ outputs

outputs

Definition at line 54 of file component.py.

◆ seed

seed

Definition at line 52 of file component.py.


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