Beispiel #1
0
 def test_argsok(self):
     myParser = trfArgParser(description='Test parser for argsok, %s' %
                             __name__)
     addTeaArguments(myParser)
     args = ['--cupsOfTea', '3']
     self.assertTrue(
         isinstance(myParser.parse_args(args), argparse.Namespace))
Beispiel #2
0
 def test_argsbad(self):
     myParser = trfArgParser(description='Test parser for argsbad, %s' %
                             __name__)
     addStandardTrfArgs(myParser)
     args = [
         '--verbose', '--outputFile', 'someFile', '--runNumber', '1234',
         '--unknownoption', 'what'
     ]
     self.assertRaises(SystemExit, myParser.parse_args, args)
Beispiel #3
0
 def test_triggerConfig(self):
     myParser = trfArgParser()
     addStandardTrfArgs(myParser)
     addTriggerArguments(myParser)
     args = ['--triggerConfig', 'r2e,e2e=MC:TRIGGERDB:124,154,132']
     myArgDict = vars(myParser.parse_args(args))
     properArgDict = {
         'r2e': 'MC:TRIGGERDB:124,154,132',
         'e2e': 'MC:TRIGGERDB:124,154,132'
     }
     self.assertTrue(isinstance(myArgDict, dict))
     self.assertEquals(myArgDict['triggerConfig']._value, properArgDict)
Beispiel #4
0
 def test_subStep(self):
     myParser = trfArgParser()
     addStandardTrfArgs(myParser)
     addAthenaArguments(myParser)
     args = [
         '--preExec', 'r2e:stuff', 'e2e:something', 'r2e:somemorestuff',
         'e2e:somethingElse'
     ]
     myArgDict = vars(myParser.parse_args(args))
     properArgDict = {
         'r2e': ['stuff', 'somemorestuff'],
         'e2e': ['something', 'somethingElse']
     }
     self.assertTrue(isinstance(myArgDict, dict))
     self.assertEquals(myArgDict['preExec']._value, properArgDict)
Beispiel #5
0
 def test_help(self):
     myParser = trfArgParser(description='Test parser for trf help, %s' %
                             __name__)
     addStandardTrfArgs(myParser)
     args = ['--help']
     self.assertRaises(SystemExit, myParser.parse_args, args)
Beispiel #6
0
    def __init__(self,
                 standardSignalHandlers=True,
                 standardTrfArgs=True,
                 standardValidationArgs=True,
                 trfName=path.basename(sys.argv[0]).rsplit('.py', 1)[0],
                 executor=set([
                     transformExecutor(),
                 ]),
                 exeArgs=None,
                 description=''):
        '''Transform class initialiser'''
        msg.debug('Welcome to ATLAS job transforms')

        ## @brief Get transform starting timestamp as early as possible
        self._transformStart = os.times()
        msg.debug('transformStart time is {0}'.format(self._transformStart))

        self._inFileValidationStart = None
        self._inFileValidationStop = None
        self._outFileValidationStart = None
        self._outFileValidationStop = None

        ## @brief Get trf pre-data as early as possible
        self._trfPredata = os.environ.get('TRF_PREDATA')

        ## Transform _name
        self._name = trfName

        ## @note Holder for arguments this trf understands
        #  Use @c argparse.SUPPRESS to have non-given arguments unset, rather than None
        #  Support reading arguments from a file using the notation @c @file
        self.parser = trfArgParser(description='Transform {0}. {1}'.format(
            trfName, description),
                                   argument_default=argparse.SUPPRESS,
                                   fromfile_prefix_chars='@')

        if standardTrfArgs:
            addStandardTrfArgs(self.parser)

        if standardValidationArgs:
            addValidationArguments(self.parser)
            addFileValidationArguments(self.parser)

        ## Argument dictionary for this transform
        self._argdict = dict()

        ## Dsta dictionary place holder (this maps data types to their argFile instances)
        self._dataDictionary = dict()

        # Transform executor list - initalise with an empty set
        self._executors = set()
        self._executorDictionary = {}

        # If we were passed executors at construction time then append them to the set:
        if executor is not None:
            self.appendToExecutorSet(executor)

        ## Transform exit code/message holders
        self._exitCode = None
        self._exitMsg = None

        ## Report object for this transform
        self._report = trfJobReport(parentTrf=self)

        ## Transform processed events
        self._processedEvents = None

        # Setup standard signal handling if asked
        if standardSignalHandlers:
            setTrfSignalHandlers(self._exitWithReport)
            msg.debug('Standard signal handlers established')