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>
20#include <TSystem.h>
21#include <fstream>
22#include <memory>
23#include <sstream>
24#include <cstdlib>
25#include <filesystem>
26
27//
28// method implementations
29//
30
32
33namespace EL
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;
57 switch (data.step)
58 {
60 {
61 data.batchInit = "export PATH LD_LIBRARY_PATH PYTHONPATH";
62 }
63 break;
64
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
ClassImp(EL::CondorDriver) namespace EL
#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
virtual::StatusCode doManagerStep(Detail::ManagerData &data) const override
a Driver to run on Condor batch systems
static const std::string optBatchSharedFileSystem
description: batch-specific options rationale: these options are for configuring batch drivers
Definition Job.h:508
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.
Definition index.py:1
TFile * file