-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathCheck_Model_Version.py
64 lines (40 loc) · 1.36 KB
/
Check_Model_Version.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Databricks notebook source
# MAGIC %md ## Check Model Version
# MAGIC
# MAGIC Checks that a model version's run model artifact (run_model) matches the cached model registry model (reg_model).
# COMMAND ----------
# MAGIC %md #### Setup
# COMMAND ----------
# MAGIC %run ../Common
# COMMAND ----------
# MAGIC %md #### Widgets
# COMMAND ----------
dbutils.widgets.text("1. Registered model", "")
model_name = dbutils.widgets.get("1. Registered model")
dbutils.widgets.text("2. Version or stage", "")
version_or_stage = dbutils.widgets.get("2. Version or stage")
print("model_name:", model_name)
print("version_or_stage:", version_or_stage)
# COMMAND ----------
assert_widget(model_name, "1. Registered model")
assert_widget(version_or_stage, "2. Version or stage")
# COMMAND ----------
# MAGIC %md #### Download scratch directory
# COMMAND ----------
download_dir = "/tmp/mlflow_tools/check_version"
import shutil
shutil.rmtree(download_dir, ignore_errors=True)
# COMMAND ----------
# MAGIC %md #### Run version check
# COMMAND ----------
from mlflow_tools.check_version.check_model_version import check_version
res = check_version(
model_name = model_name,
version_or_stage = version_or_stage,
download_dir = download_dir
)
res
# COMMAND ----------
# MAGIC %md #### Show result
# COMMAND ----------
print("Comparison result:", res["Comparison"]["equals"])