|
2 | 2 | This module contains constants and lists for the possible job states.
|
3 | 3 | """
|
4 | 4 |
|
5 |
| -from DIRAC import gLogger, S_OK, S_ERROR |
| 5 | +from DIRAC import S_OK |
6 | 6 | from DIRAC.Core.Utilities.StateMachine import State, StateMachine
|
7 |
| -from DIRAC.Core.Utilities.Decorators import deprecated |
8 |
| - |
9 | 7 | from DIRAC.WorkloadManagementSystem.Client.JobMonitoringClient import JobMonitoringClient
|
10 | 8 |
|
11 |
| - |
12 | 9 | #:
|
13 | 10 | SUBMITTING = "Submitting"
|
14 | 11 | #:
|
@@ -100,37 +97,6 @@ def __init__(self, state):
|
100 | 97 | }
|
101 | 98 |
|
102 | 99 |
|
103 |
| -@deprecated("Use filterJobStateTransition instead") |
104 |
| -def checkJobStateTransition(jobID, candidateState, currentStatus=None, jobMonitoringClient=None): |
105 |
| - """Utility to check if a job state transition is allowed""" |
106 |
| - if not currentStatus: |
107 |
| - if not jobMonitoringClient: |
108 |
| - from DIRAC.WorkloadManagementSystem.Client.JobMonitoringClient import JobMonitoringClient |
109 |
| - |
110 |
| - jobMonitoringClient = JobMonitoringClient() |
111 |
| - |
112 |
| - res = jobMonitoringClient.getJobsStatus(jobID) |
113 |
| - if not res["OK"]: |
114 |
| - return res |
115 |
| - try: |
116 |
| - currentStatus = res["Value"][jobID]["Status"] |
117 |
| - except KeyError: |
118 |
| - return S_ERROR("Job does not exist") |
119 |
| - |
120 |
| - res = JobsStateMachine(currentStatus).getNextState(candidateState) |
121 |
| - if not res["OK"]: |
122 |
| - return res |
123 |
| - |
124 |
| - # If the JobsStateMachine does not accept the candidate, return an ERROR |
125 |
| - if candidateState != res["Value"]: |
126 |
| - gLogger.error( |
127 |
| - "Job Status Error", |
128 |
| - f"{jobID} can't move from {currentStatus} to {candidateState}", |
129 |
| - ) |
130 |
| - return S_ERROR("Job state transition not allowed") |
131 |
| - return S_OK() |
132 |
| - |
133 |
| - |
134 | 100 | def filterJobStateTransition(jobIDs, candidateState):
|
135 | 101 | """Given a list of jobIDs, return a list that are allowed to transition
|
136 | 102 | to the given candidate state.
|
|
0 commit comments