15
15
Port added to the CE host name to interact with AREX services.
16
16
17
17
ProxyTimeLeftBeforeRenewal:
18
- Time in seconds before the AREXCE renews proxy of submitted pilots .
18
+ Time in seconds before the AREXCE renews proxy of submitted payloads .
19
19
20
20
RESTVersion:
21
21
Version of the REST interface to use.
@@ -105,34 +105,33 @@ def setToken(self, token, valid):
105
105
super ().setToken (token , valid )
106
106
self .headers ["Authorization" ] = "Bearer " + self .token ["access_token" ]
107
107
108
- def _arcToDiracID (self , arcJobID ):
109
- """Convert an ARC jobID into a DIRAC jobID .
108
+ def _arcIDToJobReference (self , arcJobID ):
109
+ """Convert an ARC jobID into a job reference .
110
110
Example: 1234 becomes https://<ce>:<port>/arex/1234
111
111
112
112
:param str: ARC jobID
113
- :return: DIRAC jobID
113
+ :return: job reference, defined as an ARC jobID with additional details
114
114
"""
115
115
# Add CE and protocol information to arc Job ID
116
116
if "://" in arcJobID :
117
117
self .log .warn ("Identifier already in ARC format" , arcJobID )
118
118
return arcJobID
119
119
120
- diracJobID = "https://" + self .ceHost + ":" + self .port + "/arex/" + arcJobID
121
- return diracJobID
120
+ return f"https://{ self .ceHost } :{ self .port } /arex/{ arcJobID } "
122
121
123
- def _DiracToArcID (self , diracJobID ):
124
- """Convert a DIRAC jobID into an ARC jobID.
122
+ def _jobReferenceToArcID (self , jobReference ):
123
+ """Convert a job reference into an ARC jobID.
125
124
Example: https://<ce>:<port>/arex/1234 becomes 1234
126
125
127
- :param str: DIRAC jobID
126
+ :param str: job reference, defined as an ARC jobID with additional details
128
127
:return: ARC jobID
129
128
"""
130
129
# Remove CE and protocol information from arc Job ID
131
- if "://" in diracJobID :
132
- arcJobID = diracJobID .split ("arex/" )[- 1 ]
130
+ if "://" in jobReference :
131
+ arcJobID = jobReference .split ("arex/" )[- 1 ]
133
132
return arcJobID
134
- self .log .warn ("Identifier already in REST format?" , diracJobID )
135
- return diracJobID
133
+ self .log .warn ("Identifier already in REST format?" , jobReference )
134
+ return jobReference
136
135
137
136
#############################################################################
138
137
@@ -494,12 +493,12 @@ def submitJob(self, executableFile, proxy, numberOfJobs=1, inputs=None, outputs=
494
493
if not result ["OK" ]:
495
494
break
496
495
497
- jobID = self ._arcToDiracID (arcJobID )
498
- batchIDList .append (jobID )
499
- stampDict [jobID ] = diracStamp
496
+ jobReference = self ._arcIDToJobReference (arcJobID )
497
+ batchIDList .append (jobReference )
498
+ stampDict [jobReference ] = diracStamp
500
499
self .log .debug (
501
500
"Successfully submitted job" ,
502
- f"{ jobID } to CE { self .ceHost } " ,
501
+ f"{ jobReference } to CE { self .ceHost } " ,
503
502
)
504
503
505
504
if batchIDList :
@@ -514,16 +513,16 @@ def submitJob(self, executableFile, proxy, numberOfJobs=1, inputs=None, outputs=
514
513
def killJob (self , jobIDList ):
515
514
"""Kill the specified jobs
516
515
517
- :param list jobIDList: list of DIRAC Job IDs
516
+ :param list jobIDList: list of Job references
518
517
"""
519
518
if not isinstance (jobIDList , list ):
520
519
jobIDList = [jobIDList ]
521
520
self .log .debug ("Killing jobs" , "," .join (jobIDList ))
522
521
523
- # Convert DIRAC jobs to ARC jobs
524
- # DIRAC Jobs might be stored with a DIRAC stamp (":::XXXXX") that should be removed
525
- jList = [self ._DiracToArcID (job .split (":::" )[0 ]) for job in jobIDList ]
526
- return self ._killJob (jList )
522
+ # Convert job references to ARC jobs
523
+ # Job references might be stored with a DIRAC stamp (":::XXXXX") that should be removed
524
+ arcJobList = [self ._jobReferenceToArcID (job .split (":::" )[0 ]) for job in jobIDList ]
525
+ return self ._killJob (arcJobList )
527
526
528
527
def _killJob (self , arcJobList ):
529
528
"""Kill the specified jobs
@@ -556,16 +555,16 @@ def _killJob(self, arcJobList):
556
555
def cleanJob (self , jobIDList ):
557
556
"""Clean files related to the specified jobs
558
557
559
- :param list jobIDList: list of DIRAC Job IDs
558
+ :param list jobIDList: list of job references
560
559
"""
561
560
if not isinstance (jobIDList , list ):
562
561
jobIDList = [jobIDList ]
563
562
self .log .debug ("Cleaning jobs" , "," .join (jobIDList ))
564
563
565
- # Convert DIRAC jobs to ARC jobs
566
- # DIRAC Jobs might be stored with a DIRAC stamp (":::XXXXX") that should be removed
567
- jList = [self ._DiracToArcID (job .split (":::" )[0 ]) for job in jobIDList ]
568
- return self ._cleanJob (jList )
564
+ # Convert job references to ARC jobs
565
+ # Job references might be stored with a DIRAC stamp (":::XXXXX") that should be removed
566
+ arcJobList = [self ._jobReferenceToArcID (job .split (":::" )[0 ]) for job in jobIDList ]
567
+ return self ._cleanJob (arcJobList )
569
568
570
569
def _cleanJob (self , arcJobList ):
571
570
"""Clean files related to the specified jobs
@@ -721,7 +720,7 @@ def _renewDelegation(self, delegationID):
721
720
def getJobStatus (self , jobIDList ):
722
721
"""Get the status information for the given list of jobs.
723
722
724
- :param list jobIDList: list of DIRAC Job ID , followed by the DIRAC stamp.
723
+ :param list jobIDList: list of job references , followed by the DIRAC stamp.
725
724
"""
726
725
result = self ._checkSession ()
727
726
if not result ["OK" ]:
@@ -732,9 +731,9 @@ def getJobStatus(self, jobIDList):
732
731
jobIDList = [jobIDList ]
733
732
734
733
self .log .debug ("Getting status of jobs:" , jobIDList )
735
- # Convert DIRAC jobs to ARC jobs and encapsulate them in a dictionary for the REST query
736
- # DIRAC Jobs might be stored with a DIRAC stamp (":::XXXXX") that should be removed
737
- arcJobsJson = {"job" : [{"id" : self ._DiracToArcID (job .split (":::" )[0 ])} for job in jobIDList ]}
734
+ # Convert job references to ARC jobs and encapsulate them in a dictionary for the REST query
735
+ # Job references might be stored with a DIRAC stamp (":::XXXXX") that should be removed
736
+ arcJobsJson = {"job" : [{"id" : self ._jobReferenceToArcID (job .split (":::" )[0 ])} for job in jobIDList ]}
738
737
739
738
# Prepare the command
740
739
params = {"action" : "status" }
@@ -757,16 +756,16 @@ def getJobStatus(self, jobIDList):
757
756
arcJobsInfo = [arcJobsInfo ]
758
757
759
758
for arcJob in arcJobsInfo :
760
- jobID = self ._arcToDiracID (arcJob ["id" ])
759
+ jobReference = self ._arcIDToJobReference (arcJob ["id" ])
761
760
# ARC REST interface returns hyperbole
762
761
arcState = arcJob ["state" ].capitalize ()
763
- self .log .debug ("REST ARC status" , f"for job { jobID } is { arcState } " )
764
- resultDict [jobID ] = self .mapStates [arcState ]
762
+ self .log .debug ("REST ARC status" , f"for job { jobReference } is { arcState } " )
763
+ resultDict [jobReference ] = self .mapStates [arcState ]
765
764
766
765
# Cancel held jobs so they don't sit in the queue forever
767
766
if arcState == "Hold" :
768
767
jobsToCancel .append (arcJob ["id" ])
769
- self .log .debug (f"Killing held job { jobID } " )
768
+ self .log .debug (f"Killing held job { jobReference } " )
770
769
771
770
# Renew delegations to renew the proxies of the jobs
772
771
result = self ._getDelegationIDs ()
@@ -793,7 +792,7 @@ def getJobStatus(self, jobIDList):
793
792
def getJobLog (self , jobID ):
794
793
"""Get job logging info
795
794
796
- :param str jobID: DIRAC JobID followed by the DIRAC stamp.
795
+ :param str jobID: Job reference followed by the DIRAC stamp.
797
796
:return: string representing the logging info of a given jobID
798
797
"""
799
798
result = self ._checkSession ()
@@ -802,7 +801,7 @@ def getJobLog(self, jobID):
802
801
return result
803
802
804
803
# Prepare the command: Get output files
805
- arcJob = self ._DiracToArcID (jobID .split (":::" )[0 ])
804
+ arcJob = self ._jobReferenceToArcID (jobID .split (":::" )[0 ])
806
805
query = self ._urlJoin (os .path .join ("jobs" , arcJob , "diagnose" , "errors" ))
807
806
808
807
# Submit the GET request to retrieve outputs
@@ -821,7 +820,7 @@ def getJobLog(self, jobID):
821
820
def _getListOfAvailableOutputs (self , jobID , arcJobID ):
822
821
"""Request a list of outputs available for a given jobID.
823
822
824
- :param str jobID: DIRAC job ID without the DIRAC stamp
823
+ :param str jobID: job reference without the DIRAC stamp
825
824
:param str arcJobID: ARC job ID
826
825
:return list: names of the available outputs
827
826
"""
@@ -841,11 +840,11 @@ def _getListOfAvailableOutputs(self, jobID, arcJobID):
841
840
return S_OK (response .json ()["file" ])
842
841
843
842
def getJobOutput (self , jobID , workingDirectory = None ):
844
- """Get the outputs of the given DIRAC job ID .
843
+ """Get the outputs of the given job reference .
845
844
846
845
Outputs and stored in workingDirectory if present, else in a new directory named <ARC JobID>.
847
846
848
- :param str jobID: DIRAC JobID followed by the DIRAC stamp.
847
+ :param str jobID: job reference followed by the DIRAC stamp.
849
848
:param str workingDirectory: name of the directory containing the retrieved outputs.
850
849
:return: content of stdout and stderr
851
850
"""
@@ -859,10 +858,10 @@ def getJobOutput(self, jobID, workingDirectory=None):
859
858
jobRef , stamp = jobID .split (":::" )
860
859
else :
861
860
return S_ERROR (f"DIRAC stamp not defined for { jobID } " )
862
- job = self ._DiracToArcID (jobRef )
861
+ arcJob = self ._jobReferenceToArcID (jobRef )
863
862
864
863
# Get the list of available outputs
865
- result = self ._getListOfAvailableOutputs (jobRef , job )
864
+ result = self ._getListOfAvailableOutputs (jobRef , arcJob )
866
865
if not result ["OK" ]:
867
866
return result
868
867
remoteOutputs = result ["Value" ]
@@ -871,21 +870,21 @@ def getJobOutput(self, jobID, workingDirectory=None):
871
870
if not workingDirectory :
872
871
if "WorkingDirectory" in self .ceParameters :
873
872
# We assume that workingDirectory exists
874
- workingDirectory = os .path .join (self .ceParameters ["WorkingDirectory" ], job )
873
+ workingDirectory = os .path .join (self .ceParameters ["WorkingDirectory" ], arcJob )
875
874
else :
876
- workingDirectory = job
875
+ workingDirectory = arcJob
877
876
os .mkdir (workingDirectory )
878
877
879
878
stdout = None
880
879
stderr = None
881
880
for remoteOutput in remoteOutputs :
882
881
# Prepare the command
883
- query = self ._urlJoin (os .path .join ("jobs" , job , "session" , remoteOutput ))
882
+ query = self ._urlJoin (os .path .join ("jobs" , arcJob , "session" , remoteOutput ))
884
883
885
884
# Submit the GET request to retrieve outputs
886
885
result = self ._request ("get" , query , stream = True )
887
886
if not result ["OK" ]:
888
- self .log .error ("Error downloading" , f"{ remoteOutput } for { job } : { result ['Message' ]} " )
887
+ self .log .error ("Error downloading" , f"{ remoteOutput } for { arcJob } : { result ['Message' ]} " )
889
888
return S_ERROR (f"Error downloading { remoteOutput } for { jobID } " )
890
889
response = result ["Value" ]
891
890
0 commit comments