Esempio n. 1
0
  def test_Gauss_Production_PR33857_1(self):
    """ Using ProdConf (production style). systemConfig = 'x86_64-slc6-gcc48-opt'

        This is taken from PR 33857 (and would fall back to SetupProject)
    """
    gLogger.always("**** GAUSS v49r5")

    ra = RunApplication()
    ra.applicationName = 'Gauss'
    ra.applicationVersion = 'v49r5'
    ra.systemConfig = 'x86_64-slc6-gcc48-opt'
    ra.commandOptions = ['$APPCONFIGOPTS/Gauss/Sim08-Beam4000GeV-mu100-2012-nu2.5.py',
                         '$APPCONFIGOPTS/Gauss/DataType-2012.py',
                         '$APPCONFIGOPTS/Gauss/RICHRandomHits.py',
                         '$APPCONFIGOPTS/Gauss/NoPacking.py',
                         '$DECFILESROOT/options/12877041.py',
                         '$LBPYTHIA8ROOT/options/Pythia8.py',
                         '$APPCONFIGOPTS/Gauss/G4PL_FTFP_BERT_EmNoCuts.py',
                         '$APPCONFIGOPTS/Persistency/Compression-ZLIB-1.py']
    ra.extraPackages = [('AppConfig', 'v3r277'),
                        ('Gen/DecFiles', 'v29r10'),
                        ('ProdConf', '')
                        ]
    ra.prodConfFileName = find_all('test_prodConf_gauss_v49r5.py', '..')[0]
    ra.applicationLog = '00033857_00000001_1_log.txt'
    ra.stdError = '00033857_00000001_1_err.txt'

    res = ra.run()
    self.assertTrue(res['OK'])
    self.assertEqual(res['Value'], (0, '', ''))
Esempio n. 2
0
  def test_DaVinci_2_Production_PR33857_7(self):
    """ Using ProdConf (production style). systemConfig = 'x86_64-slc6-gcc49-opt'

        This is taken from PR 33857
    """
    gLogger.always("**** DAVINCI v41r3")

    ra = RunApplication()
    ra.applicationName = 'DaVinci'
    ra.applicationVersion = 'v41r3'
    ra.systemConfig = 'x86_64-slc6-gcc49-opt'
    ra.commandOptions = ['$APPCONFIGOPTS/Merging/DVMergeDST.py',
                         '$APPCONFIGOPTS/DaVinci/DataType-2012.py',
                         '$APPCONFIGOPTS/Merging/WriteFSR.py',
                         '$APPCONFIGOPTS/Merging/MergeFSR.py']
    ra.extraPackages = [('AppConfig', 'v3r305'),
                        ('ProdConf', '')
                        ]
    ra.step_Number = 1
    ra.prodConfFileName = find_all('test_prodConf_davinci_v41r3.py', '..')[0]
    ra.applicationLog = '00033857_00000007_7_log.txt'
    ra.stdError = '00033857_00000007_7_err.txt'

    res = ra.run()
    self.assertTrue(res['OK'])
    self.assertEqual(res['Value'], (0, '', ''))
Esempio n. 3
0
  def test_DaVinci_new_gcc62(self):
    """ Using ProdConf (production style). systemConfig = 'x86_64-slc6-gcc62-opt'

        This is taken from step 130847
    """
    gLogger.always("**** DAVINCI v42r2")

    ra = RunApplication()
    ra.applicationName = 'DaVinci'
    ra.applicationVersion = 'v42r2'
    ra.systemConfig = 'x86_64-slc6-gcc62-opt'
    ra.commandOptions = ['$APPCONFIGOPTS/DaVinci/DV-Stripping27-Stripping.py',
                         '$APPCONFIGOPTS/DaVinci/DataType-2016.py',
                         '$APPCONFIGOPTS/DaVinci/InputType-RDST.py',
                         '$APPCONFIGOPTS/DaVinci/DV-RawEventJuggler-0_3-to-4_2.py']
    ra.extraPackages = [('AppConfig', 'v3r308'),
                        ('Det/SQLDDDB', 'v7r11'),
                        ('ProdConf', '')
                        ]
    ra.step_Number = 1
    ra.prodConfFileName = find_all('test_prodConf_davinci_v42r2.py', '..')[0]
    ra.applicationLog = '0daVinci_000v42r2_62_log.txt'
    ra.stdError = '0daVinci_000v42r2_62_err.txt'

    res = ra.run()
    self.assertTrue(res['OK'])
    self.assertEqual(res['Value'], (0, '', ''))
