File tree Expand file tree Collapse file tree 1 file changed +8
-10
lines changed
diabetes_regression/scoring Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change 26
26
import numpy
27
27
import joblib
28
28
import os
29
+ from azureml .core .model import Model
29
30
from inference_schema .schema_decorators \
30
31
import input_schema , output_schema
31
32
from inference_schema .parameter_types .numpy_parameter_type \
@@ -36,16 +37,13 @@ def init():
36
37
# load the model from file into a global object
37
38
global model
38
39
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
+
49
47
model = joblib .load (model_path )
50
48
51
49
You can’t perform that action at this time.
0 commit comments