From 943cfcee5207b1dfb6496e5bc35449b87814bbf5 Mon Sep 17 00:00:00 2001 From: Safoine El khabich Date: Wed, 27 Nov 2024 11:17:38 +0100 Subject: [PATCH] Handle KeyError when retrieving current model version number --- .../compute_performance_metrics_on_current_data.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/train_and_deploy/steps/promotion/compute_performance_metrics_on_current_data.py b/train_and_deploy/steps/promotion/compute_performance_metrics_on_current_data.py index 49974018..2c7b81cb 100644 --- a/train_and_deploy/steps/promotion/compute_performance_metrics_on_current_data.py +++ b/train_and_deploy/steps/promotion/compute_performance_metrics_on_current_data.py @@ -60,10 +60,14 @@ def compute_performance_metrics_on_current_data( # Get model version numbers from Model Control Plane latest_version = get_step_context().model - current_version = Model(name=latest_version.name, version=target_env) latest_version_number = latest_version.number - current_version_number = current_version.number + + current_version = Model(name=latest_version.name, version=target_env) + try: + current_version_number = current_version.number + except KeyError: + current_version_number = None if current_version_number is None: current_version_number = -1