Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix: active quam state is also updated when calling node.save #80

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading