Source code for qiskit_experiments.framework.status
# This code is part of Qiskit.## (C) Copyright IBM 2023.## This code is licensed under the Apache License, Version 2.0. You may# obtain a copy of this license in the LICENSE.txt file in the root directory# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.## Any modifications or derivative works of this code must retain this# copyright notice, and modified files need to carry a notice indicating# that they have been altered from the originals."""Status of experiment execution."""from__future__importannotationsimportdataclassesimportenumfromthreadingimportEventfromtypingimportOptional
[docs]classExperimentStatus(enum.Enum):"""Class for experiment status enumerated type."""EMPTY="experiment data is empty"INITIALIZING="experiment jobs are being initialized"VALIDATING="experiment jobs are validating"QUEUED="experiment jobs are queued"RUNNING="experiment jobs is actively running"CANCELLED="experiment jobs or analysis has been cancelled"POST_PROCESSING="experiment analysis is actively running"DONE="experiment jobs and analysis have successfully run"ERROR="experiment jobs or analysis incurred an error"def__json_encode__(self):returnself.name@classmethoddef__json_decode__(cls,value):returncls.__members__[value]# pylint: disable=unsubscriptable-object
[docs]classAnalysisStatus(enum.Enum):"""Class for analysis callback status enumerated type."""QUEUED="analysis callback is queued"RUNNING="analysis callback is actively running"CANCELLED="analysis callback has been cancelled"DONE="analysis callback has successfully run"ERROR="analysis callback incurred an error"def__json_encode__(self):returnself.name@classmethoddef__json_decode__(cls,value):returncls.__members__[value]# pylint: disable=unsubscriptable-object
@dataclasses.dataclassclassAnalysisCallback:"""Dataclass for analysis callback status"""name:str=""callback_id:str=""status:AnalysisStatus=AnalysisStatus.QUEUEDerror_msg:Optional[str]=Noneevent:Event=dataclasses.field(default_factory=Event)def__getstate__(self):# We need to remove the Event object from state when pickling# since events are not pickleablestate=self.__dict__state["event"]=Nonereturnstatedef__json_encode__(self):returnself.__getstate__()