ATLAS Offline Software
Loading...
Searching...
No Matches
CondorDriver.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// includes
10//
11
13
15#include <EventLoop/BatchJob.h>
16#include <EventLoop/Job.h>
21#include <TSystem.h>
22#include <fstream>
23#include <memory>
24#include <sstream>
25#include <cstdlib>
26#include <filesystem>
27
28//
29// method implementations
30//
31
33
34namespace EL
35{
36 void CondorDriver ::
37 testInvariant () const
38 {}
39
40
41
42 CondorDriver ::
43 CondorDriver ()
44 {
45 RCU_NEW_INVARIANT (this);
46 }
47
48
49
50 ::StatusCode CondorDriver ::
51 doManagerStep (Detail::ManagerData& data) const
52 {
53 RCU_READ_INVARIANT (this);
54 using namespace msgEventLoop;
56 switch (data.step)
57 {
59 {
60 data.batchInit = "export PATH LD_LIBRARY_PATH PYTHONPATH";
61 }
62 break;
63
66 {
67 // name of tarball being made (this needs to match BatchDriver.cxx)
68 const std::string tarballName("AnalysisPackage.tar.gz");
69
70 if (!data.resubmit)
71 {
72 if(!data.sharedFileSystem)
73 {
74 const std::string newLocation = data.submitDir + "/submit/" + tarballName;
75 int status=gSystem->CopyFile(tarballName.c_str(),newLocation.c_str());
76 if(status != 0)
77 {
78 ANA_MSG_ERROR ("failed to copy " << tarballName << " to " << newLocation);
79 return ::StatusCode::FAILURE;
80 }
81 }
82 }
83
84 {
85 std::ofstream file ((data.submitDir + "/submit/submit").c_str());
86 file << "executable = run\n";
87 file << "universe = vanilla\n";
88 file << "log = submit/run.log\n";
89 file << "output = submit/log-$(Item).out\n";
90 file << "error = submit/log-$(Item).err\n";
91 file << "initialdir = " << data.submitDir << "\n";
92 if(!data.sharedFileSystem)
93 { // Transfer data with non-shared file-systems
94 file << "should_transfer_files = YES\n";
95 file << "when_to_transfer_output = ON_EXIT\n";
96 file << "transfer_input_files = submit/" << tarballName << ", submit/segments, submit/config.root\n";
97 file << "transfer_output_files = fetch, status\n";
98 if (char* x509userproxy = std::getenv("X509_USER_PROXY")) {
99 std::filesystem::path proxyPath(x509userproxy);
100 std::filesystem::path proxyPathDestination(data.submitDir + "/submit/" + proxyPath.filename().string());
101 std::filesystem::copy(proxyPath,
102 proxyPathDestination,
103 std::filesystem::copy_options::overwrite_existing);
104 file << "x509userproxy = " << proxyPathDestination.string() <<"\n";
105 }
106 else {
107 ANA_MSG_INFO("X509_USER_PROXY not set");
108 }
109 }
110 file << "arguments = $(Item)\n";
111 file << "\n" << data.options.castString (Job::optCondorConf) << "\n";
112 file << "queue in ( ";
113 bool first {true};
114 for (std::size_t index : data.batchJobIndices)
115 {
116 if (first)
117 first = false;
118 else
119 file << ", ";
120 file << index;
121 }
122 file << " )\n";
123 }
124
125 {
126 std::ostringstream cmd;
127 cmd << "cd " << RCU::Shell::quote (data.submitDir) << "/submit && condor_submit "
128 << data.options.castString (Job::optSubmitFlags) << " submit";
129 if (gSystem->Exec (cmd.str().c_str()) != 0)
130 {
131 ANA_MSG_ERROR ("failed to execute: " << cmd.str());
132 return ::StatusCode::FAILURE;
133 }
134 }
135 data.submitted = true;
136 }
137 break;
138
139 default:
140 break;
141 }
142 return ::StatusCode::SUCCESS;
143 }
144}
#define RCU_NEW_INVARIANT(x)
Definition Assert.h:221
#define RCU_READ_INVARIANT(x)
Definition Assert.h:217
ClassImp(EL::CondorDriver) namespace EL
#define ANA_MSG_ERROR(xmsg,...)
Macro printing error messages.
#define ANA_MSG_INFO(xmsg,...)
Macro printing info messages.
#define ANA_CHECK(EXP)
check whether the given expression was successful
virtual::StatusCode doManagerStep(Detail::ManagerData &data) const override
a Driver to run on Condor batch systems
static const std::string optCondorConf
description: the name of the option for supplying extra parameters for condor systems
Definition Job.h:298
static const std::string optSubmitFlags
description: the name of the option for supplying extra submit parameters to batch systems rationale:...
Definition Job.h:292
@ doResubmit
call the actual doResubmit method
@ submitJob
do the actual job submission
Definition ManagerStep.h:92
@ batchScriptVar
create the variables needed for the batch-run script
Definition ManagerStep.h:83
This module defines the arguments passed from the BATCH driver to the BATCH worker.
::StatusCode StatusCode
StatusCode definition for legacy code.
std::string quote(const std::string &name)
effects: quote the given name to protect it from the shell returns: the quoted name guarantee: strong...
Definition ShellExec.cxx:65
Definition index.py:1
TFile * file