Skip to content

Deploy#

lit.sdk.services.deploy #

This module defines the Deploy class, an abstract subclass of Service, which represents a deployment service. The class provides methods for managing deployment actions such as starting, stopping, restarting, and checking the status of the deploy. It also includes abstract methods for adding and removing models from the deploy.

Deploy #

Bases: Service

Represents a model deployment service worker.

name instance-attribute #

The name of the deploy.

team instance-attribute #

The name of the team that owns the deploy.

__init__(team, name) #

Initializes a new instance of Deploy.

Parameters:

Name Type Description Default
team str

The name of the team that owns the Deploy.

required
name str

The name of the Deploy.

required

add_model(model) #

Adds a vaulted model to the deploy.

Parameters:

Name Type Description Default
model str

The name of the model to add.

required

Returns:

Type Description
ServiceActionStatus

a dictionary containing status of operation.

Examples:

>>> deploy = Deploy("contoso", "my_deploy")
>>> deploy.add_model("my_model")
{'status': 'SUCCESS', 'message': 'model my_model added to deploy my_deploy.'}

remove_model(model) #

Removes a vaulted model from the deploy.

Parameters:

Name Type Description Default
model str

The name of the model to remove.

required

Returns:

Type Description
ServiceActionStatus

a dictionary containing status of operation.

Examples:

>>> deploy = Deploy("contoso", "my_deploy")
>>> deploy.remove_model("my_model")
{'status': 'SUCCESS', 'message': 'model my_model removed from deploy my_deploy.'}

restart() #

Restarts the deploy.

Returns:

Name Type Description
ServiceActionStatus ServiceActionStatus

A dictionary containing the status of the operation.

Raises:

Type Description
LitServiceError

If the deploy failed to restart.

Examples:

>>> deploy = SomeDeploySubclass("contoso", "deploy_name")
>>> deploy.restart()
{'status': 'SUCCESS', 'message': 'Deploy restarted successfully.'}

start() #

Starts the deploy.

Returns:

Name Type Description
ServiceActionStatus ServiceActionStatus

A dictionary containing the status of the operation.

Raises:

Type Description
LitServiceError

If the deploy failed to start.

Examples:

>>> deploy = SomeDeploySubclass("contoso", "deploy_name")
>>> deploy.start()
{'status': 'SUCCESS', 'message': 'Deploy started successfully.'}

status() #

Retrieves the status of the deploy.

Returns:

Name Type Description
ServiceStatus ServiceStatus

A dictionary containing the current status of the deploy.

Raises:

Type Description
LitServiceError

If the deploy failed to be queried.

Examples:

>>> deploy = SomeDeploySubclass("contoso", "deploy_name")
>>> deploy.status()
{'name': 'deploy_name', 'active': 'active', 'status': 'running', 'started': 'Wed 2024-07-24 13:32:23 CDT', 'pid': 3687984, 'tasks': 5, 'memory': '3.3G'}

stop() #

Stops the deploy.

Returns:

Name Type Description
ServiceActionStatus ServiceActionStatus

A dictionary containing the status of the operation.

Raises:

Type Description
LitServiceError

If the deploy failed to stop.

Examples:

>>> deploy = SomeDeploySubclass("contoso", "deploy_name")
>>> deploy.stop()
{'status': 'SUCCESS', 'message': 'Deploy stopped successfully.'}

get_deployments(team) #

Gets a list of the available deployments.

Parameters:

Name Type Description Default
team str

The name of the team.

required

Returns:

Type Description
list[Deploy]

List of available deployments.

Examples:

>>> get_deploys("contoso")
[Deploy(team='contoso', name='test')]