Esempio n. 4
0
  def test_Brunel_Production_PR33857_5(self):
    """ Using ProdConf (production style). systemConfig = 'x86_64-slc5-gcc46-opt'

        This is taken from PR 33857
    """
    gLogger.always("**** BRUNEL v43r2p11")

    ra = RunApplication()
    ra.applicationName = 'Brunel'
    ra.applicationVersion = 'v43r2p11'
    ra.systemConfig = 'x86_64-slc5-gcc46-opt'
    ra.commandOptions = ['$APPCONFIGOPTS/Brunel/DataType-2012.py',
                         '$APPCONFIGOPTS/Brunel/MC-WithTruth.py',
                         '$APPCONFIGOPTS/Brunel/Sim09-Run1.py',
                         '$APPCONFIGOPTS/Persistency/DST-multipleTCK-2012.py',
                         '$APPCONFIGOPTS/Persistency/Compression-ZLIB-1.py']
    ra.extraPackages = [('AppConfig', 'v3r302'),
                        ('ProdConf', '')
                        ]
    ra.prodConfFileName = find_all('test_prodConf_brunel_v43r2p11.py', '..')[0]
    ra.applicationLog = '00033857_00000005_5_log.txt'
    ra.stdError = '00033857_00000005_5_err.txt'

    res = ra.run()
    self.assertTrue(res['OK'])
    self.assertEqual(res['Value'], (0, '', ''))
Esempio n. 5
0
  def test_DaVinci_1_Production_PR33857_6(self):
    """ Using ProdConf (production style). systemConfig = 'x86_64-slc5-gcc46-opt'

        This is taken from PR 33857
    """
    gLogger.always("**** DAVINCI v32r2p1")

    ra = RunApplication()
    ra.applicationName = 'DaVinci'
    ra.applicationVersion = 'v32r2p1'
    ra.systemConfig = 'x86_64-slc5-gcc46-opt'
    ra.commandOptions = ['$CHARMCONFIGOPTS/MCFiltering/D02K3PiFromB2DstmunuXStripTrigFiltering_2012.py',
                         '$APPCONFIGOPTS/DaVinci/DataType-2012.py',
                         '$APPCONFIGOPTS/DaVinci/InputType-DST.py',
                         '$APPCONFIGOPTS/Persistency/Compression-ZLIB-1.py']
    ra.extraPackages = [('AppConfig', 'v3r305'),
                        ('CharmConfig', 'v3r30'),
                        ('ProdConf', '')
                        ]
    ra.step_Number = 1
    ra.prodConfFileName = find_all('test_prodConf_davinci_v32r2p1.py', '..')[0]
    ra.applicationLog = '00033857_00000006_6_log.txt'
    ra.stdError = '00033857_00000006_6_err.txt'

    res = ra.run()
    self.assertTrue(res['OK'])
    self.assertEqual(res['Value'], (0, '', ''))
Esempio n. 6
0
  def test_Boole_2_Production_PR33857(self):
    """ Using ProdConf (production style). Taken from PR 33857.
        Same as before but using "ANY" as CMT config
    """
    gLogger.always("**** Boole v30r1")

    ra = RunApplication()
    ra.applicationName = 'Boole'
    ra.applicationVersion = 'v30r1'
    ra.commandOptions = ['$APPCONFIGOPTS/Boole/Default.py',
                         '$APPCONFIGOPTS/Boole/DataType-2012.py',
                         '$APPCONFIGOPTS/Boole/NoPacking.py',
                         '$APPCONFIGOPTS/Boole/Boole-SetOdinRndTrigger.py',
                         '$APPCONFIGOPTS/Persistency/Compression-ZLIB-1.py']
    ra.extraPackages = [('AppConfig', 'v3r266'),
                        ('ProdConf', '')
                        ]
    ra.step_Number = 1
    ra.prodConfFileName = find_all('test_prodConf_boole_v30r1_2.py', '..')[0]
    ra.applicationLog = '00033857_00000002_3_log.txt'
    ra.stdError = '00033857_00000002_3_err.txt'

    res = ra.run()
    self.assertTrue(res['OK'])
    self.assertEqual(res['Value'], (0, '', ''))
