ComputeInstance Class
Manages a cloud-based, optimized ML development environment in Azure Machine Learning.
An Azure Machine Learning compute instance is a fully-configured and managed development environment in the cloud that is optimized for machine learning development workflows. ComputeInstance is typically used to create a development environment or as a compute target for training and inference for development and testing. With a ComputeInstance you can author, train, and deploy models in a fully integrated notebook experience in your workspace. For more information, see What is an Azure Machine Learning compute instance?.
Class ComputeTarget constructor.
Retrieve a cloud representation of a Compute object associated with the provided workspace. Returns an instance of a child class corresponding to the specific type of the retrieved Compute object.
- Inheritance
-
ComputeInstance
Constructor
ComputeInstance(workspace, name)
Parameters
Name | Description |
---|---|
workspace
Required
|
The workspace object containing the Compute object to retrieve. |
name
Required
|
The name of the of the Compute object to retrieve. |
Methods
delete |
Remove the ComputeInstance object from its associated workspace. |
deserialize |
Convert a JSON object into a ComputeInstance object. This fails if the provided workspace is not the workspace the ComputeInstance is associated with. |
detach |
Detach is not supported for ComputeInstance object. Use delete instead. |
get |
Return ComputeInstance object. |
get_active_runs |
Return a generator of the runs for this compute. |
get_docs_url |
Url to the documentation for this class. |
get_status |
Retrieve the current detailed status for the ComputeInstance. |
provisioning_configuration |
Create a configuration object for provisioning a ComputeInstance target. |
refresh_state |
Perform an in-place update of the properties of the object. This method updates the properties based on the current state of the corresponding cloud object. This is primarily useful for manual polling of compute state. |
restart |
Restart the ComputeInstance. |
serialize |
Convert this ComputeInstance object into a JSON serialized dictionary. |
start |
Start the ComputeInstance. |
stop |
Stop the ComputeInstance. |
supported_vmsizes |
List the supported VM sizes in a region. |
update_sso_settings |
Update single sign-on settings of the compute instance. |
wait_for_completion |
Wait for the ComputeInstance to finish provisioning. |
delete
Remove the ComputeInstance object from its associated workspace.
delete(wait_for_completion=False, show_output=False)
Parameters
Name | Description |
---|---|
wait_for_completion
|
Default value: False
|
show_output
|
Default value: False
|
Exceptions
Type | Description |
---|---|
Remarks
If this object was created through Azure ML, the corresponding cloud based objects will also be deleted. If this object was created externally and only attached to the workspace, it will raise exception and nothing will be changed.
deserialize
Convert a JSON object into a ComputeInstance object.
This fails if the provided workspace is not the workspace the ComputeInstance is associated with.
static deserialize(workspace, object_dict)
Parameters
Name | Description |
---|---|
workspace
Required
|
The workspace object the ComputeInstance object is associated with. |
object_dict
Required
|
A JSON object to convert to a ComputeInstance object. |
Returns
Type | Description |
---|---|
The ComputeInstance representation of the provided JSON object. |
Exceptions
Type | Description |
---|---|
detach
Detach is not supported for ComputeInstance object. Use delete instead.
detach()
Exceptions
Type | Description |
---|---|
The operation is not supproted. |
get
Return ComputeInstance object.
get()
Returns
Type | Description |
---|---|
The ComputeInstance representation of the provided JSON object. |
Exceptions
Type | Description |
---|---|
get_active_runs
Return a generator of the runs for this compute.
get_active_runs(type=None, tags=None, properties=None, status=None)
Parameters
Name | Description |
---|---|
type
|
Filter the returned generator of runs by the provided type. See add_type_provider for creating run types. Default value: None
|
tags
|
Filter runs by "tag" or {"tag": "value"} Default value: None
|
properties
|
Filter runs by "property" or {"property": "value"} Default value: None
|
status
|
Run status, can be "Running" or "Queued". Default value: None
|
Returns
Type | Description |
---|---|
<xref:builtin.generator>
|
A generator of azureml._restclient.models.RunDto |
Exceptions
Type | Description |
---|---|
get_docs_url
Url to the documentation for this class.
get_docs_url()
Returns
Type | Description |
---|---|
url |
Exceptions
Type | Description |
---|---|
get_status
Retrieve the current detailed status for the ComputeInstance.
get_status()
Returns
Type | Description |
---|---|
A detailed status object for the compute |
Exceptions
Type | Description |
---|---|
provisioning_configuration
Create a configuration object for provisioning a ComputeInstance target.
static provisioning_configuration(vm_size='', ssh_public_access=False, admin_user_ssh_public_key=None, vnet_resourcegroup_name=None, vnet_name=None, subnet_name=None, tags=None, description=None, assigned_user_object_id=None, assigned_user_tenant_id=None)
Parameters
Name | Description |
---|---|
vm_size
Required
|
The size of agent VMs. More details can be found here: https://aka.ms/azureml-vm-details. Note that not all sizes are available in all regions, as detailed in the previous link. Defaults to Standard_NC6. |
ssh_public_access
|
Indicates the state of the public SSH port. Possible values are:
Default value: False
|
admin_user_ssh_public_key
|
The SSH public key of the administrator user account. Default value: None
|
vnet_resourcegroup_name
|
The name of the resource group where the virtual network is located. Default value: None
|
vnet_name
|
The name of the virtual network. Default value: None
|
subnet_name
|
The name of the subnet inside the vnet. Default value: None
|
tags
|
An optional dictionary of key value tags to associate with the compute object. Default value: None
|
description
|
An optional description for the compute object. Default value: None
|
assigned_user_object_id
|
The AAD Object ID of the assigned user (preview). Default value: None
|
assigned_user_tenant_id
|
The AAD Tenant ID of the assigned user (preview). Default value: None
|
Returns
Type | Description |
---|---|
A configuration object to be used when creating a Compute object. |
Exceptions
Type | Description |
---|---|
refresh_state
Perform an in-place update of the properties of the object.
This method updates the properties based on the current state of the corresponding cloud object. This is primarily useful for manual polling of compute state.
refresh_state()
Exceptions
Type | Description |
---|---|
restart
Restart the ComputeInstance.
restart(wait_for_completion=False, show_output=False)
Parameters
Name | Description |
---|---|
wait_for_completion
|
Boolean to wait for the state update. Defaults to False. Default value: False
|
show_output
|
Boolean to provide more verbose output. Defaults to False. Default value: False
|
Returns
Type | Description |
---|---|
None |
Exceptions
Type | Description |
---|---|
azureml.exceptions.ComputeTargetException:
|
serialize
Convert this ComputeInstance object into a JSON serialized dictionary.
serialize()
Returns
Type | Description |
---|---|
The JSON representation of this ComputeInstance object. |
Exceptions
Type | Description |
---|---|
start
Start the ComputeInstance.
start(wait_for_completion=False, show_output=False)
Parameters
Name | Description |
---|---|
wait_for_completion
|
Whether to wait for the state update. Defaults to False. Default value: False
|
show_output
|
Whether to provide more verbose output. Defaults to False. Default value: False
|
Returns
Type | Description |
---|---|
None |
Exceptions
Type | Description |
---|---|
stop
Stop the ComputeInstance.
stop(wait_for_completion=False, show_output=False)
Parameters
Name | Description |
---|---|
wait_for_completion
|
Whether to wait for the state update. Defaults to False. Default value: False
|
show_output
|
Whether to provide more verbose output. Defaults to False. Default value: False
|
Returns
Type | Description |
---|---|
None |
Exceptions
Type | Description |
---|---|
supported_vmsizes
List the supported VM sizes in a region.
static supported_vmsizes(workspace, location=None)
Parameters
Name | Description |
---|---|
workspace
Required
|
The workspace. |
location
|
The location of the instance. If not specified, the default is the workspace location. Default value: None
|
Returns
Type | Description |
---|---|
A list of supported VM sizes in a region with name of the VM, VCPUs, and RAM. |
Exceptions
Type | Description |
---|---|
update_sso_settings
Update single sign-on settings of the compute instance.
update_sso_settings(value)
Parameters
Name | Description |
---|---|
value
Required
|
The value of sso settings |
Returns
Type | Description |
---|---|
Whether the update was successful or not |
Exceptions
Type | Description |
---|---|
wait_for_completion
Wait for the ComputeInstance to finish provisioning.
wait_for_completion(show_output=False, is_delete_operation=False)
Parameters
Name | Description |
---|---|
show_output
|
Whether to provide more verbose output. Defaults to False. Default value: False
|
is_delete_operation
|
Indicates whether the operation is meant for deleting. Default value: False
|
Exceptions
Type | Description |
---|---|