2 from AnalysisAlgorithmsConfig.CPBaseRunner
import CPBaseRunner
3 from AnalysisAlgorithmsConfig.ConfigAccumulator
import ConfigAccumulator
8 self.logger.
info(
"EventLoopCPRunScript initialized")
14 derivedGroup = self.parser.add_argument_group(
'EventLoop specific arguments')
15 derivedGroup.add_argument(
'--direct-driver', dest=
'direct_driver',
16 action=
'store_true', help=
'Run the job with the direct driver')
17 derivedGroup.add_argument(
'--strip', dest=
'strip', action=
'store_true', help=
'Move the analysis root file to the top level, and delete the work directory.'
18 ' Mainly useful for standardizing the output with the Athena framework.')
19 derivedGroup.add_argument(
'--work-dir', dest=
'work_dir', default=
'workDir', help=
'The work directory for the EL job')
23 from AnaAlgorithm.AlgSequence
import AlgSequence
25 self.logger.
info(
"Configuring algorithms based on YAML file")
27 self.logger.
info(
"Configuring common services")
28 configAccumulator = ConfigAccumulator(autoconfigFromFlags=self.flags,
30 noSystematics=self.args.no_systematics)
31 self.logger.
info(
"Configuring algorithms")
32 configSeq.fullConfigure(configAccumulator)
38 sampleFiles = ROOT.SH.SampleLocal(f
"{self.args.output_name}")
39 self.logger.
info(
"Adding files to the sample handler")
40 for file
in self.inputList:
47 self.logger.
info(
"Moving the analysis root file to the top level, and deleting the work directory. (--strip option)")
48 workDir = os.path.realpath(self.args.work_dir)
49 rootfilePath = os.path.realpath(os.path.join(workDir,
'data-ANALYSIS', f
'{self.args.output_name}.root'))
50 currentDir = os.getcwd()
51 shutil.move(rootfilePath, os.path.join(currentDir, f
"{self.args.output_name}.root"))
52 shutil.rmtree(workDir)
53 os.remove(os.path.join(currentDir, self.args.work_dir))
57 Important if you want to run code after submitting the job, with external driver e.g., ExecDriver.
58 Assistant function to call driver submit. Move the submission to a child process to avoid the main process being terminated.
59 Directly calling external driver submission will not return controls to the main process, the main thread will be terminated.
62 if (pid := os.fork()) == 0:
63 driver.submit(self.
job, self.args.work_dir)
78 self.
job = ROOT.EL.Job()
80 self.
job.
options().setDouble(ROOT.EL.Job.optMaxEvents, self.flags.Exec.MaxEvents)
81 self.
job.
options().setString(ROOT.EL.Job.optSubmitDirMode,
'unique-link')
84 self.
job.outputAdd(ROOT.EL.OutputStream(
'ANALYSIS'))
86 driver = ROOT.EL.DirectDriver()
if self.args.direct_driver
else ROOT.EL.ExecDriver()