Skip to content

Commit f1d85cc

Browse files
authored
Update register_model.py (#65)
Changing to use run.register_model
1 parent d00ab84 commit f1d85cc

File tree

1 file changed

+3
-20
lines changed

1 file changed

+3
-20
lines changed

code/register/register_model.py

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import json
2828
import sys
2929
from azureml.core import Run
30-
from azureml.core.model import Model
3130
import argparse
3231

3332
from azureml.core.authentication import AzureCliAuthentication
@@ -90,33 +89,17 @@
9089
names = run.get_file_names
9190
names()
9291
print("Run ID for last run: {}".format(run_id))
93-
model_local_dir = "model"
94-
os.makedirs(model_local_dir, exist_ok=True)
9592

96-
# Download Model to Project root directory
97-
# model_name = "sklearn_regression_model.pkl"
98-
run.download_file(
99-
name="./outputs/" + model_name, output_file_path="./model/" + model_name
100-
)
101-
print("Downloaded model {} to Project root directory".format(model_name))
102-
os.chdir("./model")
103-
model = Model.register(
104-
model_path=model_name, # this points to a local file
105-
model_name=model_name, # this is the name the model is registered as
106-
tags={"area": "diabetes", "type": "regression", "run_id": run_id},
107-
description="Regression model for diabetes dataset",
108-
workspace=ws,
109-
)
93+
model = run.register_model(model_name=model_name,
94+
model_path="./outputs/" + model_name,
95+
tags={"area": "diabetes", "type": "regression"})
11096
os.chdir("..")
11197
print(
11298
"Model registered: {} \nModel Description: {} \nModel Version: {}".format(
11399
model.name, model.description, model.version
114100
)
115101
)
116102

117-
# Remove the evaluate.json as we no longer need it
118-
# os.remove("aml_config/evaluate.json")
119-
120103
# Writing the registered model details to /aml_config/model.json
121104
model_json = {}
122105
model_json["model_name"] = model.name

0 commit comments

Comments
 (0)