Esempio n. 7
0
    def test__gaudirunCommand(self, _patch):
        """ Testing what is run (the gaudirun command, for example)
    """

        ra = RunApplication()
        ra.opsH = MagicMock()
        ra.opsH.getValue.return_value = 'gaudirun.py'

        # simplest
        res = str(ra._gaudirunCommand())
        expected = 'gaudirun.py'
        self.assertEqual(res, expected)

        # simplest with extra opts
        ra.extraOptionsLine = 'bla bla'
        res = str(ra._gaudirunCommand())
        expected = 'gaudirun.py gaudi_extra_options.py'
        self.assertEqual(res, expected)
        with open('gaudi_extra_options.py', 'r') as fd:
            geo = fd.read()
            self.assertEqual(geo, ra.extraOptionsLine)

        # productions style /1
        ra.prodConf = True
        ra.extraOptionsLine = ''
        ra.prodConfFileName = 'prodConf.py'
        res = str(ra._gaudirunCommand())
        expected = 'gaudirun.py prodConf.py'
        self.assertEqual(res, expected)

        # productions style /2 (multicore)
        ra.optFile = ''
        ra.multicore = True
        res = str(ra._gaudirunCommand())
        self.assertEqual(res, expected)  # it won't be allowed on this "CE"

        # productions style /3 (multicore and opts)
        ra.optFile = ''
        ra.extraOptionsLine = 'bla bla'
        res = str(ra._gaudirunCommand())
        expected = 'gaudirun.py prodConf.py gaudi_extra_options.py'
        self.assertEqual(res, expected)  # it won't be allowed on this "CE"

        # productions style /4
        ra.extraOptionsLine = ''
        ra.commandOptions = ['$APP/1.py', '$APP/2.py']
        res = str(ra._gaudirunCommand())
        expected = r'gaudirun.py $APP/1.py $APP/2.py prodConf.py'
        self.assertEqual(res, expected)
Esempio n. 8
0
  def test_Brunel_new_bestCMT(self):
    """ Using ProdConf (production style). systemConfig = 'ANY'

        This is taken from step 131287 (Reco17)
    """
    gLogger.always("**** Brunel v52r2")

    ra = RunApplication()
    ra.applicationName = 'Brunel'
    ra.applicationVersion = 'v52r2'
    ra.commandOptions = ['$APPCONFIGOPTS/Brunel/DataType-2017.py',
                         '$APPCONFIGOPTS/Brunel/rdst.py']
    ra.extraPackages = [('AppConfig', 'v3r323'),
                        ('Det/SQLDDDB', 'v7r11'),
                        ('ProdConf', '')
                        ]
    ra.step_Number = 1
    ra.prodConfFileName = find_all('test_prodConf_brunel_v52r2.py', '..')[0]
    ra.applicationLog = '0brunel_000v52r2_ANY_62_log.txt'
    ra.stdError = '0brunel_000v52r2_ANY_62_err.txt'

    self.assertRaises(LHCbApplicationError, ra.run)  # This will fail as there's no input file
Esempio n. 9
0
  def test_Moore_2_Production_PR33857_4(self):
    """ Using ProdConf (production style). systemConfig = 'x86_64-slc5-gcc46-opt'

        This is taken from PR 33857
    """
    gLogger.always("**** MOORE v14r8p1")

    ra = RunApplication()
    ra.applicationName = 'Moore'
    ra.applicationVersion = 'v14r8p1'
    ra.systemConfig = 'x86_64-slc5-gcc46-opt'
    ra.commandOptions = ['$APPCONFIGOPTS/Moore/MooreSimProductionForSeparateL0AppStep.py',
                         '$APPCONFIGOPTS/Conditions/TCK-0x409f0045.py',
                         '$APPCONFIGOPTS/Moore/DataType-2012.py']
    ra.extraPackages = [('AppConfig', 'v3r241'),
                        ('ProdConf', '')
                        ]
    ra.prodConfFileName = find_all('test_prodConf_moore_v14r8p1.py', '..')[0]
    ra.applicationLog = '00033857_00000004_4_log.txt'
    ra.stdError = '00033857_00000004_4_err.txt'

    res = ra.run()
    self.assertTrue(res['OK'])
    self.assertEqual(res['Value'], (0, '', ''))
