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
@@ -483,12 +482,12 @@ def submitJob(self, executableFile, proxy, numberOfJobs=1, inputs=None, outputs=
483
482
if not result ["OK" ]:
484
483
break
485
484
486
- jobID = self ._arcToDiracID (arcJobID )
487
- batchIDList .append (jobID )
488
- stampDict [jobID ] = diracStamp
485
+ jobReference = self ._arcIDToJobReference (arcJobID )
486
+ batchIDList .append (jobReference )
487
+ stampDict [jobReference ] = diracStamp
489
488
self .log .debug (
490
489
"Successfully submitted job" ,
491
- f"{ jobID } to CE { self .ceHost } " ,
490
+ f"{ jobReference } to CE { self .ceHost } " ,
492
491
)
493
492
494
493
if batchIDList :
@@ -503,16 +502,16 @@ def submitJob(self, executableFile, proxy, numberOfJobs=1, inputs=None, outputs=
503
502
def killJob (self , jobIDList ):
504
503
"""Kill the specified jobs
505
504
506
- :param list jobIDList: list of DIRAC Job IDs
505
+ :param list jobIDList: list of Job references
507
506
"""
508
507
if not isinstance (jobIDList , list ):
509
508
jobIDList = [jobIDList ]
510
509
self .log .debug ("Killing jobs" , "," .join (jobIDList ))
511
510
512
- # Convert DIRAC jobs to ARC jobs
513
- # DIRAC Jobs might be stored with a DIRAC stamp (":::XXXXX") that should be removed
514
- jList = [self ._DiracToArcID (job .split (":::" )[0 ]) for job in jobIDList ]
515
- return self ._killJob (jList )
511
+ # Convert job references to ARC jobs
512
+ # Job references might be stored with a DIRAC stamp (":::XXXXX") that should be removed
513
+ arcJobList = [self ._jobReferenceToArcID (job .split (":::" )[0 ]) for job in jobIDList ]
514
+ return self ._killJob (arcJobList )
516
515
517
516
def _killJob (self , arcJobList ):
518
517
"""Kill the specified jobs
@@ -545,16 +544,16 @@ def _killJob(self, arcJobList):
545
544
def cleanJob (self , jobIDList ):
546
545
"""Clean files related to the specified jobs
547
546
548
- :param list jobIDList: list of DIRAC Job IDs
547
+ :param list jobIDList: list of job references
549
548
"""
550
549
if not isinstance (jobIDList , list ):
551
550
jobIDList = [jobIDList ]
552
551
self .log .debug ("Cleaning jobs" , "," .join (jobIDList ))
553
552
554
- # Convert DIRAC jobs to ARC jobs
555
- # DIRAC Jobs might be stored with a DIRAC stamp (":::XXXXX") that should be removed
556
- jList = [self ._DiracToArcID (job .split (":::" )[0 ]) for job in jobIDList ]
557
- return self ._cleanJob (jList )
553
+ # Convert job references to ARC jobs
554
+ # Job references might be stored with a DIRAC stamp (":::XXXXX") that should be removed
555
+ arcJobList = [self ._jobReferenceToArcID (job .split (":::" )[0 ]) for job in jobIDList ]
556
+ return self ._cleanJob (arcJobList )
558
557
559
558
def _cleanJob (self , arcJobList ):
560
559
"""Clean files related to the specified jobs
@@ -710,7 +709,7 @@ def _renewDelegation(self, delegationID):
710
709
def getJobStatus (self , jobIDList ):
711
710
"""Get the status information for the given list of jobs.
712
711
713
- :param list jobIDList: list of DIRAC Job ID , followed by the DIRAC stamp.
712
+ :param list jobIDList: list of job references , followed by the DIRAC stamp.
714
713
"""
715
714
result = self ._checkSession ()
716
715
if not result ["OK" ]:
@@ -721,9 +720,9 @@ def getJobStatus(self, jobIDList):
721
720
jobIDList = [jobIDList ]
722
721
723
722
self .log .debug ("Getting status of jobs:" , jobIDList )
724
- # Convert DIRAC jobs to ARC jobs and encapsulate them in a dictionary for the REST query
725
- # DIRAC Jobs might be stored with a DIRAC stamp (":::XXXXX") that should be removed
726
- arcJobsJson = {"job" : [{"id" : self ._DiracToArcID (job .split (":::" )[0 ])} for job in jobIDList ]}
723
+ # Convert job references to ARC jobs and encapsulate them in a dictionary for the REST query
724
+ # Job references might be stored with a DIRAC stamp (":::XXXXX") that should be removed
725
+ arcJobsJson = {"job" : [{"id" : self ._jobReferenceToArcID (job .split (":::" )[0 ])} for job in jobIDList ]}
727
726
728
727
# Prepare the command
729
728
params = {"action" : "status" }
@@ -746,16 +745,16 @@ def getJobStatus(self, jobIDList):
746
745
arcJobsInfo = [arcJobsInfo ]
747
746
748
747
for arcJob in arcJobsInfo :
749
- jobID = self ._arcToDiracID (arcJob ["id" ])
748
+ jobReference = self ._arcIDToJobReference (arcJob ["id" ])
750
749
# ARC REST interface returns hyperbole
751
750
arcState = arcJob ["state" ].capitalize ()
752
- self .log .debug ("REST ARC status" , f"for job { jobID } is { arcState } " )
753
- resultDict [jobID ] = self .mapStates [arcState ]
751
+ self .log .debug ("REST ARC status" , f"for job { jobReference } is { arcState } " )
752
+ resultDict [jobReference ] = self .mapStates [arcState ]
754
753
755
754
# Cancel held jobs so they don't sit in the queue forever
756
755
if arcState == "Hold" :
757
756
jobsToCancel .append (arcJob ["id" ])
758
- self .log .debug (f"Killing held job { jobID } " )
757
+ self .log .debug (f"Killing held job { jobReference } " )
759
758
760
759
# Renew delegations to renew the proxies of the jobs
761
760
result = self ._getDelegationIDs ()
@@ -782,7 +781,7 @@ def getJobStatus(self, jobIDList):
782
781
def getJobLog (self , jobID ):
783
782
"""Get job logging info
784
783
785
- :param str jobID: DIRAC JobID followed by the DIRAC stamp.
784
+ :param str jobID: Job reference followed by the DIRAC stamp.
786
785
:return: string representing the logging info of a given jobID
787
786
"""
788
787
result = self ._checkSession ()
@@ -791,7 +790,7 @@ def getJobLog(self, jobID):
791
790
return result
792
791
793
792
# Prepare the command: Get output files
794
- arcJob = self ._DiracToArcID (jobID .split (":::" )[0 ])
793
+ arcJob = self ._jobReferenceToArcID (jobID .split (":::" )[0 ])
795
794
query = self ._urlJoin (os .path .join ("jobs" , arcJob , "diagnose" , "errors" ))
796
795
797
796
# Submit the GET request to retrieve outputs
@@ -810,7 +809,7 @@ def getJobLog(self, jobID):
810
809
def _getListOfAvailableOutputs (self , jobID , arcJobID ):
811
810
"""Request a list of outputs available for a given jobID.
812
811
813
- :param str jobID: DIRAC job ID without the DIRAC stamp
812
+ :param str jobID: job reference without the DIRAC stamp
814
813
:param str arcJobID: ARC job ID
815
814
:return list: names of the available outputs
816
815
"""
@@ -830,11 +829,11 @@ def _getListOfAvailableOutputs(self, jobID, arcJobID):
830
829
return S_OK (response .json ()["file" ])
831
830
832
831
def getJobOutput (self , jobID , workingDirectory = None ):
833
- """Get the outputs of the given DIRAC job ID .
832
+ """Get the outputs of the given job reference .
834
833
835
834
Outputs and stored in workingDirectory if present, else in a new directory named <ARC JobID>.
836
835
837
- :param str jobID: DIRAC JobID followed by the DIRAC stamp.
836
+ :param str jobID: job reference followed by the DIRAC stamp.
838
837
:param str workingDirectory: name of the directory containing the retrieved outputs.
839
838
:return: content of stdout and stderr
840
839
"""
@@ -848,10 +847,10 @@ def getJobOutput(self, jobID, workingDirectory=None):
848
847
jobRef , stamp = jobID .split (":::" )
849
848
else :
850
849
return S_ERROR (f"DIRAC stamp not defined for { jobID } " )
851
- job = self ._DiracToArcID (jobRef )
850
+ arcJob = self ._jobReferenceToArcID (jobRef )
852
851
853
852
# Get the list of available outputs
854
- result = self ._getListOfAvailableOutputs (jobRef , job )
853
+ result = self ._getListOfAvailableOutputs (jobRef , arcJob )
855
854
if not result ["OK" ]:
856
855
return result
857
856
remoteOutputs = result ["Value" ]
@@ -860,21 +859,21 @@ def getJobOutput(self, jobID, workingDirectory=None):
860
859
if not workingDirectory :
861
860
if "WorkingDirectory" in self .ceParameters :
862
861
# We assume that workingDirectory exists
863
- workingDirectory = os .path .join (self .ceParameters ["WorkingDirectory" ], job )
862
+ workingDirectory = os .path .join (self .ceParameters ["WorkingDirectory" ], arcJob )
864
863
else :
865
- workingDirectory = job
864
+ workingDirectory = arcJob
866
865
os .mkdir (workingDirectory )
867
866
868
867
stdout = None
869
868
stderr = None
870
869
for remoteOutput in remoteOutputs :
871
870
# Prepare the command
872
- query = self ._urlJoin (os .path .join ("jobs" , job , "session" , remoteOutput ))
871
+ query = self ._urlJoin (os .path .join ("jobs" , arcJob , "session" , remoteOutput ))
873
872
874
873
# Submit the GET request to retrieve outputs
875
874
result = self ._request ("get" , query , stream = True )
876
875
if not result ["OK" ]:
877
- self .log .error ("Error downloading" , f"{ remoteOutput } for { job } : { result ['Message' ]} " )
876
+ self .log .error ("Error downloading" , f"{ remoteOutput } for { arcJob } : { result ['Message' ]} " )
878
877
return S_ERROR (f"Error downloading { remoteOutput } for { jobID } " )
879
878
response = result ["Value" ]
880
879
0 commit comments