You are deploying your trained model as a web service to ACI compute in order to expose it as a REST API accessible for HTTP requests.
One of your teammates has written the following code.
You are reviewing it and you find that a line of code is missing.
# code sample deployment_config = AciWebservice.deploy_configuration(cpu_cores = 1, memory_gb = 1) ... service = Model.deploy(ws, service_name, [model], inference_config, deployment_config) ... <insert missing line here> ... predictions = requests.post(endpoint, input_json, headers = headers)Which of the following code segments must be added to the script?
Click on the arrows to vote for the correct answer
A. B. C. D.Answer: B.
Option A is incorrect because the name of the service must be defined during the creation (deployment) of the service.
This is a string, not a URL.
Option B is CORRECT because in order to access a deployed web service via HTTP, you need the name of the endpoint, i.e.
the URL of the service.
This can be queried from the scoring_uri parameter of the service object.
Option C is incorrect because there is no such attribute in the AciWebservice object.
It is the attribute scoring_uri that holds the URL for the REST calls.
Option D is incorrect because it lists the models deployed to the Webservice, which cannot be used for REST requests.
Reference:
To expose the trained model as a REST API accessible for HTTP requests, you need to deploy it as a web service to Azure Container Instances (ACI) compute. In the given code sample, the deployment configuration is defined, and the model is deployed as a web service using the Azure Machine Learning SDK.
However, one important line of code is missing that defines the endpoint URL that will be used to send HTTP requests to the deployed web service. The correct endpoint URL must be used to access the web service and get the predictions from the trained model.
The correct endpoint URL can be obtained using the service.scoring_uri
property, which returns the scoring endpoint for the deployed service. This endpoint is the URL that clients can use to send requests to the web service and get predictions.
Therefore, the missing line of code in the given script should be:
makefileendpoint = service.scoring_uri
This line of code assigns the scoring URI to the endpoint
variable, which can be used later in the script to send HTTP requests to the deployed web service.
Option A (service.service_name
) is not the correct option, as this property returns the name of the deployed web service, not the scoring endpoint URL.
Option B (service.scoring_uri
) is the correct option, as explained above.
Option C (service.service_endpoint
) is not the correct option, as this property returns the URL of the deployed web service, not the scoring endpoint URL.
Option D (service.models
) is not a valid property of the service
object, and therefore, is not the correct option.