-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into test-ml-sdk-version-ml-1.11.1
- Loading branch information
Showing
39 changed files
with
2,488 additions
and
2 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
cli/endpoints/online/deploy-with-packages/custom-model/deploy.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#<register_model> | ||
MODEL_NAME='sklearn-regression' | ||
MODEL_PATH='model' | ||
az ml model create --name $MODEL_NAME --path $MODEL_PATH --type custom_model | ||
#</register_model> | ||
|
||
#<base_environment> | ||
az ml environment create -f environment/sklearn-regression-env.yml | ||
#</base_environment> | ||
|
||
#<build_package> | ||
az ml model package -n $MODEL_NAME -l latest --file package-moe.yml | ||
#</build_package> | ||
|
||
#<endpoint_name> | ||
ENDPOINT_NAME = "sklearn-regression-online" | ||
#</endpoint_name> | ||
|
||
# The following code ensures the created deployment has a unique name | ||
ENDPOINT_SUFIX=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w ${1:-5} | head -n 1) | ||
ENDPOINT_NAME="$ENDPOINT_NAME-$ENDPOINT_SUFIX" | ||
|
||
#<create_endpoint> | ||
az ml online-endpoint create -n $ENDPOINT_NAME | ||
#</create_endpoint> | ||
|
||
#<create_deployment> | ||
az ml online-deployment create -f deployment.yml | ||
#</create_deployment> | ||
|
||
#<test_deployment> | ||
az ml online-endpoint invoke -n $ENDPOINT_NAME -d with-package -f sample-request.json | ||
#</test_deployment> | ||
|
||
#<create_deployment_with_package> | ||
az ml online-deployment create -f model-deployment.yml --with-package | ||
#</create_deployment_with_package> | ||
|
||
#<delete_resources> | ||
az ml online-endpoint delete -n $ENDPOINT_NAME --yes | ||
#</delete_resources> | ||
|
||
#<build_package_copy> | ||
az ml model package -n $MODEL_NAME -l latest --file package-external.yml | ||
#</build_package_copy> |
6 changes: 6 additions & 0 deletions
6
cli/endpoints/online/deploy-with-packages/custom-model/deployment.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
$schema: https://azuremlschemas.azureedge.net/latest/managedOnlineDeployment.schema.json | ||
name: with-package | ||
endpoint_name: hello-packages | ||
environment: azureml:sklearn-regression-online-pkg@latest | ||
instance_type: Standard_DS3_v2 | ||
instance_count: 1 |
3 changes: 3 additions & 0 deletions
3
cli/endpoints/online/deploy-with-packages/custom-model/endpoint.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
$schema: https://azuremlschemas.azureedge.net/latest/managedOnlineEndpoint.schema.json | ||
name: hello-packages | ||
auth_mode: key |
10 changes: 10 additions & 0 deletions
10
cli/endpoints/online/deploy-with-packages/custom-model/environment/conda.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: model-env | ||
channels: | ||
- conda-forge | ||
dependencies: | ||
- python=3.9 | ||
- numpy=1.23.5 | ||
- pip=23.0.1 | ||
- scikit-learn=1.2.2 | ||
- scipy=1.10.1 | ||
- xgboost==1.3.3 |
5 changes: 5 additions & 0 deletions
5
...endpoints/online/deploy-with-packages/custom-model/environment/sklearn-regression-env.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
$schema: https://azuremlschemas.azureedge.net/latest/environment.schema.json | ||
name: sklearn-regression-env | ||
image: mcr.microsoft.com/azureml/openmpi4.1.0-ubuntu22.04 | ||
conda_file: conda.yaml | ||
description: An environment for models built with XGBoost and Scikit-learn. |
10 changes: 10 additions & 0 deletions
10
cli/endpoints/online/deploy-with-packages/custom-model/model-deployment.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
$schema: https://azuremlschemas.azureedge.net/latest/managedOnlineDeployment.schema.json | ||
name: with-package | ||
endpoint_name: hello-packages | ||
model: azureml:sklearn-regression@latest | ||
environment: azureml:sklearn-regression-env@latest | ||
code_configuration: | ||
code: src | ||
scoring_script: score.py | ||
instance_type: Standard_DS3_v2 | ||
instance_count: 1 |
Binary file added
BIN
+756 Bytes
cli/endpoints/online/deploy-with-packages/custom-model/model/sklearn_regression_model.pkl
Binary file not shown.
12 changes: 12 additions & 0 deletions
12
cli/endpoints/online/deploy-with-packages/custom-model/package-external.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
$schema: http://azureml/sdk-2-0/ModelVersionPackage.json | ||
base_environment_source: | ||
type: environment_asset | ||
resource_id: azureml:sklearn-regression-env@latest | ||
target_environment_name: sklearn-regression-docker-pkg | ||
inferencing_server: | ||
type: azureml_online | ||
code_configuration: | ||
code: src | ||
entry_script: score.py | ||
model_configuration: | ||
mode: copy |
10 changes: 10 additions & 0 deletions
10
cli/endpoints/online/deploy-with-packages/custom-model/package-moe.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
$schema: http://azureml/sdk-2-0/ModelVersionPackage.json | ||
base_environment_source: | ||
type: environment_asset | ||
resource_id: azureml:sklearn-regression-env@latest | ||
target_environment_name: sklearn-regression-online-pkg | ||
inferencing_server: | ||
type: azureml_online | ||
code_configuration: | ||
code: src | ||
entry_script: score.py |
6 changes: 6 additions & 0 deletions
6
cli/endpoints/online/deploy-with-packages/custom-model/sample-request.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"data": [ | ||
[1,2,3,4,5,6,7,8,9,10], | ||
[10,9,8,7,6,5,4,3,2,1] | ||
] | ||
} |
36 changes: 36 additions & 0 deletions
36
cli/endpoints/online/deploy-with-packages/custom-model/src/score.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import os | ||
import logging | ||
import json | ||
import numpy | ||
import joblib | ||
|
||
|
||
def init(): | ||
""" | ||
This function is called when the container is initialized/started, typically after create/update of the deployment. | ||
You can write the logic here to perform init operations like caching the model in memory | ||
""" | ||
global model | ||
# AZUREML_MODEL_DIR is an environment variable created during deployment. | ||
# It is the path to the model folder (./azureml-models/$MODEL_NAME/$VERSION) | ||
# Please provide your model's folder name if there is one | ||
model_path = os.path.join( | ||
os.getenv("AZUREML_MODEL_DIR"), "model/sklearn_regression_model.pkl" | ||
) | ||
# deserialize the model file back into a sklearn model | ||
model = joblib.load(model_path) | ||
logging.info("Init complete") | ||
|
||
|
||
def run(raw_data): | ||
""" | ||
This function is called for every invocation of the endpoint to perform the actual scoring/prediction. | ||
In the example we extract the data from the json input and call the scikit-learn model's predict() | ||
method and return the result back | ||
""" | ||
logging.info("model 1: request received") | ||
data = json.loads(raw_data)["data"] | ||
data = numpy.array(data) | ||
result = model.predict(data) | ||
logging.info("Request processed") | ||
return result.tolist() |
41 changes: 41 additions & 0 deletions
41
cli/endpoints/online/deploy-with-packages/mlflow-model/deploy.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#<register_model> | ||
MODEL_NAME='heart-classifier-mlflow' | ||
MODEL_PATH='model' | ||
az ml model create --name $MODEL_NAME --path $MODEL_PATH --type mlflow_model | ||
#</register_model> | ||
|
||
#<build_package> | ||
az ml model package -n $MODEL_NAME -l latest --file package.yml | ||
#</build_package> | ||
|
||
#<endpoint_name> | ||
ENDPOINT_NAME = "heart-classifier" | ||
#</endpoint_name> | ||
|
||
# The following code ensures the created deployment has a unique name | ||
ENDPOINT_SUFIX=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w ${1:-5} | head -n 1) | ||
ENDPOINT_NAME="$ENDPOINT_NAME-$ENDPOINT_SUFIX" | ||
|
||
#<create_endpoint> | ||
az ml online-endpoint create -n $ENDPOINT_NAME | ||
#</create_endpoint> | ||
|
||
#<create_deployment> | ||
az ml online-deployment create -f deployment.yml -e $ENDPOINT_NAME | ||
#</create_deployment> | ||
|
||
#<test_deployment> | ||
az ml online-endpoint invoke -n $ENDPOINT_NAME -d with-package -f sample-request.json | ||
#</test_deployment> | ||
|
||
#<create_deployment_inline> | ||
az ml online-deployment create -f model-deployment.yml -e $ENDPOINT_NAME | ||
#</create_deployment_inline> | ||
|
||
#<delete_resources> | ||
az ml online-endpoint delete -n $ENDPOINT_NAME --yes | ||
#</delete_resources> | ||
|
||
#<build_package_copy> | ||
az ml model package -n $MODEL_NAME -l latest --file package-external.yml | ||
#</build_package_copy> |
6 changes: 6 additions & 0 deletions
6
cli/endpoints/online/deploy-with-packages/mlflow-model/deployment.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
$schema: https://azuremlschemas.azureedge.net/latest/managedOnlineDeployment.schema.json | ||
name: with-package | ||
endpoint_name: heart-classifier | ||
environment: azureml:heart-classifier-mlflow-pkg@latest | ||
instance_type: Standard_DS3_v2 | ||
instance_count: 1 |
3 changes: 3 additions & 0 deletions
3
cli/endpoints/online/deploy-with-packages/mlflow-model/endpoint.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
$schema: https://azuremlschemas.azureedge.net/latest/managedOnlineEndpoint.schema.json | ||
name: heart-classifier | ||
auth_mode: key |
6 changes: 6 additions & 0 deletions
6
cli/endpoints/online/deploy-with-packages/mlflow-model/model-deployment.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
$schema: https://azuremlschemas.azureedge.net/latest/managedOnlineDeployment.schema.json | ||
name: with-package-inline | ||
endpoint_name: heart-classifier-mlflow | ||
model: azureml:heart-classifier-mlflow@latest | ||
instance_type: Standard_DS3_v2 | ||
instance_count: 1 |
22 changes: 22 additions & 0 deletions
22
cli/endpoints/online/deploy-with-packages/mlflow-model/model/MLmodel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
artifact_path: pipeline | ||
flavors: | ||
python_function: | ||
env: conda.yaml | ||
loader_module: mlflow.sklearn | ||
model_path: model.pkl | ||
python_version: 3.8.5 | ||
sklearn: | ||
pickled_model: model.pkl | ||
serialization_format: cloudpickle | ||
sklearn_version: 1.1.2 | ||
model_uuid: 04bd660a1b8b4b1e84b9198c46cfd117 | ||
run_id: 22874b7e-b069-43f0-b90c-1c57793c7854 | ||
signature: | ||
inputs: '[{"name": "age", "type": "long"}, {"name": "sex", "type": "long"}, | ||
{"name": "cp", "type": "long"}, {"name": "trestbps", "type": "long"}, {"name": | ||
"chol", "type": "long"}, {"name": "fbs", "type": "long"}, {"name": "restecg", | ||
"type": "long"}, {"name": "thalach", "type": "long"}, {"name": "exang", "type": | ||
"long"}, {"name": "oldpeak", "type": "double"}, {"name": "slope", "type": "long"}, | ||
{"name": "ca", "type": "long"}, {"name": "thal", "type": "string"}]' | ||
outputs: '[{"type": "long"}]' | ||
utc_time_created: '2022-10-13 00:55:57.543663' |
11 changes: 11 additions & 0 deletions
11
cli/endpoints/online/deploy-with-packages/mlflow-model/model/conda.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
channels: | ||
- conda-forge | ||
dependencies: | ||
- python=3.8.5 | ||
- pip | ||
- pip: | ||
- mlflow | ||
- cloudpickle==1.6.0 | ||
- scikit-learn==1.1.2 | ||
- xgboost==1.3.3 | ||
name: mlflow-env |
Binary file added
BIN
+116 KB
cli/endpoints/online/deploy-with-packages/mlflow-model/model/model.pkl
Binary file not shown.
15 changes: 15 additions & 0 deletions
15
cli/endpoints/online/deploy-with-packages/mlflow-model/model/requirements.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
mlflow | ||
cloudpickle==1.6.0 | ||
colorama==0.4.4 | ||
dask==2.30.0 | ||
dataclasses==0.6 | ||
lz4==4.0.0 | ||
psutil==5.9.0 | ||
scikit-learn==1.1.2 | ||
sparse==0.13.0 | ||
tblib==1.7.0 | ||
toolz==0.11.2 | ||
typing-extensions==4.1.1 | ||
uuid==1.30 | ||
xgboost==1.4.2 | ||
xxhash==3.0.0 |
6 changes: 6 additions & 0 deletions
6
cli/endpoints/online/deploy-with-packages/mlflow-model/package-external.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
$schema: http://azureml/sdk-2-0/ModelVersionPackage.json | ||
target_environment_name: heart-classifier-mlflow-pkg | ||
inferencing_server: | ||
type: azureml_online | ||
model_configuration: | ||
mode: copy |
4 changes: 4 additions & 0 deletions
4
cli/endpoints/online/deploy-with-packages/mlflow-model/package.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
$schema: http://azureml/sdk-2-0/ModelVersionPackage.json | ||
target_environment_name: heart-classifier-mlflow-pkg | ||
inferencing_server: | ||
type: azureml_online |
11 changes: 11 additions & 0 deletions
11
cli/endpoints/online/deploy-with-packages/mlflow-model/sample-request.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"input_data": { | ||
"columns": [ | ||
"age", "sex", "cp", "trestbps", "chol", "fbs", "restecg", "thalach", "exang", "oldpeak", "slope", "ca", "thal" | ||
], | ||
"index": [1], | ||
"data": [ | ||
[1, 1, 4, 145, 233, 1, 2, 150, 0, 2.3, 3, 0, 2] | ||
] | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
cli/endpoints/online/deploy-with-packages/registry-model/deploy.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#<get_model> | ||
MODEL_NAME="t5-base" | ||
MODEL_VERSION=$(az ml model show --name $MODEL_NAME --label latest --registry-name azureml | jq .version -r) | ||
#</get_model> | ||
|
||
#<build_package> | ||
az ml model package --name $MODEL_NAME \ | ||
--version $MODEL_VERSION \ | ||
--registry-name azureml \ | ||
--file package.yml | ||
#</build_package> |
4 changes: 4 additions & 0 deletions
4
cli/endpoints/online/deploy-with-packages/registry-model/package.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
$schema: http://azureml/sdk-2-0/ModelVersionPackage.json | ||
target_environment_name: pkg-t5-base-online | ||
inferencing_server: | ||
type: azureml_online |
10 changes: 10 additions & 0 deletions
10
sdk/python/endpoints/online/deploy-with-packages/custom-model/environment/conda.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: model-env | ||
channels: | ||
- conda-forge | ||
dependencies: | ||
- python=3.9 | ||
- numpy=1.23.5 | ||
- pip=23.0.1 | ||
- scikit-learn=1.2.2 | ||
- scipy=1.10.1 | ||
- xgboost==1.3.3 |
5 changes: 5 additions & 0 deletions
5
...endpoints/online/deploy-with-packages/custom-model/environment/sklearn-regression-env.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
$schema: https://azuremlschemas.azureedge.net/latest/environment.schema.json | ||
name: sklearn-regression-env | ||
image: mcr.microsoft.com/azureml/openmpi4.1.0-ubuntu22.04 | ||
conda_file: conda.yaml | ||
description: An environment for models built with XGBoost and Scikit-learn. |
Binary file added
BIN
+756 Bytes
...hon/endpoints/online/deploy-with-packages/custom-model/model/sklearn_regression_model.pkl
Binary file not shown.
6 changes: 6 additions & 0 deletions
6
sdk/python/endpoints/online/deploy-with-packages/custom-model/sample-request.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"data": [ | ||
[1,2,3,4,5,6,7,8,9,10], | ||
[10,9,8,7,6,5,4,3,2,1] | ||
] | ||
} |
Oops, something went wrong.