nerdexam
Microsoft

DP-100 · Question #420

You register a model in an Azure Machine Learning workspace by running the following code: You are creating a scoring script to use in a real-time service for the model. You need to write code in…

The correct answer is A. path = Model.get_model_path('loan_model'). The Model.get_model_path() method is the correct Azure ML SDK approach to retrieve the local file path of a registered model inside a scoring script.

Train and deploy models

Question

You register a model in an Azure Machine Learning workspace by running the following code: You are creating a scoring script to use in a real-time service for the model. You need to write code in the scoring script to set the path of the registered model so that it can be loaded by the service. You include the necessary import statements. Which code segment should you use?

Exhibit

DP-100 question #420 exhibit

Options

  • Apath = Model.get_model_path('loan_model')
  • Bpath = 'model.pkl'
  • Cpath = ws.models('loan_model')
  • Dpath = 'outputs/model.pkl'

How the community answered

(23 responses)
  • A
    91% (21)
  • C
    4% (1)
  • D
    4% (1)

Why each option

The Model.get_model_path() method is the correct Azure ML SDK approach to retrieve the local file path of a registered model inside a scoring script.

Apath = Model.get_model_path('loan_model')Correct

When a registered model is deployed as a real-time service, Azure ML downloads the model files to the container environment. The Model.get_model_path('loan_model') call resolves the correct local file system path to those downloaded artifacts at runtime, allowing the script to load the model regardless of where the service is deployed.

Bpath = 'model.pkl'

'model.pkl' is a hardcoded relative path that will only work if the file happens to exist at that exact location in the deployment environment, making it fragile and not tied to the registered model.

Cpath = ws.models('loan_model')

ws.models() is not a valid method on the Workspace object for retrieving a model file path; it would raise an AttributeError.

Dpath = 'outputs/model.pkl'

'outputs/model.pkl' is a hardcoded path referencing a training run output directory, which is not the path used when a model is deployed as a real-time service.

Concept tested: Retrieving registered model path in a scoring script

Source: https://learn.microsoft.com/en-us/python/api/azureml-core/azureml.core.model.model#azureml-core-model-model-get-model-path

Topics

#Model Deployment#Scoring Script#Azure Machine Learning SDK#Model Registration

Community Discussion

No community discussion yet for this question.

Full DP-100 Practice