@@ -417,7 +417,7 @@ def _getProxyFromDelegationID(self, delegationID):
417417
418418 #############################################################################
419419
420- def _writeXRSL (self , executableFile , inputs , outputs , diracXSecret ):
420+ def _writeXRSL (self , executableFile , inputs , outputs , additionalEnv ):
421421 """Create the JDL for submission
422422
423423 :param str executableFile: executable to wrap in a XRSL file
@@ -465,7 +465,7 @@ def _writeXRSL(self, executableFile, inputs, outputs, diracXSecret):
465465(inputFiles=({executable} "{executableFile}") {xrslInputAdditions})
466466(stdout="{diracStamp}.out")
467467(stderr="{diracStamp}.err")
468- (environment=("DIRAC_PILOT_STAMP" "{diracStamp}") ("DIRACX_SECRET" "{diracXSecret}") )
468+ (environment=("DIRAC_PILOT_STAMP" "{diracStamp}") {additionalEnv} )
469469(outputFiles={xrslOutputFiles})
470470(queue={queue})
471471{xrslMPAdditions}
@@ -476,7 +476,7 @@ def _writeXRSL(self, executableFile, inputs, outputs, diracXSecret):
476476 executable = os .path .basename (executableFile ),
477477 xrslInputAdditions = xrslInputs ,
478478 diracStamp = diracStamp ,
479- diracXSecret = diracXSecret ,
479+ additionalEnv = additionalEnv ,
480480 queue = self .queue ,
481481 xrslOutputFiles = xrslOutputs ,
482482 xrslMPAdditions = xrslMPAdditions ,
@@ -502,7 +502,7 @@ def _bundlePreamble(self, executableFile):
502502 bundleFile .write (wrapperContent )
503503 return bundleFile .name
504504
505- def _getArcJobID (self , executableFile , inputs , outputs , delegation , diracXSecret ):
505+ def _getArcJobID (self , executableFile , inputs , outputs , delegation , additionalEnv ):
506506 """Get an ARC JobID endpoint to upload executables and inputs.
507507
508508 :param str executableFile: executable to submit
@@ -517,7 +517,7 @@ def _getArcJobID(self, executableFile, inputs, outputs, delegation, diracXSecret
517517 query = self ._urlJoin ("jobs" )
518518
519519 # 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 )
521521 xrslString += delegation
522522 self .log .debug ("XRSL string submitted" , f"is { xrslString } " )
523523 self .log .debug ("DIRAC stamp for job" , f"is { diracStamp } " )
@@ -570,7 +570,7 @@ def _uploadJobDependencies(self, arcJobID, executableFile, inputs):
570570 self .log .verbose ("Input correctly uploaded" , fileToSubmit )
571571 return S_OK ()
572572
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 = []):
574574 """Method to submit job
575575 Assume that the ARC queues are always of the format nordugrid-<batchSystem>-<queue>
576576 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=
653653 # Also : https://bugzilla.nordugrid.org/show_bug.cgi?id=4069
654654 batchIDList = []
655655 stampDict = {}
656- secretDict = {}
656+ additionalEnvMappingResponse = {}
657657 for i in range (numberOfJobs ):
658- if i > len (diracXSecrets ):
659- currentSecret = ""
658+ if i > len (additionalEnv ):
659+ currentEnv = ""
660660 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 )
663666 if not result ["OK" ]:
664667 break
665668 arcJobID , diracStamp = result ["Value" ]
@@ -673,8 +676,11 @@ def submitJob(self, executableFile, proxy, numberOfJobs=1, inputs=None, outputs=
673676 jobReference = self ._arcIDToJobReference (arcJobID )
674677 batchIDList .append (jobReference )
675678 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+
678684 self .log .debug (
679685 "Successfully submitted job" ,
680686 f"{ jobReference } to CE { self .ceName } " ,
@@ -687,7 +693,7 @@ def submitJob(self, executableFile, proxy, numberOfJobs=1, inputs=None, outputs=
687693 if batchIDList :
688694 result = S_OK (batchIDList )
689695 result ["PilotStampDict" ] = stampDict
690- result ["SecretDict " ] = secretDict
696+ result ["EnvMapping " ] = additionalEnvMappingResponse
691697 else :
692698 result = S_ERROR ("No ID obtained from the ARC job submission" )
693699 return result
0 commit comments