Esempio n. 10
0
  def test_Moore_1_Production_PR33857_3(self):
    """ Using ProdConf (production style). systemConfig = 'x86_64-slc6-gcc48-opt'

        This is taken from PR 33857
    """
    gLogger.always("**** MOORE v20r4")

    ra = RunApplication()
    ra.applicationName = 'Moore'
    ra.applicationVersion = 'v20r4'
    ra.systemConfig = 'x86_64-slc6-gcc48-opt'
    ra.commandOptions = ['$APPCONFIGOPTS/L0App/L0AppSimProduction.py',
                         '$APPCONFIGOPTS/L0App/L0AppTCK-0x0045.py',
                         '$APPCONFIGOPTS/L0App/DataType-2012.py']
    ra.extraPackages = [('AppConfig', 'v3r200'),
                        ('ProdConf', '')
                        ]
    ra.prodConfFileName = find_all('test_prodConf_moore_v20r4.py', '..')[0]
    ra.applicationLog = '00033857_00000003_3_log.txt'
    ra.stdError = '00033857_00000003_3_err.txt'

    res = ra.run()
    self.assertTrue(res['OK'])
    self.assertEqual(res['Value'], (0, '', ''))
Esempio n. 11
0
    def execute(self,
                production_id=None,
                prod_job_id=None,
                wms_job_id=None,
                workflowStatus=None,
                stepStatus=None,
                wf_commons=None,
                step_commons=None,
                step_id=None,
                step_number=None):
        """ The main execution method of GaudiApplication. It runs a gaudirun app using RunApplication module.
        This is the module used for each and every job of productions. It can also be used by users.
    """

        try:
            super(GaudiApplication,
                  self).execute(__RCSID__, production_id, prod_job_id,
                                wms_job_id, workflowStatus, stepStatus,
                                wf_commons, step_commons, step_number, step_id)

            if not self._checkWFAndStepStatus():
                return S_OK()

            self._resolveInputVariables()

            self.log.info("Executing application %s %s for binary tag %s" %
                          (self.applicationName, self.applicationVersion,
                           self.systemConfig))
            if self.jobType.lower() == 'merge' in self.siteName:
                self._disableWatchdogCPUCheck()

            # Resolve options files
            commandOptions = []
            if self.optionsFile and self.optionsFile != "None":
                for fileopt in self.optionsFile.split(';'):
                    if os.path.exists(
                            '%s/%s' %
                        (os.getcwd(), os.path.basename(fileopt))):
                        commandOptions.append(fileopt)
                    # Otherwise take the one from the application options directory
                    elif re.search(r'\$', fileopt):
                        self.log.info(
                            'Found options file containing environment variable: %s'
                            % fileopt)
                        commandOptions.append(fileopt)
                    else:
                        self.log.error(
                            'Cannot process options: "%s" not found via environment variable or in local directory'
                            % (fileopt))

            self.log.info('Final options files: %s' %
                          (', '.join(commandOptions)))

            runNumberGauss = 0
            firstEventNumberGauss = 0
            if self.applicationName.lower(
            ) == "gauss" and self.production_id and self.prod_job_id:
                if self.jobType.lower() == 'user':
                    eventsMax = self.numberOfEvents
                else:
                    # maintaining backward compatibility
                    eventsMax = self.maxNumberOfEvents if self.maxNumberOfEvents else self.numberOfEvents
                runNumberGauss = int(self.production_id) * 100 + int(
                    self.prod_job_id)
                firstEventNumberGauss = eventsMax * (int(self.prod_job_id) -
                                                     1) + 1

            if self.optionsLine or self.jobType.lower() == 'user':
                self.log.debug("Won't get any step outputs (USER job)")
                stepOutputs = []
                stepOutputTypes = []
                histogram = False
            else:
                self.log.debug("Getting the step outputs")
                stepOutputs, stepOutputTypes, histogram = self._determineOutputs(
                )
                self.log.debug(
                    "stepOutputs, stepOutputTypes, histogram  ==>  %s, %s, %s"
                    % (stepOutputs, stepOutputTypes, histogram))

            prodConfFileName = ''
            if self.optionsLine or self.jobType.lower() == 'user':
                # Prepare standard project run time options
                generatedOpts = 'gaudi_extra_options.py'
                if os.path.exists(generatedOpts):
                    os.remove(generatedOpts)
                inputDataOpts = getDataOptions(
                    self.applicationName, self.stepInputData,
                    self.inputDataType,
                    self.poolXMLCatName)['Value']  # always OK
                projectOpts = getModuleOptions(
                    self.applicationName, self.numberOfEvents, inputDataOpts,
                    self.optionsLine, runNumberGauss, firstEventNumberGauss,
                    self.jobType)['Value']  # always OK
                self.log.info('Extra options generated for %s %s step:' %
                              (self.applicationName, self.applicationVersion))
                print projectOpts  # Always useful to see in the logs (don't use gLogger as we often want to cut n' paste)
                with open(generatedOpts, 'w') as options:
                    options.write(projectOpts)
                commandOptions.append(generatedOpts)

            else:
                prodConfFileName = self.createProdConfFile(
                    stepOutputTypes, histogram, runNumberGauss,
                    firstEventNumberGauss)

            # How to run the application
            ra = RunApplication()
            # lb-run stuff
            ra.applicationName = self.applicationName
            ra.applicationVersion = self.applicationVersion
            ra.systemConfig = self.systemConfig
            ra.extraPackages = self.extraPackages
            ra.runTimeProject = self.runTimeProjectName
            ra.runTimeProjectVersion = self.runTimeProjectVersion
            # actual stuff to run
            ra.command = self.executable
            ra.extraOptionsLine = self.extraOptionsLine
            ra.commandOptions = commandOptions
            if self.multicoreStep.upper() == 'Y':
                ra.multicore = self.multicoreJob
            ra.prodConfFileName = prodConfFileName
            if self.applicationLog:
                ra.applicationLog = self.applicationLog
            ra.stdError = self.stdError

            # Now really running
            try:
                self.setApplicationStatus(
                    '%s step %s' % (self.applicationName, self.step_number))
                ra.run(
                )  # This would trigger an exception in case of failure, or application status != 0
            except LHCbApplicationError as appError:
                # Running gdb in case of core dump
                if 'core' in [
                        fileProduced.split('.')[0]
                        for fileProduced in os.listdir('.')
                ]:
                    # getting the environment where the application executed
                    app = ra.applicationName + '/' + ra.applicationVersion
                    envCommand = ra.lbrunCommand.split(
                        app)[0] + ' --py -A ' + app

                    # FIXME: The following may raise CalledProcessError if the application is not lb-run native.
                    # The exception will be caught at the end of the module.
                    # We enter here iff the application fails, and there's a core dump, so it's ~OKish.
                    # Nevertheless, it would be better if it was handled correctly.
                    lhcbApplicationEnv = eval(
                        subprocess.check_output(shlex.split(envCommand)))

                    # now running the GDB command
                    gdbCommand = "gdb python core.* >> %s_Step%s_coredump.log" % (
                        self.applicationName, self.step_number)
                    rg = RunApplication()
                    rg._runApp(gdbCommand, lhcbApplicationEnv)
                raise appError

            self.log.info("Going to manage %s output" % self.applicationName)
            self._manageAppOutput(stepOutputs)

            # Still have to set the application status e.g. user job case.
            self.setApplicationStatus(
                '%s %s Successful' %
                (self.applicationName, self.applicationVersion))

            return S_OK("%s %s Successful" %
                        (self.applicationName, self.applicationVersion))

        except LbRunError as lbre:  # This is the case for lb-run/environment errors
            self.setApplicationStatus(repr(lbre))
            return S_ERROR(DErrno.EWMSRESC, str(lbre))
        except LHCbApplicationError as lbae:  # This is the case for real application errors
            self.setApplicationStatus(repr(lbae))
            return S_ERROR(str(lbae))
        except LHCbDIRACError as lbde:  # This is the case for LHCbDIRAC errors (e.g. subProcess call failed)
            self.setApplicationStatus(repr(lbde))
            return S_ERROR(str(lbde))
        except Exception as exc:  # pylint:disable=broad-except
            self.log.exception("Failure in GaudiApplication execute module",
                               lException=exc,
                               lExcInfo=True)
            self.setApplicationStatus("Error in GaudiApplication module")
            return S_ERROR(str(exc))
        finally:
            super(GaudiApplication, self).finalize(__RCSID__)