3
3
Module created to run failed jobs locally on a CVMFS-configured machine.
4
4
It creates the necessary environment, downloads the necessary files, modifies the necessary
5
5
files and runs the job
6
-
7
- Usage:
8
- dirac-production-runjoblocal [Data imput mode] [job ID]
9
-
10
- Arguments:
11
- Download (Job ID): Defines data aquisition as DownloadInputData
12
- Protocol (Job ID): Defines data acquisition as InputDataByProtocol
13
6
"""
14
- from __future__ import absolute_import
15
- from __future__ import division
16
- from __future__ import print_function
17
-
18
- __RCSID__ = "$Id$"
19
-
20
7
import os
21
8
import shutil
22
9
import ssl
23
10
11
+ from xml .etree import ElementTree as et
12
+
24
13
from urllib .request import urlopen
25
14
15
+ from DIRAC .Interfaces .API .Dirac import Dirac
16
+ from DIRAC .Core .Utilities .File import mkDir
26
17
from DIRAC .Core .Utilities .DIRACScript import DIRACScript as Script
18
+ from DIRAC .ConfigurationSystem .Client .Helpers .CSGlobals import getVO , getSetup
19
+ from DIRAC .ConfigurationSystem .Client .ConfigurationData import gConfigurationData
27
20
28
21
29
22
def __runSystemDefaults (jobID , vo ):
30
23
"""
31
24
Creates the environment for running the job and returns
32
25
the path for the other functions.
33
-
34
26
"""
35
- from DIRAC .Core .Utilities .File import mkDir
36
-
37
27
tempdir = str (vo ) + "job" + str (jobID ) + "temp"
38
28
mkDir (tempdir )
39
29
basepath = os .getcwd ()
@@ -44,10 +34,7 @@ def __downloadJobDescriptionXML(jobID, basepath):
44
34
"""
45
35
Downloads the jobDescription.xml file into the temporary directory
46
36
created.
47
-
48
37
"""
49
- from DIRAC .Interfaces .API .Dirac import Dirac
50
-
51
38
jdXML = Dirac ()
52
39
jdXML .getInputSandbox (jobID , basepath )
53
40
@@ -56,24 +43,18 @@ def __modifyJobDescription(jobID, basepath, downloadinputdata):
56
43
"""
57
44
Modifies the jobDescription.xml to, instead of DownloadInputData, it
58
45
uses InputDataByProtocol
59
-
60
46
"""
61
- from DIRAC import S_OK
62
-
63
47
if not downloadinputdata :
64
- from xml .etree import ElementTree as et
65
-
66
48
archive = et .parse (basepath + "InputSandbox" + str (jobID ) + os .path .sep + "jobDescription.xml" )
67
49
for element in archive .iter ():
68
50
if element .text == "DIRAC.WorkloadManagementSystem.Client.DownloadInputData" :
69
51
element .text = "DIRAC.WorkloadManagementSystem.Client.InputDataByProtocol"
70
52
archive .write (basepath + "InputSandbox" + str (jobID ) + os .path .sep + "jobDescription.xml" )
71
53
72
54
73
- def __downloadPilotScripts (basepath , diracpath ):
55
+ def __downloadPilotScripts ():
74
56
"""
75
57
Downloads the scripts necessary to configure the pilot
76
-
77
58
"""
78
59
79
60
context = ssl ._create_unverified_context ()
@@ -105,11 +86,6 @@ def __configurePilot(basepath, vo):
105
86
This method was created specifically for LHCb pilots, more info
106
87
about othe VOs is needed to make it more general.
107
88
"""
108
-
109
- from DIRAC .ConfigurationSystem .Client .Helpers .CSGlobals import getVO , getSetup
110
- from DIRAC .ConfigurationSystem .Client .ConfigurationData import gConfigurationData
111
-
112
- vo = getVO ()
113
89
currentSetup = getSetup ()
114
90
masterCS = gConfigurationData .getMasterServer ()
115
91
@@ -131,7 +107,6 @@ def __configurePilot(basepath, vo):
131
107
def __runJobLocally (jobID , basepath , vo ):
132
108
"""
133
109
Runs the job!
134
-
135
110
"""
136
111
ipr = __import__ (str (vo ) + "DIRAC.Interfaces.API." + str (vo ) + "Job" , globals (), locals (), [str (vo ) + "Job" ], - 1 )
137
112
voJob = getattr (ipr , str (vo ) + "Job" )
@@ -144,26 +119,22 @@ def __runJobLocally(jobID, basepath, vo):
144
119
145
120
@Script ()
146
121
def main ():
147
- Script .registerSwitch ("D:" , "Download=" , "Defines data acquisition as DownloadInputData" )
148
- Script .registerSwitch ("P :" , "Protocol=" , "Defines data acquisition as InputDataByProtocol" )
149
- Script .parseCommandLine (ignoreErrors = False )
122
+ Script .registerSwitch ("D:" , "Download=" , "Set jobID here. Defines data acquisition as DownloadInputData" )
123
+ Script .registerSwitch ("I :" , "Protocol=" , "Set jobID here. Defines data acquisition as InputDataByProtocol" )
124
+ switches , args = Script .parseCommandLine (ignoreErrors = False )
150
125
151
126
_downloadinputdata = False
152
127
_jobID = None
153
128
154
- for switch in Script . getUnprocessedSwitches () :
129
+ for switch in switches :
155
130
if switch [0 ] in ("D" , "Download" ):
156
131
_downloadinputdata = True
157
132
_jobID = switch [1 ]
158
133
if switch [0 ] in ("I" , "Protocol" ):
159
134
_downloadinputdata = False
160
135
_jobID = switch [1 ]
161
136
162
- from DIRAC .ConfigurationSystem .Client .Helpers .CSGlobals import Extensions
163
-
164
- ext = Extensions ()
165
- _vo = ext .getCSExtensions ()[0 ]
166
- _diracPath = Extensions ().getExtensionPath ("DIRAC" )
137
+ _vo = getVO ()
167
138
_dir = os .path .expanduser ("~" ) + os .path .sep
168
139
try :
169
140
_path = __runSystemDefaults (_jobID , _vo )
@@ -172,12 +143,11 @@ def main():
172
143
173
144
__modifyJobDescription (_jobID , _path , _downloadinputdata )
174
145
175
- __downloadPilotScripts (_path , _diracPath )
146
+ __downloadPilotScripts ()
176
147
177
148
__configurePilot (_path , _vo )
178
149
179
150
__runJobLocally (_jobID , _path , _vo )
180
-
181
151
finally :
182
152
os .chdir (_dir )
183
153
os .rename (_dir + ".dirac.cfg.old" , _dir + ".dirac.cfg" )
0 commit comments