Skip to content

Commit dc88c72

Browse files
jotayloeedorenko
authored andcommitted
Tag the experiment runs and model with a link to the build ui (#132)
1 parent d79338f commit dc88c72

File tree

5 files changed

+42
-2
lines changed

5 files changed

+42
-2
lines changed

code/evaluate/evaluate_model.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@
9090
model_name = args.model_name
9191
metric_eval = "mse"
9292
run.tag("BuildId", value=build_id)
93+
builduri_base = os.environ.get("BUILDURI_BASE")
94+
if (builduri_base is not None):
95+
build_uri = builduri_base + build_id
96+
run.tag("BuildUri", value=build_uri)
9397

9498
# Paramaterize the matrices on which the models should be compared
9599
# Add golden data set on which all the model performance can be evaluated

code/register/register_model.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,11 @@ def main():
8888
register_aml_model(model_name, exp, run_id)
8989
else:
9090
run.tag("BuildId", value=build_id)
91-
register_aml_model(model_name, exp, run_id, build_id)
91+
builduri_base = os.environ.get("BUILDURI_BASE")
92+
if (builduri_base is not None):
93+
build_uri = builduri_base + build_id
94+
run.tag("BuildUri", value=build_uri)
95+
register_aml_model(model_name, exp, run_id, build_id, build_uri)
9296

9397

9498
def model_already_registered(model_name, exp, run_id):
@@ -102,14 +106,22 @@ def model_already_registered(model_name, exp, run_id):
102106
print("Model is not registered for this run.")
103107

104108

105-
def register_aml_model(model_name, exp, run_id, build_id: str = 'none'):
109+
def register_aml_model(
110+
model_name,
111+
exp,
112+
run_id,
113+
build_id: str = 'none',
114+
build_uri=None
115+
):
106116
try:
107117
if (build_id != 'none'):
108118
model_already_registered(model_name, exp, run_id)
109119
run = Run(experiment=exp, run_id=run_id)
110120
tagsValue = {"area": "diabetes", "type": "regression",
111121
"BuildId": build_id, "run_id": run_id,
112122
"experiment_name": exp.name}
123+
if (build_uri is not None):
124+
tagsValue["BuildUri"] = build_uri
113125
else:
114126
run = Run(experiment=exp, run_id=run_id)
115127
if (run is not None):

code/training/train.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,16 @@ def main():
101101
print("Following files are uploaded ")
102102
print(run.parent.get_file_names())
103103

104+
run.parent.tag("BuildId", value=build_id)
105+
104106
# Add properties to identify this specific training run
105107
run.tag("BuildId", value=build_id)
106108
run.tag("run_type", value="train")
109+
builduri_base = os.environ.get("BUILDURI_BASE")
110+
if (builduri_base is not None):
111+
build_uri = builduri_base + build_id
112+
run.tag("BuildUri", value=build_uri)
113+
run.parent.tag("BuildUri", value=build_uri)
107114
print(f"tags now present for run: {run.tags}")
108115

109116
run.complete()

ml_service/pipelines/build_train_pipeline.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ def main():
3939
)
4040
run_config.environment.docker.enabled = True
4141

42+
config_envvar = {}
43+
if (e.collection_uri is not None and e.teamproject_name is not None):
44+
builduri_base = e.collection_uri + e.teamproject_name
45+
builduri_base = builduri_base + "/_build/results?buildId="
46+
config_envvar["BUILDURI_BASE"] = builduri_base
47+
run_config.environment.environment_variables = config_envvar
48+
4249
model_name_param = PipelineParameter(
4350
name="model_name", default_value=e.model_name)
4451
build_id_param = PipelineParameter(

ml_service/util/env_variables.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ def __init__(self):
3939
self._model_path = os.environ.get('MODEL_PATH')
4040
self._db_cluster_id = os.environ.get("DB_CLUSTER_ID")
4141
self._score_script = os.environ.get("SCORE_SCRIPT")
42+
self._collection_uri = os.environ.get("SYSTEM_COLLECTIONURI")
43+
self._teamproject_name = os.environ.get("SYSTEM_TEAMPROJECT")
4244

4345
@property
4446
def workspace_name(self):
@@ -135,3 +137,11 @@ def model_path(self):
135137
@property
136138
def score_script(self):
137139
return self._score_script
140+
141+
@property
142+
def collection_uri(self):
143+
return self._collection_uri
144+
145+
@property
146+
def teamproject_name(self):
147+
return self._teamproject_name

0 commit comments

Comments
 (0)