Skip to content

Commit 23522b4

Browse files
committed
refactor: remove PilotBundle
1 parent a2a30c3 commit 23522b4

File tree

5 files changed

+9
-135
lines changed

5 files changed

+9
-135
lines changed

src/DIRAC/Resources/Computing/AREXComputingElement.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import os
4949
import shutil
5050
import stat
51+
import tempfile
5152
import uuid
5253

5354
import requests
@@ -57,7 +58,6 @@
5758
from DIRAC.Core.Security.ProxyInfo import getVOfromProxyGroup
5859
from DIRAC.Core.Security.X509Chain import X509Chain # pylint: disable=import-error
5960
from DIRAC.Resources.Computing.ComputingElement import ComputingElement
60-
from DIRAC.Resources.Computing.PilotBundle import writeScript
6161
from DIRAC.WorkloadManagementSystem.Client import PilotStatus
6262

6363
MANDATORY_PARAMETERS = ["Queue"]
@@ -495,7 +495,11 @@ def _bundlePreamble(self, executableFile):
495495
if not os.access(executableFile, os.X_OK):
496496
os.chmod(executableFile, stat.S_IRWXU | stat.S_IRGRP | stat.S_IXGRP | stat.S_IROTH + stat.S_IXOTH)
497497

498-
return writeScript(wrapperContent, os.getcwd())
498+
with tempfile.NamedTemporaryFile(
499+
"w", delete=False, prefix="preamble-", suffix=f"-{executableFile}"
500+
) as bundleFile:
501+
bundleFile.write(wrapperContent)
502+
return bundleFile.name
499503

