DeployApi

class DeployApi(api)[source]

Bases: object

API for deploying models and controlling serving apps.

This class is used internally by NeuralNetworkApi, but it can also be used directly for advanced deployment workflows.

Key capabilities:

  • deploy a pretrained model into a new serving task,

  • deploy a custom checkpoint (from team files or experiment artifacts),

  • load/replace model inside an existing serving task.

Parameters:
api

Api object to use for API connection.

Methods

deploy_custom_model_by_artifacts_dir

Deploy a custom model based on the artifacts directory.

deploy_custom_model_by_checkpoint

Deploy a custom model based on the checkpoint path.

deploy_custom_model_from_experiment_info

Deploy a custom model based on the training session.

deploy_pretrained_model

Deploy a pretrained model.

find_serving_app_by_framework

Find the serving app by framework.

find_serving_app_by_slug

Find the serving app by slug.

get_deploy_info

Get deploy info of a serving task.

get_serving_app_by_train_app

Get the serving app by train app.

load_custom_model

Load a custom model in running serving App.

load_custom_model_from_experiment_info

Load a custom model in running serving App based on the training session.

load_pretrained_model

Load a pretrained model in running serving App.

start_serve_app

Run a serving app.

wait

Wait for the model to be started or deployed.

deploy_custom_model_by_artifacts_dir(artifacts_dir, checkpoint_name=None, device=None, runtime=None, timeout=100, team_id=None, workspace_id=None, agent_id=None, **kwargs)[source]

Deploy a custom model based on the artifacts directory.

Parameters:
artifacts_dir : str

Path to the artifacts directory in the team fies.

checkpoint_name : Optional[str]

Checkpoint name (with file extension) to deploy, e.g. “best.pt”. If not provided, checkpoint will be chosen automatically, depending on the app version.

device : Optional[str]

Device string. If not provided, will be chosen automatically.

runtime : Optional[str]

Runtime string, if not present will be defined automatically.

timeout : Optional[int]

Timeout in seconds (default is 100). The maximum time to wait for the serving app to be ready.

team_id : Optional[int]

Team ID where the artifacts are stored. If not provided, will be taken from the current context.

workspace_id : Optional[int]

Workspace ID where the app will be deployed. If not provided, will be taken from the current context.

agent_id : Optional[int]

Agent ID. If not provided, will be found automatically.

kwargs : Dict[str, Any]

Additional parameters to start the task. See start() for more details.

Returns:

Task Info

Return type:

Dict[str, Any]

Raises:

ValueError – if validations fail.

deploy_custom_model_by_checkpoint(checkpoint, device=None, runtime=None, timeout=100, team_id=None, workspace_id=None, agent_id=None, **kwargs)[source]

Deploy a custom model based on the checkpoint path.

Parameters:
checkpoint : str

Path to the checkpoint in Team Files.

device : Optional[str]

Device string. If not provided, will be chosen automatically.

runtime : Optional[str]

Runtime string, if not present will be defined automatically.

timeout : Optional[int]

Timeout in seconds (default is 100). The maximum time to wait for the serving app to be ready.

team_id : Optional[int]

Team ID where the artifacts are stored. If not provided, will be taken from the current context.

workspace_id : Optional[int]

Workspace ID where the app will be deployed. If not provided, will be taken from the current context.

agent_id : Optional[int]

Agent ID. If not provided, will be found automatically.

kwargs : Dict[str, Any]

Additional parameters to start the task. See start() for more details.

Returns:

Task Info

Return type:

Dict[str, Any]

Raises:

ValueError – if validations fail.

deploy_custom_model_from_experiment_info(agent_id, experiment_info, checkpoint_name=None, device=None, runtime=None, timeout=100, **kwargs)[source]

Deploy a custom model based on the training session.

Parameters:
experiment_info

Experiment info from TrainApp.

checkpoint_name : Optional[str]

Checkpoint name (with file extension) to deploy, e.g. “best.pt”. If not provided, the best checkpoint will be chosen.

device : Optional[str]

Device string. If not provided, will be chosen automatically.

timeout : Optional[int]

Timeout in seconds (default is 100). The maximum time to wait for the serving app to be ready.

kwargs : Dict[str, Any]

