@@ -417,7 +417,7 @@ def _getProxyFromDelegationID(self, delegationID):
417
417
418
418
#############################################################################
419
419
420
- def _writeXRSL (self , executableFile , inputs , outputs , diracXSecret ):
420
+ def _writeXRSL (self , executableFile , inputs , outputs , additionalEnv ):
421
421
"""Create the JDL for submission
422
422
423
423
:param str executableFile: executable to wrap in a XRSL file
@@ -465,7 +465,7 @@ def _writeXRSL(self, executableFile, inputs, outputs, diracXSecret):
465
465
(inputFiles=({executable} "{executableFile}") {xrslInputAdditions})
466
466
(stdout="{diracStamp}.out")
467
467
(stderr="{diracStamp}.err")
468
- (environment=("DIRAC_PILOT_STAMP" "{diracStamp}") ("DIRACX_SECRET" "{diracXSecret}") )
468
+ (environment=("DIRAC_PILOT_STAMP" "{diracStamp}") {additionalEnv} )
469
469
(outputFiles={xrslOutputFiles})
470
470
(queue={queue})
471
471
{xrslMPAdditions}
@@ -476,7 +476,7 @@ def _writeXRSL(self, executableFile, inputs, outputs, diracXSecret):
476
476
executable = os .path .basename (executableFile ),
477
477
xrslInputAdditions = xrslInputs ,
478
478
diracStamp = diracStamp ,
479
- diracXSecret = diracXSecret ,
479
+ additionalEnv = additionalEnv ,
480
480
queue = self .queue ,
481
481
xrslOutputFiles = xrslOutputs ,
482
482
xrslMPAdditions = xrslMPAdditions ,
@@ -502,7 +502,7 @@ def _bundlePreamble(self, executableFile):
502
502
bundleFile .write (wrapperContent )
503
503
return bundleFile .name
504
504
505
- def _getArcJobID (self , executableFile , inputs , outputs , delegation , diracXSecret ):
505
+ def _getArcJobID (self , executableFile , inputs , outputs , delegation , additionalEnv ):
506
506
"""Get an ARC JobID endpoint to upload executables and inputs.
507
507
508
508
:param str executableFile: executable to submit
@@ -517,7 +517,7 @@ def _getArcJobID(self, executableFile, inputs, outputs, delegation, diracXSecret
517
517
query = self ._urlJoin ("jobs" )
518
518
519
519
# Get the job into the ARC way
520
- xrslString , diracStamp = self ._writeXRSL (executableFile , inputs , outputs , diracXSecret )
520
+ xrslString , diracStamp = self ._writeXRSL (executableFile , inputs , outputs , additionalEnv )
521
521
xrslString += delegation
522
522
self .log .debug ("XRSL string submitted" , f"is { xrslString } " )
523
523
self .log .debug ("DIRAC stamp for job" , f"is { diracStamp } " )
@@ -570,7 +570,7 @@ def _uploadJobDependencies(self, arcJobID, executableFile, inputs):
570
570
self .log .verbose ("Input correctly uploaded" , fileToSubmit )
571
571
return S_OK ()
572
572
573
- def submitJob (self , executableFile , proxy , numberOfJobs = 1 , inputs = None , outputs = None , diracXSecrets = []):
573
+ def submitJob (self , executableFile , proxy , numberOfJobs = 1 , inputs = None , outputs = None , additionalEnv = []):
574
574
"""Method to submit job
575
575
Assume that the ARC queues are always of the format nordugrid-<batchSystem>-<queue>
576
576
And none of our supported batch systems have a "-" in their name
@@ -653,13 +653,16 @@ def submitJob(self, executableFile, proxy, numberOfJobs=1, inputs=None, outputs=
653
653
# Also : https://bugzilla.nordugrid.org/show_bug.cgi?id=4069
654
654
batchIDList = []
655
655
stampDict = {}
656
- secretDict = {}
656
+ additionalEnvMappingResponse = {}
657
657
for i in range (numberOfJobs ):
658
- if i > len (diracXSecrets ):
659
- currentSecret = ""
658
+ if i > len (additionalEnv ):
659
+ currentEnv = ""
660
660
else :
661
- currentSecret = diracXSecrets [i ]
662
- result = self ._getArcJobID (executableFile , inputs , outputs , delegation , currentSecret )
661
+ # AdditionalEnv[i] format:
662
+ # {"secret": "1_l0v3_1c3cr34m", ...}
663
+ # We merge them to have the right format: '("key" "value") (...)'
664
+ currentEnv = " " .join ([f"({ key } { value } )" for key , value in additionalEnv [i ]])
665
+ result = self ._getArcJobID (executableFile , inputs , outputs , delegation , currentEnv )
663
666
if not result ["OK" ]:
664
667
break
665
668
arcJobID , diracStamp = result ["Value" ]
@@ -673,8 +676,11 @@ def submitJob(self, executableFile, proxy, numberOfJobs=1, inputs=None, outputs=
673
676
jobReference = self ._arcIDToJobReference (arcJobID )
674
677
batchIDList .append (jobReference )
675
678
stampDict [jobReference ] = diracStamp
676
- secretDict [currentSecret ] = {}
677
- secretDict [currentSecret ]["PilotStamps" ] = [diracStamp ] # Used by DiracX to associate secrets and pilots
679
+
680
+ # Add all env variables we added into additionalEnvMappingResponse so we have:
681
+ # { "Stamp1": { "SECRET": "I_luv_strawberries", "...": "..." }, "Stamp2": {...} }
682
+ additionalEnvMappingResponse [diracStamp ] = additionalEnv [i ]
683
+
678
684
self .log .debug (
679
685
"Successfully submitted job" ,
680
686
f"{ jobReference } to CE { self .ceName } " ,
@@ -687,7 +693,7 @@ def submitJob(self, executableFile, proxy, numberOfJobs=1, inputs=None, outputs=
687
693
if batchIDList :
688
694
result = S_OK (batchIDList )
689
695
result ["PilotStampDict" ] = stampDict
690
- result ["SecretDict " ] = secretDict
696
+ result ["EnvMapping " ] = additionalEnvMappingResponse
691
697
else :
692
698
result = S_ERROR ("No ID obtained from the ARC job submission" )
693
699
return result
0 commit comments