DeployApi

class DeployApi[source]

Bases: object

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_serving_app_by_slug

rtype

int

get_deploy_info

Get deploy info of a serving task.

get_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

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 Api.task.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 Api.task.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 : ExperimentInfo

an ExperimentInfo object.

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 Api.task.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 Api.task.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.

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]

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 : ExperimentInfo

an ExperimentInfo object.

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 Api.task.start() for more details.

Returns

Task Info

Return type

Dict[str, Any]