From d95a08962e8b38296b92fa1321890f546173f66c Mon Sep 17 00:00:00 2001 From: Maxim V4S Date: Wed, 22 Jan 2025 15:52:17 +0300 Subject: [PATCH] hotfix: return state path to local storage manager --- qualibrate/config/resolvers.py | 28 ++++++++++++++++++++++++++++ qualibrate/qualibration_node.py | 3 +++ 2 files changed, 31 insertions(+) create mode 100644 qualibrate/config/resolvers.py diff --git a/qualibrate/config/resolvers.py b/qualibrate/config/resolvers.py new file mode 100644 index 0000000..ca23511 --- /dev/null +++ b/qualibrate/config/resolvers.py @@ -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) diff --git a/qualibrate/qualibration_node.py b/qualibrate/qualibration_node.py index 03f30bc..8bb34bc 100644 --- a/qualibrate/qualibration_node.py +++ b/qualibrate/qualibration_node.py @@ -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 @@ -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)