LocalWebservice class

Definition

Class for local debug Webservices.

LocalWebservice(workspace, name, must_exist=True)
Inheritance
LocalWebservice

Parameters

workspace
Workspace

The workspace object containing any Model objects that will be retrieved.

name
str

The name of the Webservice object to retrieve.

Methods

delete(delete_cache=True, delete_image=False, delete_volume=True)

Delete this LocalWebservice from the local machine.

This function call is not asynchronous; it runs until the service is deleted.

deploy_configuration(port=None)

Create a configuration object for deploying a local Webservice.

deploy_to_cloud(name=None, deployment_config=None, deployment_target=None)

Deploy a Webservice based on the LocalWebservice's configuration.

deserialize(workspace, webservice_payload)

Convert a json object generated from serialize() into a Webservice object.

Not supported for LocalWebservice.

get_keys()

Retrieve auth keys for this Webservice.

Not supported for LocalWebservice.

get_logs(num_lines=5000, raw=False)

Retrieve logs for this LocalWebservice.

get_token()

Retrieve auth token for this Webservice, scoped to the current user.

list(workspace, model_name=None, model_id=None)

List the LocalWebservices associated with the corresponding Workspace. Can be filtered using parameters.

Not supported for LocalWebservice.

regen_key(key)

Regenerate one of the Webservice's keys.

Not supported for LocalWebservice.

reload(wait=False)

Reload the LocalWebservice's execution script and dependencies.

This restarts the service's container with copies of updated assets, including the execution script and local dependencies, but it does not rebuild the underlying image. Accordingly, changes to Conda/pip dependencies or custom Docker steps will not be reflected in the reloaded LocalWebservice. To handle those changes call LocalWebservice.update(), instead.

run(input_data)

Call this LocalWebservice with the provided input.

serialize()

Convert this Webservice into a JSON-serialized dictionary.

update(models=None, image_config=None, deployment_config=None, wait=False, inference_config=None)

Update the LocalWebservice with provided properties.

Values left as None will remain unchanged in this LocalWebservice.

update_deployment_state(must_exist=False)

Refresh the current state of the in-memory object.

Perform an in-place update of the properties of the object based on the current state of the corresponding local Docker container.

wait_for_deployment(show_output=False)

Poll the running LocalWebservice deployment.

delete(delete_cache=True, delete_image=False, delete_volume=True)

Delete this LocalWebservice from the local machine.

This function call is not asynchronous; it runs until the service is deleted.

delete(delete_cache=True, delete_image=False, delete_volume=True)

Parameters

delete_cache
bool

Delete temporary files cached for the service. (Default: True)

delete_image
bool

Delete the service's Docker image. (Default: False)

delete_volume
bool

Delete the service's Docker volume. (Default: True)

deploy_configuration(port=None)

Create a configuration object for deploying a local Webservice.

deploy_configuration(port=None)

Parameters

port
int

The local port on which to expose the service's HTTP endpoint.

default value: None

Returns

A configuration object to use when deploying a Webservice object

Return type

LocalWebserviceDeploymentConfiguration

deploy_to_cloud(name=None, deployment_config=None, deployment_target=None)

Deploy a Webservice based on the LocalWebservice's configuration.

deploy_to_cloud(name=None, deployment_config=None, deployment_target=None)

Parameters

name
str

The name to give the deployed service. Must be unique to the workspace.

default value: None
deployment_config
WebserviceDeploymentConfiguration

A WebserviceDeploymentConfiguration used to configure the webservice. If one is not provided, an empty configuration object will be used based on the desired target.

default value: None
deployment_target
ComputeTarget

A ComputeTarget to which to deploy the Webservice. As ACI has no associated ComputeTarget, leave this parameter as None to deploy to ACI.

default value: None

Returns

A Webservice object corresponding to the deployed webservice.

Return type

deserialize(workspace, webservice_payload)

Convert a json object generated from serialize() into a Webservice object.

Not supported for LocalWebservice.

deserialize(workspace, webservice_payload)

Parameters

cls
workspace
Workspace

The workspace object the Webservice is registered under

webservice_payload
dict

A json object to convert to a Webservice object

get_keys()

Retrieve auth keys for this Webservice.

Not supported for LocalWebservice.

get_keys()

Returns

The auth keys for this Webservice

get_logs(num_lines=5000, raw=False)

Retrieve logs for this LocalWebservice.

get_logs(num_lines=5000, raw=False)

Parameters

num_lines
int

The maximum number of log lines to retrieve. (Default: 5000)

raw
bool

Return the raw Docker container output without attempting to format it. (Default: False)

Returns

The logs for this LocalWebservice.

Return type

str

get_token()

Retrieve auth token for this Webservice, scoped to the current user.

get_token()

Returns

