diff --git a/qualibrate_config/cli/config.py b/qualibrate_config/cli/config.py index 8d64136..a6b034f 100644 --- a/qualibrate_config/cli/config.py +++ b/qualibrate_config/cli/config.py @@ -24,6 +24,7 @@ ) from qualibrate_config.models.qualibrate import QualibrateTopLevelConfig from qualibrate_config.models.storage_type import StorageType +from qualibrate_config.qulibrate_types import RawConfigType from qualibrate_config.validation import ( InvalidQualibrateConfigVersion, qualibrate_version_validator, @@ -109,7 +110,7 @@ ) @click.option( "--storage-location", - type=click.Path(file_okay=False, dir_okay=True), + type=click.Path(file_okay=False, dir_okay=True, path_type=Path), default=get_user_storage(), show_default=True, help=( @@ -118,9 +119,13 @@ ) @click.option( "--calibration-library-resolver", + "--runner-calibration-library-resolver", type=str, default="qualibrate.QualibrationLibrary", show_default=True, + cls=DeprecatedOption, + deprecated=("--runner-calibration-library-resolver",), + preferred="--calibration-library-resolver", help=( "String contains python path to the class that represents qualibration " "library." @@ -128,9 +133,13 @@ ) @click.option( "--calibration-library-folder", - type=click.Path(file_okay=False, dir_okay=True), + "--runner-calibration-library-resolver", + type=click.Path(file_okay=False, dir_okay=True, path_type=Path), default=QUALIBRATE_PATH / "calibrations", show_default=True, + cls=DeprecatedOption, + deprecated=("--runner-calibration-library-resolver",), + preferred="--calibration-library-folder", help="Path to the folder contains calibration nodes and graphs.", ) @click.option( @@ -178,11 +187,21 @@ ) @click.option( "--app-static-site-files", - type=click.Path(file_okay=False, dir_okay=True), + type=click.Path(file_okay=False, dir_okay=True, path_type=Path), default=get_qapp_static_file_path(), show_default=True, help="Path to the frontend build static files.", ) +@click.option( + "--quam-state-path", + "--active-machine-path", + type=click.Path(file_okay=False, dir_okay=True, path_type=Path), + cls=DeprecatedOption, + required=False, + deprecated=("--active-machine-path",), + preferred="--quam-state-path", + help="Path to the quam state.", +) @click.option("--check-generator", is_flag=True, hidden=True) @click.pass_context def config_command( @@ -201,6 +220,7 @@ def config_command( runner_timeout: float, spawn_app: bool, app_static_site_files: Path, + quam_state_path: Optional[Path], check_generator: bool, ) -> None: common_config, config_file = get_config_file_content(config_path) @@ -225,6 +245,7 @@ def config_command( qs = QualibrateTopLevelConfig({QUALIBRATE_CONFIG_KEY: qualibrate_config}) qs.qualibrate.storage.location.mkdir(parents=True, exist_ok=True) try: + _temporary_fill_quam_state_path(common_config, quam_state_path) write_config( config_file, common_config, @@ -239,5 +260,20 @@ def config_command( raise +def _temporary_fill_quam_state_path( + common_config: RawConfigType, state_path: Optional[Path] +) -> RawConfigType: + quam = common_config.get("quam", {}) + active_machine = common_config.get("active_machine", {}) + new_state_path = ( + state_path or quam.get("state_path") or active_machine.get("path") + ) + if new_state_path is None: + return common_config + quam["state_path"] = str(new_state_path) + common_config.update({"quam": quam}) + return common_config + + if __name__ == "__main__": config_command([], standalone_mode=False)