500504
def _getArcJobID(self, executableFile, inputs, outputs, delegation):
501505
"""Get an ARC JobID endpoint to upload executables and inputs.

src/DIRAC/Resources/Computing/LocalComputingElement.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
from DIRAC import S_OK, S_ERROR
4444

4545
from DIRAC.Resources.Computing.ComputingElement import ComputingElement
46-
from DIRAC.Resources.Computing.PilotBundle import bundleProxy, writeScript
4746
from DIRAC.Core.Utilities.List import uniqueElements
4847
from DIRAC.Core.Utilities.Subprocess import systemCall
4948

@@ -153,26 +152,12 @@ def submitJob(self, executableFile, proxy=None, numberOfJobs=1):
153152
if not os.access(executableFile, 5):
154153
os.chmod(executableFile, stat.S_IRWXU | stat.S_IRGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IXOTH)
155154

156-
# if no proxy is supplied, the executable can be submitted directly
157-
# otherwise a wrapper script is needed to get the proxy to the execution node
158-
# The wrapper script makes debugging more complicated and thus it is
159-
# recommended to transfer a proxy inside the executable if possible.
160-
if self.proxy and not proxy:
161-
proxy = self.proxy
162-
if proxy:
163-
self.log.verbose("Setting up proxy for payload")
164-
wrapperContent = bundleProxy(executableFile, proxy)
165-
name = writeScript(wrapperContent, os.getcwd())
166-
submitFile = name
167-
else: # no proxy
168-
submitFile = executableFile
169-
170155
jobStamps = []
171156
for _i in range(numberOfJobs):
172157
jobStamps.append(uuid.uuid4().hex)
173158

174159
batchDict = {
175-
"Executable": submitFile,
160+
"Executable": executableFile,
176161
"NJobs": numberOfJobs,
177162
"OutputDir": self.batchOutput,
178163
"ErrorDir": self.batchError,
@@ -186,8 +171,6 @@ def submitJob(self, executableFile, proxy=None, numberOfJobs=1):
186171
"NumberOfGPUs": self.numberOfGPUs,
187172
}
188173
resultSubmit = self.batchSystem.submitJob(**batchDict)
189-
if proxy:
190-
os.remove(submitFile)
191174

192175
if resultSubmit["Status"] == 0:
193176
self.submittedJobs += len(resultSubmit["Jobs"])

src/DIRAC/Resources/Computing/PilotBundle.py

Lines changed: 0 additions & 80 deletions
This file was deleted.

src/DIRAC/Resources/Computing/SSHBatchComputingElement.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from urllib.parse import urlparse
88

99
from DIRAC import S_ERROR, S_OK
10-
from DIRAC.Resources.Computing.PilotBundle import bundleProxy, writeScript
1110
from DIRAC.Resources.Computing.SSHComputingElement import SSHComputingElement
1211
from DIRAC.WorkloadManagementSystem.Client import PilotStatus
1312

@@ -80,18 +79,6 @@ def submitJob(self, executableFile, proxy, numberOfJobs=1):
8079
if not os.access(executableFile, 5):
8180
os.chmod(executableFile, stat.S_IRWXU | stat.S_IRGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IXOTH)
8281

83-
# if no proxy is supplied, the executable can be submitted directly
84-
# otherwise a wrapper script is needed to get the proxy to the execution node
85-
# The wrapper script makes debugging more complicated and thus it is
86-
# recommended to transfer a proxy inside the executable if possible.
87-
if proxy:
88-
self.log.verbose("Setting up proxy for payload")
89-
wrapperContent = bundleProxy(executableFile, proxy)
90-
name = writeScript(wrapperContent, os.getcwd())
91-
submitFile = name
92-
else: # no proxy
93-
submitFile = executableFile
94-
9582
# Submit jobs now
9683
restJobs = numberOfJobs
9784
submittedJobs = []
@@ -100,7 +87,7 @@ def submitJob(self, executableFile, proxy, numberOfJobs=1):
10087
if slots not in rankHosts:
10188
continue
10289
for host in rankHosts[slots]:
103-
result = self._submitJobToHost(submitFile, min(slots, restJobs), host)
90+
result = self._submitJobToHost(executableFile, min(slots, restJobs), host)
10491
if not result["OK"]:
10592
continue
10693

@@ -114,9 +101,6 @@ def submitJob(self, executableFile, proxy, numberOfJobs=1):
114101
if restJobs <= 0:
115102
break
116103

117-
if proxy:
118-
os.remove(submitFile)
119-
120104
result = S_OK(submittedJobs)
121105
result["PilotStampDict"] = stampDict
122106
return result

src/DIRAC/Resources/Computing/SSHComputingElement.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@
7878
from DIRAC.Core.Utilities.List import breakListIntoChunks, uniqueElements
7979
from DIRAC.Resources.Computing.BatchSystems.executeBatch import executeBatchContent
8080
from DIRAC.Resources.Computing.ComputingElement import ComputingElement
81-
from DIRAC.Resources.Computing.PilotBundle import bundleProxy, writeScript
8281

8382

8483
class SSH:
@@ -532,23 +531,7 @@ def submitJob(self, executableFile, proxy, numberOfJobs=1):
532531
if not os.access(executableFile, 5):
533532
os.chmod(executableFile, stat.S_IRWXU | stat.S_IRGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IXOTH)
534533

535-
# if no proxy is supplied, the executable can be submitted directly
536-
# otherwise a wrapper script is needed to get the proxy to the execution node
537-
# The wrapper script makes debugging more complicated and thus it is
538-
# recommended to transfer a proxy inside the executable if possible.
539-
if proxy:
540-
self.log.verbose("Setting up proxy for payload")
541-
wrapperContent = bundleProxy(executableFile, proxy)
542-
name = writeScript(wrapperContent, os.getcwd())
543-
submitFile = name
544-
else: # no proxy
545-
submitFile = executableFile
546-
547-
result = self._submitJobToHost(submitFile, numberOfJobs)
548-
if proxy:
549-
os.remove(submitFile)
550-
551-
return result
534+
return self._submitJobToHost(executableFile, numberOfJobs)
552535

553536
def _submitJobToHost(self, executableFile, numberOfJobs, host=None):
554537
"""Submit prepared executable to the given host"""

0 commit comments

Comments
 (0)