The auth token for this Webservice and when it should be refreshed after.

Return type

list(workspace, model_name=None, model_id=None)

List the LocalWebservices associated with the corresponding Workspace. Can be filtered using parameters.

Not supported for LocalWebservice.

list(workspace, model_name=None, model_id=None)

Parameters

workspace
Workspace

The Workspace object associated with the LocalWebservices.

model_name
str

Filter list to only include LocalWebservices deployed with the specific model name.

default value: None
model_id
str

Filter list to only include LocalWebservices deployed with the specific model ID.

default value: None

Returns

A filtered list of LocalWebservices associated with the provided Workspace.

Return type

regen_key(key)

Regenerate one of the Webservice's keys.

Not supported for LocalWebservice.

regen_key(key)

Parameters

key
str

Which key to regenerate. Options are 'Primary' or 'Secondary'

reload(wait=False)

Reload the LocalWebservice's execution script and dependencies.

This restarts the service's container with copies of updated assets, including the execution script and local dependencies, but it does not rebuild the underlying image. Accordingly, changes to Conda/pip dependencies or custom Docker steps will not be reflected in the reloaded LocalWebservice. To handle those changes call LocalWebservice.update(), instead.

reload(wait=False)

Parameters

wait
bool

Wait for the service's container to reach a healthy state. (Default: False)

run(input_data)

Call this LocalWebservice with the provided input.

run(input_data)

Parameters

input_data
varies

The input with which to call the LocalWebservice.

Returns

The result of calling the LocalWebservice.

Return type

varies

serialize()

Convert this Webservice into a JSON-serialized dictionary.

serialize()

Returns

Serialized representation of the Webservice.

Return type

update(models=None, image_config=None, deployment_config=None, wait=False, inference_config=None)

Update the LocalWebservice with provided properties.

Values left as None will remain unchanged in this LocalWebservice.

update(models=None, image_config=None, deployment_config=None, wait=False, inference_config=None)

Parameters

models
list[Model]

A new list of models contained in the LocalWebservice.

image_config
ContainerImageConfig

Image configuration options to apply to the LocalWebservice.

deployment_config
LocalWebserviceDeploymentConfiguration

Deployment configuration options to apply to the LocalWebservice.

inference_config
InferenceConfig

An InferenceConfig object used to provide the required model deployment properties.

wait
bool

Wait for the service's container to reach a healthy state. (Default: False)

Return type

update_deployment_state(must_exist=False)

Refresh the current state of the in-memory object.

Perform an in-place update of the properties of the object based on the current state of the corresponding local Docker container.

update_deployment_state(must_exist=False)

Parameters

must_exist
bool

Boolean for if there must be a service deployed in order to get the object (Default: False)

default value: False

wait_for_deployment(show_output=False)

Poll the running LocalWebservice deployment.

wait_for_deployment(show_output=False)

Parameters

show_output
bool

Option to print more verbose output. (Default: False)

Attributes

port

Get the local webservice port.

Returns

Port number.

Return type

int

scoring_uri

Get the local webservice scoring URI.

Returns

Scoring URI.

Return type

str

swagger_uri

Get the local webservice Swagger URI.

Returns

Swagger URI.

Return type

str

CONTAINER_ENVVAR_MODEL_PATH

CONTAINER_ENVVAR_MODEL_PATH = 'AZUREML_MODEL_DIR'

CONTAINER_LABEL_DEPLOYMENT_CONFIG

CONTAINER_LABEL_DEPLOYMENT_CONFIG = 'amlDeploymentConfig'

CONTAINER_LABEL_IMAGE_CONFIG

CONTAINER_LABEL_IMAGE_CONFIG = 'amlImageConfig'

CONTAINER_LABEL_INFERENCE_CONFIG

CONTAINER_LABEL_INFERENCE_CONFIG = 'amlInferenceConfig'

CONTAINER_LABEL_IS_SERVICE

CONTAINER_LABEL_IS_SERVICE = 'amlIsService'

CONTAINER_LABEL_MODELS_LOCAL

CONTAINER_LABEL_MODELS_LOCAL = 'amlModelsLocal'

CONTAINER_LABEL_MODELS_REMOTE

CONTAINER_LABEL_MODELS_REMOTE = 'amlModelsRemote'

CONTAINER_LABEL_SERVICE_NAME

CONTAINER_LABEL_SERVICE_NAME = 'amlServiceName'

NETWORK_NAME

NETWORK_NAME = 'azureml-local'

STATE_DELETED

STATE_DELETED = 'deleted'

STATE_DEPLOYING

STATE_DEPLOYING = 'deploying'

STATE_FAILED

STATE_FAILED = 'failed'

STATE_RUNNING

STATE_RUNNING = 'running'

STATE_UNKNOWN

STATE_UNKNOWN = 'unknown'