ATLAS Offline Software
Loading...
Searching...
No Matches
SubmitManager.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7
8
9//
10// includes
11//
12
14
16#include <EventLoop/Driver.h>
17#include <EventLoop/Job.h>
25#include <TFile.h>
26#include <TSystem.h>
27#include <fstream>
28
29using namespace EL::msgEventLoop;
30
31//
32// method implementations
33//
34
35namespace EL
36{
37 namespace Detail
38 {
39 std::pair<Detail::ManagerOrder,std::string> SubmitManager ::
40 getManagerOrder () const noexcept
41 {
42 return std::make_pair (ManagerOrder::OPERATION, "");
43 }
44
45
46
47 ::StatusCode SubmitManager ::
48 doManagerStep (Detail::ManagerData& data) const
49 {
50 switch (data.step)
51 {
53 {
54 if (data.resubmit)
56 else
58 }
59 break;
60
62 {
63 data.options = *data.job->options();
64 data.options.fetchDefaults (*data.driver->options());
65 }
66 break;
67
69 {
70 if (data.options.castBool (Job::optDisableMetrics, false))
71 if (!data.job->algsHas (MetricsSvc::name))
72 data.job->algsAdd (new MetricsSvc);
73 }
74 break;
75
77 {
78 {
79 std::unique_ptr<TFile> file (TFile::Open ((data.submitDir + "/driver.root").c_str(), "RECREATE"));
80 file->WriteObject (data.driver, "driver");
81 file->Close ();
82 }
83 data.job->sampleHandler().save (data.submitDir + "/input");
84 {
85 std::ofstream file ((data.submitDir + "/location").c_str());
86 file << data.submitDir << "\n";
87 }
88
89 SH::SampleHandler sh_hist;
90 for (SH::SampleHandler::iterator sample = data.job->sampleHandler().begin(),
91 end = data.job->sampleHandler().end(); sample != end; ++ sample)
92 {
93 const std::string histfile
94 = data.submitDir + "/hist-" + (*sample)->name() + ".root";
95 std::unique_ptr<SH::SampleHist> hist
96 (new SH::SampleHist ((*sample)->name(), histfile));
97 hist->meta()->fetch (*(*sample)->meta());
98 sh_hist.add (hist.release());
99 }
100 sh_hist.save (data.submitDir + "/hist");
101 }
102 break;
103
105 {
106 ANA_MSG_INFO ("submitting job in " << data.submitDir);
107 }
108 break;
109
111 {
112 if (!data.submitted)
113 {
114 ANA_MSG_FATAL ("Driver::submit not implemented in class " << typeid(*data.driver).name());
115 std::abort ();
116 }
117
118 ANA_MSG_DEBUG ("make submitted");
119 // this particular file can be checked to see if a job has
120 // been submitted successfully.
121 std::ofstream ((data.submitDir + "/submitted").c_str());
122 }
123 break;
124
126 {
128 }
129 break;
130
132 {
133 if (!data.submitted)
134 {
135 ANA_MSG_FATAL ("Driver::resubmit not implemented in class " << typeid(*data.driver).name());
136 std::abort ();
137 }
138
140 }
141 break;
142
143 default:
144 (void) true; // safe to do nothing
145 }
146 return ::StatusCode::SUCCESS;
147 }
148 }
149}
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
#define ANA_MSG_DEBUG(xmsg)
Macro printing debug messages.
#define ANA_MSG_FATAL(xmsg)
Macro printing fatal messages.
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
static const std::string optDisableMetrics
description: the option to turn off collection of performance data
Definition Job.h:430
static const std::string name
description: the name of the service
Definition MetricsSvc.h:26
A class that manages a list of Sample objects.
void save(const std::string &directory) const
save the list of samples to the given directory
std::vector< Sample * >::const_iterator iterator
the iterator to use
void add(Sample *sample)
add a sample to the handler
A sample that represents a single histogram file.
Definition SampleHist.h:31
@ finalSubmit
the final submit step
@ finalResubmit
the final resubmit step
@ submitJob
do the actual job submission
Definition ManagerStep.h:92
@ addSystemAlgs
add any system algorithms to the job that may need to get added
Definition ManagerStep.h:71
@ fillOptions
in this step we fill the options structure, combining the different locations from which we can pull ...
Definition ManagerStep.h:56
@ initial
this is just the initial step we do, nothing really happens here
Definition ManagerStep.h:45
@ prepareSubmitDir
prepare files in our submission directory
Definition ManagerStep.h:74
@ postSubmit
do whatever needs to be done after the submission is done
Definition ManagerStep.h:98
@ initialSubmit
the initial submit step
Definition ManagerStep.h:48
@ initialResubmit
the initial resubmit step
@ OPERATION
the base-operation performed (e.g. submit, retrieve)
This module defines the arguments passed from the BATCH driver to the BATCH worker.
::StatusCode StatusCode
StatusCode definition for legacy code.
an internal data structure for passing data between different manager objects anbd step
Definition ManagerData.h:46
TFile * file