File tree Expand file tree Collapse file tree
diabetes_regression/scoring Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2626import numpy
2727import joblib
2828import os
29+ from azureml .core .model import Model
2930from inference_schema .schema_decorators \
3031 import input_schema , output_schema
3132from inference_schema .parameter_types .numpy_parameter_type \
@@ -36,16 +37,13 @@ def init():
3637 # load the model from file into a global object
3738 global model
3839
39- # AZUREML_MODEL_DIR is an environment variable created during service
40- # deployment. It contains the path to the folder containing the model.
41- path = os .environ ['AZUREML_MODEL_DIR' ]
42- model_path = None
43- for root , dirs , files in os .walk (path ):
44- for file in files :
45- if '.pkl' in file :
46- model_path = os .path .join (path , file )
47- if model_path is None :
48- raise ValueError (".pkl model not found" )
40+ # we assume that we have just one model
41+ # AZUREML_MODEL_DIR is an environment variable created during deployment.
42+ # It is the path to the model folder
43+ # (./azureml-models/$MODEL_NAME/$VERSION)
44+ model_path = Model .get_model_path (
45+ os .getenv ("AZUREML_MODEL_DIR" ).split ('/' )[- 2 ])
46+
4947 model = joblib .load (model_path )
5048
5149
You can’t perform that action at this time.
0 commit comments