ATLAS Offline Software
Loading...
Searching...
No Matches
CondorDriver.cxx File Reference
#include <EventLoop/CondorDriver.h>
#include <AsgMessaging/StatusCode.h>
#include <EventLoop/BatchJob.h>
#include <EventLoop/Job.h>
#include <EventLoop/ManagerData.h>
#include <EventLoop/MessageCheck.h>
#include <RootCoreUtils/Assert.h>
#include <TSystem.h>
#include <fstream>
#include <memory>
#include <sstream>
#include <cstdlib>
#include <filesystem>

Go to the source code of this file.

Functions

 ClassImp (EL::CondorDriver) namespace EL

Function Documentation

◆ ClassImp()

ClassImp ( EL::CondorDriver )
Author
Nils Krumnack

Definition at line 31 of file CondorDriver.cxx.

34{
35 void CondorDriver ::
36 testInvariant () const
37 {
38 RCU_INVARIANT (this != 0);
39 }
40
41
42
43 CondorDriver ::
44 CondorDriver ()
45 {
46 RCU_NEW_INVARIANT (this);
47 }
48
49
50
51 ::StatusCode CondorDriver ::
52 doManagerStep (Detail::ManagerData& data) const
53 {
54 RCU_READ_INVARIANT (this);
55 using namespace msgEventLoop;
56 ANA_CHECK (BatchDriver::doManagerStep (data));
57 switch (data.step)
58 {
59 case Detail::ManagerStep::batchScriptVar:
60 {
61 data.batchInit = "export PATH LD_LIBRARY_PATH PYTHONPATH";
62 }
63 break;
64
65 case Detail::ManagerStep::submitJob:
66 case Detail::ManagerStep::doResubmit:
67 {
68 // name of tarball being made (this needs to match BatchDriver.cxx)
69 const std::string tarballName("AnalysisPackage.tar.gz");
70
71 if (!data.resubmit)
72 {
73 if(!data.options.castBool(Job::optBatchSharedFileSystem,true))
74 {
75 const std::string newLocation = data.submitDir + "/submit/" + tarballName;
76 int status=gSystem->CopyFile(tarballName.c_str(),newLocation.c_str());
77 if(status != 0)
78 {
79 ANA_MSG_ERROR ("failed to copy " << tarballName << " to " << newLocation);
80 return ::StatusCode::FAILURE;
81 }
82 }
83 }
84
85 {
86 std::ofstream file ((data.submitDir + "/submit/submit").c_str());
87 file << "executable = run\n";
88 file << "universe = vanilla\n";
89 file << "log = submit/run.log\n";
90 file << "output = submit/log-$(Item).out\n";
91 file << "error = submit/log-$(Item).err\n";
92 file << "initialdir = " << data.submitDir << "\n";
93 if(!data.options.castBool(Job::optBatchSharedFileSystem,true))
94 { // Transfer data with non-shared file-systems
95 file << "should_transfer_files = YES\n";
96 file << "when_to_transfer_output = ON_EXIT\n";
97 file << "transfer_input_files = submit/" << tarballName << ", submit/segments, submit/config.root\n";
98 file << "transfer_output_files = fetch, status\n";
99 if (char* x509userproxy = std::getenv("X509_USER_PROXY")) {
100 std::filesystem::path proxyPath(x509userproxy);
101 std::filesystem::path proxyPathDestination(data.submitDir + "/submit/" + proxyPath.filename().string());
102 std::filesystem::copy(proxyPath,
103 proxyPathDestination,
104 std::filesystem::copy_options::overwrite_existing);
105 file << "x509userproxy = " << proxyPathDestination.string() <<"\n";
106 }
107 else {
108 ANA_MSG_INFO("X509_USER_PROXY not set");
109 }
110 }
111 file << "arguments = $(Item)\n";
112 file << "\n" << data.options.castString (Job::optCondorConf) << "\n";
113 file << "queue in ( ";
114 bool first {true};
115 for (std::size_t index : data.batchJobIndices)
116 {
117 if (first)
118 first = false;
119 else
120 file << ", ";
121 file << index;
122 }
123 file << " )\n";
124 }
125
126 {
127 std::ostringstream cmd;
128 cmd << "cd " << data.submitDir << "/submit && condor_submit "
129 << data.options.castString (Job::optSubmitFlags) << " submit";
130 if (gSystem->Exec (cmd.str().c_str()) != 0)
131 {
132 ANA_MSG_ERROR ("failed to execute: " << cmd.str());
133 return ::StatusCode::FAILURE;
134 }
135 }
136 data.submitted = true;
137 }
138 break;
139
140 default:
141 break;
142 }
143 return ::StatusCode::SUCCESS;
144 }
145}
#define RCU_INVARIANT(x)
Definition Assert.h:189
#define RCU_NEW_INVARIANT(x)
Definition Assert.h:221
#define RCU_READ_INVARIANT(x)
Definition Assert.h:217
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
#define ANA_CHECK(EXP)
check whether the given expression was successful
bool first
Definition DeMoScan.py:534
Definition index.py:1
status
Definition merge.py:16
TFile * file