Skip to content

Commit 72939c7

Browse files
direct: refactor models test; record API requests
1 parent c3a2754 commit 72939c7

22 files changed

+374
-144
lines changed

acceptance/bundle/deploy/models/basic/output.txt

Lines changed: 0 additions & 110 deletions
This file was deleted.

acceptance/bundle/deploy/models/basic/script

Lines changed: 0 additions & 32 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
bundle:
2+
name: model-change-description-$UNIQUE_NAME
3+
4+
resources:
5+
models:
6+
my_model:
7+
name: $MODEL_NAME
8+
description: $MODEL_DESCRIPTION
9+
tags:
10+
- key: "k1"
11+
value: "v1"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"method": "POST",
3+
"path": "/api/2.0/mlflow/registered-models/create",
4+
"body": {
5+
"description": "original-description-[UNIQUE_NAME]",
6+
"name": "original-name-[UNIQUE_NAME]",
7+
"tags": [
8+
{
9+
"key": "k1",
10+
"value": "v1"
11+
}
12+
]
13+
}
14+
}

acceptance/bundle/deploy/models/basic/out.test.toml renamed to acceptance/bundle/resources/models/change-description/out.test.toml

File renamed without changes.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
2+
=== create the model
3+
>>> export MODEL_DESCRIPTION=original-description-[UNIQUE_NAME]
4+
5+
>>> export MODEL_NAME=original-name-[UNIQUE_NAME]
6+
7+
>>> [CLI] bundle plan
8+
create models.my_model
9+
10+
Plan: 1 to add, 0 to change, 0 to delete, 0 unchanged
11+
12+
>>> [CLI] bundle deploy
13+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/model-change-description-[UNIQUE_NAME]/default/files...
14+
Deploying resources...
15+
Updating deployment state...
16+
Deployment complete!
17+
18+
>>> [CLI] model-registry get-model original-name-[UNIQUE_NAME]
19+
{
20+
"name": "original-name-[UNIQUE_NAME]",
21+
"description": "original-description-[UNIQUE_NAME]",
22+
"tags": [
23+
{
24+
"key": "k1",
25+
"value": "v1"
26+
}
27+
]
28+
}
29+
30+
=== update the description
31+
>>> export MODEL_DESCRIPTION=new-description-[UNIQUE_NAME]
32+
33+
>>> [CLI] bundle plan
34+
update models.my_model
35+
36+
Plan: 0 to add, 1 to change, 0 to delete, 0 unchanged
37+
38+
>>> [CLI] bundle deploy
39+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/model-change-description-[UNIQUE_NAME]/default/files...
40+
Deploying resources...
41+
Updating deployment state...
42+
Deployment complete!
43+
44+
>>> [CLI] model-registry get-model original-name-[UNIQUE_NAME]
45+
{
46+
"name": "original-name-[UNIQUE_NAME]",
47+
"description": "new-description-[UNIQUE_NAME]",
48+
"tags": [
49+
{
50+
"key": "k1",
51+
"value": "v1"
52+
}
53+
]
54+
}
55+
56+
=== Print all POST API requests made the the models service.
57+
>>> cat out.requests.txt
58+
59+
>>> [CLI] bundle destroy --auto-approve
60+
The following resources will be deleted:
61+
delete model my_model
62+
63+
All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/model-change-description-[UNIQUE_NAME]/default
64+
65+
Deleting files...
66+
Destroy complete!
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
cleanup() {
2+
trace $CLI bundle destroy --auto-approve
3+
rm out.requests.txt
4+
}
5+
6+
trap cleanup EXIT
7+
8+
deploy_with_plan() {
9+
trace $CLI bundle plan
10+
trace $CLI bundle deploy
11+
model_id=$($CLI bundle summary --output json | jq -r '.resources.models.my_model.id')
12+
trace $CLI model-registry get-model $model_id | jq '.registered_model_databricks | {name, description, tags}'
13+
}
14+
15+
title "create the model"
16+
trace export MODEL_DESCRIPTION="original-description-${UNIQUE_NAME}"
17+
trace export MODEL_NAME="original-name-${UNIQUE_NAME}"
18+
envsubst < databricks.yml.tmpl > databricks.yml
19+
deploy_with_plan
20+
21+
title "update the description"
22+
trace export MODEL_DESCRIPTION="new-description-${UNIQUE_NAME}"
23+
envsubst < databricks.yml.tmpl > databricks.yml
24+
deploy_with_plan
25+
26+
title "Print all POST API requests made the the models service."
27+
trace cat out.requests.txt | jq 'select(.method == "POST")' | jq 'select(.path | contains("/api/2.0/mlflow/registered-models"))' > out.requests.models.txt
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
bundle:
2+
name: model-change-name-$UNIQUE_NAME
3+
4+
resources:
5+
models:
6+
my_model:
7+
name: $MODEL_NAME
8+
description: $MODEL_DESCRIPTION
9+
tags:
10+
- key: "k1"
11+
value: "v1"
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"method": "POST",
3+
"path": "/api/2.0/mlflow/registered-models/create",
4+
"body": {
5+
"description": "original-description-[UNIQUE_NAME]",
6+
"name": "original-name-[UNIQUE_NAME]",
7+
"tags": [
8+
{
9+
"key": "k1",
10+
"value": "v1"
11+
}
12+
]
13+
}
14+
}
15+
{
16+
"method": "POST",
17+
"path": "/api/2.0/mlflow/registered-models/create",
18+
"body": {
19+
"description": "original-description-[UNIQUE_NAME]",
20+
"name": "new-name-[UNIQUE_NAME]",
21+
"tags": [
22+
{
23+
"key": "k1",
24+
"value": "v1"
25+
}
26+
]
27+
}
28+
}

acceptance/bundle/resources/models/change-name/out.test.toml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)