Skip to content

Commit

Permalink
Merge pull request #79 from qua-platform/fix_node_stop
Browse files Browse the repository at this point in the history
Fix stop active node
  • Loading branch information
maxim-v4s authored Jan 15, 2025
2 parents 1d552dd + c63d49f commit 03b5639
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions qualibrate/qualibration_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class QualibrationNode(
storage_manager: Optional[
StorageManager["QualibrationNode[NodeParameters]"]
] = None
active_node: Optional["QualibrationNode[ParametersType]"] = None

def __init__(
self,
Expand Down Expand Up @@ -129,7 +130,7 @@ def __init__(
raise StopInspection(
"Node instantiated in inspection mode", instance=self
)

self.__class__.active_node = self
last_executed_node_ctx.set(self)

self._warn_if_external_and_interactive_mpl()
Expand Down Expand Up @@ -605,14 +606,20 @@ def stop(self, **kwargs: Any) -> bool:
Returns:
True if the node is successfully stopped, False otherwise.
"""
logger.debug(f"Stop node {self.name}")
active_node = self.__class__.active_node
logger.debug(f"Stop node {active_node} with id {id(active_node)}")
if active_node is None:
return False
logger.info(f"Stop node {active_node.name}")
if find_spec("qm") is None:
return False
qmm = getattr(self.machine, "qmm", None)
qmm = getattr(active_node.machine, "qmm", None)
if not qmm:
if self.machine is None or not hasattr(self.machine, "connect"):
if active_node.machine is None or not hasattr(
active_node.machine, "connect"
):
return False
qmm = self.machine.connect()
qmm = active_node.machine.connect()
if hasattr(qmm, "list_open_qms"):
ids = qmm.list_open_qms()
elif hasattr(qmm, "list_open_quantum_machines"):
Expand Down

0 comments on commit 03b5639

Please sign in to comment.