Skip to content

Commit

Permalink
Merge pull request #80 from qua-platform/hotfix_quam_state_path
Browse files Browse the repository at this point in the history
Hotfix: active quam state is also updated when calling node.save
  • Loading branch information
nulinspiratie authored Jan 22, 2025
2 parents b7b7b5f + d95a089 commit 34c5f7a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
28 changes: 28 additions & 0 deletions qualibrate/config/resolvers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import warnings
from pathlib import Path
from typing import Optional

from qualibrate_config.models import QualibrateConfig


def get_quam_state_path(config: QualibrateConfig) -> Optional[Path]:
root = config.__class__._root
if root is None:
return None
raw_config = root._raw_dict
state_path = raw_config.get("quam", {}).get("state_path")
if state_path is not None:
return Path(state_path)
am_path = raw_config.get("active_machine", {}).get("path")
if am_path is None:
return None
warnings.warn(
(
'The config entry "active_machine.path" has been deprecated in '
'favor of "quam.state_path". Please update the qualibrate config '
"(~/.qualibrate/config.toml) accordingly."
),
DeprecationWarning,
stacklevel=2,
)
return Path(am_path)
3 changes: 3 additions & 0 deletions qualibrate/qualibration_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
get_qualibrate_config_path,
)

from qualibrate.config.resolvers import get_quam_state_path
from qualibrate.models.outcome import Outcome
from qualibrate.models.run_mode import RunModes
from qualibrate.models.run_summary.base import BaseRunSummary
Expand Down Expand Up @@ -322,8 +323,10 @@ def save(self) -> None:
logger.warning(msg)
q_config_path = get_qualibrate_config_path()
qs = get_qualibrate_config(q_config_path)
state_path = get_quam_state_path(qs)
self.storage_manager = LocalStorageManager(
root_data_folder=qs.storage.location,
active_machine_path=state_path,
)
self.storage_manager.save(
node=cast("QualibrationNode[NodeParameters]", self)
Expand Down

0 comments on commit 34c5f7a

Please sign in to comment.