Additional parameters to start the task. See start() for more details.

Returns:

Task Info

Return type:

Dict[str, Any]

Raises:

ValueError – if validations fail.

deploy_pretrained_model(framework, model_name, device=None, runtime=None, workspace_id=None, agent_id=None, app=None, **kwargs)[source]

Deploy a pretrained model.

Parameters:
framework : Union[str, int]

Framework name or Framework ID in Supervisely.

model_name : str

Model name to deploy.

device : Optional[str]

Device string. If not provided, will be chosen automatically.

runtime : Optional[str]

Runtime string, if not present will be defined automatically.

workspace_id : Optional[int]

Workspace ID where the app will be deployed. If not provided, will be taken from the current context.

agent_id : Optional[int]

Agent ID. If not provided, will be found automatically.

app : Union[str, int]

App name or App module ID in Supervisely.

kwargs : Dict[str, Any]

Additional parameters to start the task. See start() for more details.

Returns:

Task Info

Return type:

Dict[str, Any]

Raises:

ValueError – if no serving apps found for the app name or multiple serving apps found for the app name.

find_serving_app_by_framework(framework)[source]

Find the serving app by framework.

Parameters:
framework : str

Framework name.

Returns:

Serving app info

Return type:

Dict[str, Any]

find_serving_app_by_slug(slug)[source]

Find the serving app by slug.

Parameters:
slug : str

Slug of the serving app.

Returns:

Serving app ID

Return type:

int

get_deploy_info(task_id)[source]

Get deploy info of a serving task.

Parameters:
task_id : int

Task ID of the serving App.

Returns:

Deploy Info

Return type:

Dict[str, Any]

get_serving_app_by_train_app(app_name=None, module_id=None)[source]

Get the serving app by train app.

Parameters:
app_name : Optional[str]

App name in Supervisely.

module_id : int

Module ID in Supervisely.

Returns:

Serving app info

Return type:

Dict[str, Any]

load_custom_model(session_id, team_id, artifacts_dir, checkpoint_name=None, device=None, runtime=None)[source]

Load a custom model in running serving App.

Parameters:
session_id : int

Task ID of the serving App.

team_id : int

Team ID in Supervisely.

artifacts_dir : str

Path to the artifacts directory in the team fies.

checkpoint_name : Optional[str]

Checkpoint name (with file extension) to deploy, e.g. “best.pt”. If not provided, checkpoint will be chosen automatically, depending on the app version.

device : Optional[str]

Device string. If not provided, will be chosen automatically.

runtime : Optional[str]

Runtime string, if not present will be defined automatically.

load_custom_model_from_experiment_info(session_id, experiment_info, checkpoint_name=None, device=None, runtime=None)[source]

Load a custom model in running serving App based on the training session.

Parameters:
session_id : int

Task ID of the serving App.

experiment_info

Experiment info from TrainApp.

checkpoint_name : Optional[str]

Checkpoint name (with file extension) to deploy, e.g. “best.pt”. If not provided, checkpoint will be chosen automatically, depending on the app version.

device : Optional[str]

Device string. If not provided, will be chosen automatically.

runtime : Optional[str]

Runtime string, if not present will be defined automatically.

load_pretrained_model(session_id, model_name, device=None, runtime=None)[source]

Load a pretrained model in running serving App.

Parameters:
session_id : int

Task ID of the serving App.

model_name : str

Model name to deploy.

device : Optional[str]

Device string. If not provided, will be chosen automatically.

runtime : Optional[str]

Runtime string, if not present will be defined automatically.

start_serve_app(agent_id, app_name=None, module_id=None, **kwargs)[source]

Run a serving app. Either app_name or module_id must be provided.

Parameters:
app_name : Optional[str]

App name in Supervisely.

module_id : Optional[int]

Module ID in Supervisely.

kwargs : Dict[str, Any]

Additional parameters to start the task. See start() for more details.

Returns:

Task Info

Return type:

Dict[str, Any]

wait(model_id, target='started', timeout=300)[source]

Wait for the model to be started or deployed.

Parameters:
model_id : int

Model ID.

target : Literal["started", "deployed"]

Target status.

timeout : int

Timeout in seconds.