From 01ed27f0d9c606d368c2f5683659f941b272fb6e Mon Sep 17 00:00:00 2001 From: Alexej Penner Date: Thu, 7 Nov 2024 14:00:22 +0100 Subject: [PATCH] Adjust to https://github.com/zenml-io/zenml/pull/3096 (#44) --- .gitignore | 1 + README.md | 2 +- template/steps/deployment/deployment_deploy.py | 2 +- ...re_promotion %}promote_with_metric_compare.py{% endif %} | 6 +++--- ...compare_promotion %}promote_latest_version.py{% endif %} | 4 ++-- .../hp_tuning_select_best_model.py | 2 +- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 8d24949..5b35ecf 100644 --- a/.gitignore +++ b/.gitignore @@ -163,3 +163,4 @@ cython_debug/ .local/ .ruff_cache/ .DS_Store +.idea \ No newline at end of file diff --git a/README.md b/README.md index c6e65d6..148d10c 100644 --- a/README.md +++ b/README.md @@ -154,7 +154,7 @@ for step_name in step_names: ) model: ClassifierMixin = hp_output.load() # fetch metadata we attached earlier - metric = float(hp_output.run_metadata["metric"].value) + metric = float(hp_output.run_metadata["metric"]) if best_model is None or best_metric < metric: best_model = model ``` diff --git a/template/steps/deployment/deployment_deploy.py b/template/steps/deployment/deployment_deploy.py index c7e1468..b8472f2 100644 --- a/template/steps/deployment/deployment_deploy.py +++ b/template/steps/deployment/deployment_deploy.py @@ -47,7 +47,7 @@ def deployment_deploy() -> ( # deploy predictor service deployment_service = mlflow_model_registry_deployer_step.entrypoint( registry_model_name=model.name, - registry_model_version=model.run_metadata["model_registry_version"].value, + registry_model_version=model.run_metadata["model_registry_version"], replace_existing=True, ) else: diff --git a/template/steps/promotion/{% if metric_compare_promotion %}promote_with_metric_compare.py{% endif %} b/template/steps/promotion/{% if metric_compare_promotion %}promote_with_metric_compare.py{% endif %} index ffd8d5d..3ed5580 100644 --- a/template/steps/promotion/{% if metric_compare_promotion %}promote_with_metric_compare.py{% endif %} +++ b/template/steps/promotion/{% if metric_compare_promotion %}promote_with_metric_compare.py{% endif %} @@ -77,11 +77,11 @@ def promote_with_metric_compare( logger.info(f"Current model version was promoted to '{target_env}'.") # Promote in Model Registry - latest_version_model_registry_number = latest_version.run_metadata["model_registry_version"].value + latest_version_model_registry_number = latest_version.run_metadata["model_registry_version"] if current_version_number is None: current_version_model_registry_number = latest_version_model_registry_number else: - current_version_model_registry_number = current_version.run_metadata["model_registry_version"].value + current_version_model_registry_number = current_version.run_metadata["model_registry_version"] promote_in_model_registry( latest_version=latest_version_model_registry_number, current_version=current_version_model_registry_number, @@ -90,7 +90,7 @@ def promote_with_metric_compare( ) promoted_version = latest_version_model_registry_number else: - promoted_version = current_version.run_metadata["model_registry_version"].value + promoted_version = current_version.run_metadata["model_registry_version"] logger.info( f"Current model version in `{target_env}` is `{promoted_version}` registered in Model Registry" diff --git a/template/steps/promotion/{% if not metric_compare_promotion %}promote_latest_version.py{% endif %} b/template/steps/promotion/{% if not metric_compare_promotion %}promote_latest_version.py{% endif %} index fb90618..7c5ab09 100644 --- a/template/steps/promotion/{% if not metric_compare_promotion %}promote_latest_version.py{% endif %} +++ b/template/steps/promotion/{% if not metric_compare_promotion %}promote_latest_version.py{% endif %} @@ -32,11 +32,11 @@ def promote_latest_version( logger.info(f"Current model version was promoted to '{target_env}'.") # Promote in Model Registry - latest_version_model_registry_number = latest_version.run_metadata["model_registry_version"].value + latest_version_model_registry_number = latest_version.run_metadata["model_registry_version"] if current_version.number is None: current_version_model_registry_number = latest_version_model_registry_number else: - current_version_model_registry_number = current_version.run_metadata["model_registry_version"].value + current_version_model_registry_number = current_version.run_metadata["model_registry_version"] promote_in_model_registry( latest_version=latest_version_model_registry_number, current_version=current_version_model_registry_number, diff --git a/template/steps/{% if hyperparameters_tuning %}hp_tuning{% endif %}/hp_tuning_select_best_model.py b/template/steps/{% if hyperparameters_tuning %}hp_tuning{% endif %}/hp_tuning_select_best_model.py index d037d8b..028f217 100644 --- a/template/steps/{% if hyperparameters_tuning %}hp_tuning{% endif %}/hp_tuning_select_best_model.py +++ b/template/steps/{% if hyperparameters_tuning %}hp_tuning{% endif %}/hp_tuning_select_best_model.py @@ -34,7 +34,7 @@ def hp_tuning_select_best_model( hp_output = model.get_data_artifact("hp_result") model_: ClassifierMixin = hp_output.load() # fetch metadata we attached earlier - metric = float(hp_output.run_metadata["metric"].value) + metric = float(hp_output.run_metadata["metric"]) if best_model is None or best_metric < metric: best_model = model_ ### YOUR CODE ENDS HERE ###