Skip to content

Commit

Permalink
No pkl extension requirement for model name (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbaidachni authored Jan 31, 2020
1 parent 962778c commit 8ae6701
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions diabetes_regression/scoring/score.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import numpy
import joblib
import os
from azureml.core.model import Model
from inference_schema.schema_decorators \
import input_schema, output_schema
from inference_schema.parameter_types.numpy_parameter_type \
Expand All @@ -36,16 +37,13 @@ def init():
# load the model from file into a global object
global model

# AZUREML_MODEL_DIR is an environment variable created during service
# deployment. It contains the path to the folder containing the model.
path = os.environ['AZUREML_MODEL_DIR']
model_path = None
for root, dirs, files in os.walk(path):
for file in files:
if '.pkl' in file:
model_path = os.path.join(path, file)
if model_path is None:
raise ValueError(".pkl model not found")
# we assume that we have just one model
# AZUREML_MODEL_DIR is an environment variable created during deployment.
# It is the path to the model folder
# (./azureml-models/$MODEL_NAME/$VERSION)
model_path = Model.get_model_path(
os.getenv("AZUREML_MODEL_DIR").split('/')[-2])

model = joblib.load(model_path)


Expand Down

0 comments on commit 8ae6701

Please sign in to comment.