Base class for components in a job. More...
Public Member Functions | |
def | __init__ (self, name, command=None, nevents=None, seed=1, inputs=[], outputs=None, append_tok=None, output_ext=None, ignore_job_params=[], **kwargs) |
def | cmd_line_str (self) |
def | execute (self, log_out=sys.stdout, log_err=sys.stderr) |
Generic component execution method. More... | |
def | cmd_exists (self) |
Check if the component's assigned command exists. More... | |
def | cmd_args (self) |
Return the command arguments of this component. More... | |
def | cmd_args_str (self) |
Return list of arguments, making sure they are all converted to strings. More... | |
def | setup (self) |
Perform any necessary setup for this component to run such as making symlinks to required directories. More... | |
def | cleanup (self) |
Perform post-job cleanup such as deleting temporary files. More... | |
def | config_logging (self, parser) |
Configure the logging for a component. More... | |
def | config (self, parser) |
Automatic configuration. More... | |
def | set_parameters (self, params) |
Set class attributes for the component based on JSON parameters. More... | |
def | required_parameters (self) |
Return a list of required parameters. More... | |
def | optional_parameters (self) |
Return a list of optional parameters. More... | |
def | required_config (self) |
Return a list of required configuration settings. More... | |
def | check_config (self) |
Raise an exception on the first missing config setting for this component. More... | |
def | input_files (self) |
Get a list of input files for this component. More... | |
def | output_files (self) |
Return a list of output files created by this component. More... | |
def | 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. More... | |
Public Attributes | |
name | |
command | |
nevents | |
seed | |
inputs | |
outputs | |
append_tok | |
output_ext | |
ignore_job_params | |
hpsmc_dir | |
logger | |
Private Member Functions | |
def | _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. More... | |
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
name | name of the component |
command | command to execute |
nevents | number of events to process |
seed | random seed |
inputs | list of input files |
outputs | list of output files |
append_tok | token to append to output file names |
output_ext | extension to append to output file names; format is .ext |
ignore_job_params | list of parameters to ignore when setting parameters |
kwargs | additional keyword arguments |
Definition at line 15 of file component.py.
def __init__ | ( | self, | |
name, | |||
command = None , |
|||
nevents = None , |
|||
seed = 1 , |
|||
inputs = [] , |
|||
outputs = None , |
|||
append_tok = None , |
|||
output_ext = None , |
|||
ignore_job_params = [] , |
|||
** | kwargs | ||
) |
Definition at line 37 of file component.py.
|
private |
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.
def check_config | ( | self | ) |
Raise an exception on the first missing config setting for this component.
Definition at line 194 of file component.py.
def cleanup | ( | self | ) |
Perform post-job cleanup such as deleting temporary files.
Reimplemented in PEDE.
Definition at line 107 of file component.py.
def cmd_args | ( | self | ) |
Return the command arguments of this component.
Reimplemented in LCIOMerge, LCIOCount, LCIOConcat, LCIOTool, LCIODumpEvent, ExtractEventsWithHitAtHodoEcal, FilterBunches, EvioToLcio, JavaTool, StdHepCount, MergePoisson, AddMotherFullTruth, DisplaceUni, DisplaceTime, RandomSample, BeamCoords, StdHepTool, HPSTR, JobManager, SLIC, MG, PEDE, ConstructDetector, and hadd.
Definition at line 93 of file component.py.
def cmd_args_str | ( | self | ) |
Return list of arguments, making sure they are all converted to strings.
Definition at line 97 of file component.py.
def cmd_exists | ( | self | ) |
Check if the component's assigned command exists.
Reimplemented in MoveFiles, TarFiles, and LHECount.
Definition at line 88 of file component.py.
def cmd_line_str | ( | self | ) |
Reimplemented in WriteMisalignedDet, and ApplyPedeRes.
Definition at line 68 of file component.py.
def 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. @param parser config parser
Reimplemented in LCIOTool, LCIODumpEvent, FilterBunches, JavaTool, JobManager, SLIC, and StdHepConverter.
Definition at line 123 of file component.py.
def 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.
def config_logging | ( | self, | |
parser | |||
) |
Configure the logging for a component.
parser | the ConfigParser object passed from the job manager |
Definition at line 111 of file component.py.
def execute | ( | self, | |
log_out = sys.stdout , |
|||
log_err = sys.stderr |
|||
) |
Generic component execution method.
Individual components may override this if specific behavior is required. @param log_out name of log file for output @param log_err name of log file for error @return error code
Reimplemented in WriteMisalignedDet, DummyComponent, MoveFiles, TarFiles, LHECount, Unzip, StdHepCount, MergePoisson, RandomSample, HPSTR, SLIC, MG5, MG4, MG, StdHepConverter, EGS5, and ApplyPedeRes.
Definition at line 73 of file component.py.
def input_files | ( | self | ) |
Get a list of input files for this component.
Definition at line 202 of file component.py.
def optional_parameters | ( | self | ) |
Return a list of optional parameters.
Optional parameters are: nevents, seed
Reimplemented in LCIOCount, ExtractEventsWithHitAtHodoEcal, FilterBunches, EvioToLcio, MergeFiles, DisplaceUni, DisplaceTime, RandomSample, BeamCoords, HPSTR, JobManager, SLIC, MG, EGS5, PEDE, ConstructDetector, ApplyPedeRes, _DetectorEditor, and hadd.
Definition at line 178 of file component.py.
def 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 Unzip, HPSTR, MG, StdHepConverter, and EGS5.
Definition at line 206 of file component.py.
def required_config | ( | self | ) |
Return a list of required configuration settings.
There are none by default.
Reimplemented in LCIOTool, LCIODumpEvent, FilterBunches, JavaTool, HPSTR, JobManager, SLIC, PEDE, ConstructDetector, WriteMisalignedDet, and _DetectorEditor.
Definition at line 186 of file component.py.
def required_parameters | ( | self | ) |
Return a list of required parameters.
The job will fail if these are not present in the JSON file.
Reimplemented in LCIOCount, LCIOTool, LCIODumpEvent, EvioToLcio, MergeFiles, MergePoisson, HPSTR, JobManager, SLIC, MG, EGS5, EventGenerator, PEDE, WriteMisalignedDet, and _DetectorEditor.
Definition at line 170 of file component.py.
def set_parameters | ( | self, | |
params | |||
) |
Set class attributes for the component based on JSON parameters.
Components should not need to override this method. @param params parameters to setup component
Reimplemented in MG.
Definition at line 141 of file component.py.
def setup | ( | self | ) |
Perform any necessary setup for this component to run such as making symlinks to required directories.
Reimplemented in LHECount, LCIODumpEvent, EvioToLcio, MergePoisson, HPSTR, JobManager, SLIC, MG5, MG4, MG, StdHepConverter, EGS5, PEDE, and ConstructDetector.
Definition at line 101 of file component.py.
append_tok |
Definition at line 55 of file component.py.
command |
Definition at line 50 of file component.py.
hpsmc_dir |
Definition at line 61 of file component.py.
ignore_job_params |
Definition at line 59 of file component.py.
inputs |
Definition at line 53 of file component.py.
logger |
Definition at line 66 of file component.py.
name |
Definition at line 49 of file component.py.
nevents |
Definition at line 51 of file component.py.
output_ext |
Definition at line 56 of file component.py.
outputs |
Definition at line 54 of file component.py.
seed |
Definition at line 52 of file component.py.