HPS-MC
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

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...
 

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

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.

Member Function Documentation

◆ _inputs_to_outputs()

def _inputs_to_outputs (   self)
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.

◆ check_config()

def check_config (   self)

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

Definition at line 194 of file component.py.

◆ cleanup()

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

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.

◆ cmd_exists()

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.

◆ cmd_line_str()

def cmd_line_str (   self)

Reimplemented in WriteMisalignedDet, and ApplyPedeRes.

Definition at line 68 of file component.py.

◆ config()

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.

◆ config_from_environ()

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.

◆ config_logging()

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

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.

◆ input_files()

def input_files (   self)

Get a list of input files for this component.

Definition at line 202 of file component.py.

◆ optional_parameters()

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.

◆ output_files()

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.

◆ required_config()

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.

◆ required_parameters()

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.

◆ set_parameters()

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.

◆ setup()

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.

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: