Skip to content

Commit 4b2667e

Browse files
Improve readability of exceptions in build pipeline script (microsoft#357)
* Update manage_environment.py * Update attach_compute.py * Update attach_compute.py * Update manage_environment.py Co-authored-by: João Pedro Martins <[email protected]>
1 parent d081fc2 commit 4b2667e

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

ml_service/util/attach_compute.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
import traceback
23
from azureml.core import Workspace
34
from azureml.core.compute import AmlCompute
45
from azureml.core.compute import ComputeTarget
@@ -32,7 +33,7 @@ def get_compute(workspace: Workspace, compute_name: str, vm_size: str, for_batch
3233
show_output=True, min_node_count=None, timeout_in_minutes=10
3334
)
3435
return compute_target
35-
except ComputeTargetException as ex:
36-
print(ex)
36+
except ComputeTargetException:
37+
traceback.print_exc()
3738
print("An error occurred trying to provision compute.")
3839
exit(1)

ml_service/util/manage_environment.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
import os
3+
import traceback
34
from azureml.core import Workspace, Environment
45
from ml_service.util.env_variables import Env
56
from azureml.core.runconfig import DEFAULT_CPU_IMAGE, DEFAULT_GPU_IMAGE
@@ -35,6 +36,6 @@ def get_environment(
3536
if restored_environment is not None:
3637
print(restored_environment)
3738
return restored_environment
38-
except Exception as e:
39-
print(e)
39+
except Exception:
40+
traceback.print_exc()
4041
exit(1)

0 commit comments

Comments
 (0)