From 4b2667e34be793fa74abe801223279454b502d97 Mon Sep 17 00:00:00 2001 From: Tim Johnson <43890311+Inevitable-Marzipan@users.noreply.github.com> Date: Tue, 14 Dec 2021 20:27:26 +0000 Subject: [PATCH] Improve readability of exceptions in build pipeline script (#357) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update manage_environment.py * Update attach_compute.py * Update attach_compute.py * Update manage_environment.py Co-authored-by: João Pedro Martins --- ml_service/util/attach_compute.py | 5 +++-- ml_service/util/manage_environment.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ml_service/util/attach_compute.py b/ml_service/util/attach_compute.py index ad9668db..cf8c07a6 100644 --- a/ml_service/util/attach_compute.py +++ b/ml_service/util/attach_compute.py @@ -1,4 +1,5 @@ +import traceback from azureml.core import Workspace from azureml.core.compute import AmlCompute from azureml.core.compute import ComputeTarget @@ -32,7 +33,7 @@ def get_compute(workspace: Workspace, compute_name: str, vm_size: str, for_batch show_output=True, min_node_count=None, timeout_in_minutes=10 ) return compute_target - except ComputeTargetException as ex: - print(ex) + except ComputeTargetException: + traceback.print_exc() print("An error occurred trying to provision compute.") exit(1) diff --git a/ml_service/util/manage_environment.py b/ml_service/util/manage_environment.py index 54c5a72f..b61c97fe 100644 --- a/ml_service/util/manage_environment.py +++ b/ml_service/util/manage_environment.py @@ -1,5 +1,6 @@ import os +import traceback from azureml.core import Workspace, Environment from ml_service.util.env_variables import Env from azureml.core.runconfig import DEFAULT_CPU_IMAGE, DEFAULT_GPU_IMAGE @@ -35,6 +36,6 @@ def get_environment( if restored_environment is not None: print(restored_environment) return restored_environment - except Exception as e: - print(e) + except Exception: + traceback.print_exc() exit(1)