@@ -107,6 +107,21 @@ def parse_utc_datetime(dt_str: str) -> datetime:
107
107
return dt_utc
108
108
109
109
110
+ def get_job_status (job : Job ) -> JobStatus :
111
+ """Get job status in JobStatus format defined in:
112
+ `from qiskit.providers.jobstatus import JobStatus`"""
113
+ status = job .status ()
114
+ if isinstance (status , str ):
115
+ qe_job_status = getattr (JobStatus , status , None )
116
+ if qe_job_status is None :
117
+ raise QiskitError (
118
+ f"The status of job { job .job_id ()} is { status } "
119
+ "which is not supported by qiskit-experiments."
120
+ )
121
+ status = qe_job_status
122
+ return status
123
+
124
+
110
125
class ExperimentData :
111
126
"""Experiment data container class.
112
127
@@ -910,7 +925,7 @@ def _add_job_data(
910
925
return jid , True
911
926
except Exception as ex : # pylint: disable=broad-except
912
927
# Handle cancelled jobs
913
- status = job . status ( )
928
+ status = get_job_status ( job )
914
929
if status == JobStatus .CANCELLED :
915
930
LOG .warning ("Job was cancelled before completion [Job ID: %s]" , jid )
916
931
return jid , False
@@ -1171,7 +1186,7 @@ def _retrieve_data(self):
1171
1186
# Add retrieved job objects to stored jobs and extract data
1172
1187
for jid , job in retrieved_jobs .items ():
1173
1188
self ._jobs [jid ] = job
1174
- if job . status ( ) in JOB_FINAL_STATES :
1189
+ if get_job_status ( job ) in JOB_FINAL_STATES :
1175
1190
# Add job results synchronously
1176
1191
self ._add_job_data (job )
1177
1192
else :
@@ -1982,7 +1997,7 @@ def cancel_jobs(
1982
1997
if ids and jid not in ids :
1983
1998
# Skip cancelling this callback
1984
1999
continue
1985
- if job and job . status ( ) not in JOB_FINAL_STATES :
2000
+ if job and get_job_status ( job ) not in JOB_FINAL_STATES :
1986
2001
try :
1987
2002
job .cancel ()
1988
2003
LOG .warning ("Cancelled job [Job ID: %s]" , jid )
@@ -2259,7 +2274,7 @@ def job_status(self) -> JobStatus:
2259
2274
statuses = set ()
2260
2275
for job in self ._jobs .values ():
2261
2276
if job :
2262
- statuses .add (job . status ( ))
2277
+ statuses .add (get_job_status ( job ))
2263
2278
2264
2279
# If any jobs are in non-DONE state return that state
2265
2280
for stat in [
@@ -2310,7 +2325,7 @@ def job_errors(self) -> str:
2310
2325
2311
2326
# Get any job errors
2312
2327
for job in self ._jobs .values ():
2313
- if job and job . status ( ) == JobStatus .ERROR :
2328
+ if job and get_job_status ( job ) == JobStatus .ERROR :
2314
2329
if hasattr (job , "error_message" ):
2315
2330
error_msg = job .error_message ()
2316
2331
else :
0 commit comments