AppApi¶
- class AppApi(api)[source]¶
Bases:
TaskApiAPI for launching and managing Supervisely Apps (built on top of
TaskApi).Methods
Convert information about an entity to a dictionary.
create_task_detached
deploy_model
download_git_archive
Download a file from app repository.
download_import_file
find_module_id_by_app_nameGet context information by Application Task ID.
Returns ecosystem module id by slug.
Returns ModuleInfo object by module id and version.
get_field
get_fields
get_import_files_list
get_info
Get application info by numeric ID.
Get list of applications for the specified team.
Get list of all or limited quantity entities from the Supervisely server.
This generator function retrieves a list of all or a limited quantity of entities from the Supervisely server, yielding batches of entities as they are retrieved
get_list_ecosystem_modulesGet the list of items for a given page number.
Yields list of images in dataset asynchronously page by page.
Returns the log entries for the given task ID in JSON format.
Get session token for the app with specified slug.
Get list of sessions (tasks) for the specified team and module.
get_statusget_training_metrics
get_url
Sequence of fields that are returned by the API to represent AppInfo.
Name of the tuple that represents AppInfo.
initialize
Check if the task is ready.
Checks if app is ready for API calls.
Check if the task is running.
Raise error if Application Task status is ERROR.
run_dtl
run_inference
run_train
send_request
set_field
set_fields
set_fields_from_dict
set_output_archive
set_output_directory
Set custom error message to the task output.
Sets output for the task with experiment info.
set_output_file_download
set_output_project
set_output_report
Set custom text message to the task output.
Start a new application session (task).
stop
submit_logs
Update given task metadata :param id: int - task id :param data: dict - meta data to update
Sets the specified status for the task.
upload_files
wait
Waits until app is ready for API calls.
Attributes
MAX_WAIT_ATTEMPTSMaximum number of attempts that will be made to wait for a certain condition to be met.
WAIT_ATTEMPT_TIMEOUT_SECNumber of seconds for intervals between attempts.
- InfoType¶
alias of
AppInfo
- class PluginTaskType(*values)¶
Bases:
StrEnumTask type for plugin-based tasks (train/inference/smarttool/etc.).
- classmethod values()¶
Get all values of the enum.
- class RestartPolicy(*values)¶
Bases:
StrEnumTask restart policy used for app deployments.
- classmethod values()¶
Get all values of the enum.
- class Status(*values)¶
Bases:
StrEnumTask lifecycle status values returned by the API.
- classmethod values()¶
Get all values of the enum.
-
CONSUMED =
'consumed'¶ Application is consumed by an agent
-
DEPLOYED =
'deployed'¶ Only for Plugins
-
ERROR =
'error'¶ Application has finished with an error
-
FINISHED =
'finished'¶ Application has finished successfully
-
QUEUED =
'queued'¶ Application is queued for execution
-
STARTED =
'started'¶ Application has been started
-
STOPPED =
'stopped'¶ Application has been stopped
-
TERMINATING =
'terminating'¶ Application is being terminated
- class Workflow(api)[source]¶
Bases:
objectWorkflow functionality for connecting project states and task application sessions.
-
add_input_dataset(dataset, task_id=
None, meta=None)[source]¶ Add input type “dataset” to the workflow node. This type is used to show that the application has used the specified dataset. Customization of the dataset node is not supported and will be ignored. You can only customize the main node with this method.
-
add_input_file(file, model_weight=
False, task_id=None, meta=None)[source]¶ Add input type “file” to the workflow node. This type is used to show that the application has used the specified file.
- Parameters:
- Returns:
Response from the API.
- Return type:
-
add_input_folder(path, task_id=
None, meta=None)[source]¶ Add input type “folder” to the workflow node. Path to the folder is a path in Team Files. This type is used to show that the application has used files from the specified folder.
-
add_input_job(id, task_id=
None, meta=None)[source]¶ Add input type “job” to the workflow node. Job is a Labeling Job. This type indicates that the application has utilized a labeling job during its operation.
-
add_input_project(project=
None, version_id=None, version_num=None, task_id=None, meta=None)[source]¶ Add input type “project” to the workflow node. The project version can be specified to indicate that the project version was used especially for this task. Arguments project and version_id are mutually exclusive. If both are specified, version_id will be used. Argument version_num can only be used in conjunction with the project. This type is used to show that the application has used the specified project. Customization of the project node is not supported and will be ignored. You can only customize the main node with this method.
- Parameters:
- project=
None¶ Project ID or ProjectInfo object.
- version_id : Optional[int]¶
Version ID of the project.
- version_num : Optional[int]¶
Version number of the project. This argument can only be used in conjunction with the project.
- task_id : Optional[int]¶
Task ID. If not specified, the task ID will be determined automatically.
- meta=
None¶ Additional data for node customization.
- project=
- Returns:
Response from the API.
- Return type:
-
add_input_task(input_task_id, task_id=
None, meta=None)[source]¶ Add input type “task” to the workflow node. This type usually indicates that the one application has used another application for its work.
-
add_output_app(task_id=
None, meta=None)[source]¶ Add output type “app_session” to the workflow node. This type is used to show that the application has an offline session in which you can find the result of its work.
-
add_output_dataset(dataset, task_id=
None, meta=None)[source]¶ Add output type “dataset” to the workflow node. This type is used to show that the application has created a dataset with the result of its work. Customization of the dataset node is not supported and will be ignored. You can only customize the main node with this method.
-
add_output_file(file, model_weight=
False, task_id=None, meta=None)[source]¶ Add output type “file” to the workflow node. This type is used to show that the application has created a file with the result of its work.
- Parameters:
- Returns:
Response from the API.
- Return type:
-
add_output_folder(path, task_id=
None, meta=None)[source]¶ Add output type “folder” to the workflow node. Path to the folder is a path in Team Files. This type is used to show that the application has created a folder with the result files of its work.
-
add_output_job(id, task_id=
None, meta=None)[source]¶ Add output type “job” to the workflow node. Job is a Labeling Job. This type is used to show that the application has created a labeling job with the result of its work.
-
add_output_project(project, version_id=
None, task_id=None, meta=None)[source]¶ Add output type “project” to the workflow node. The project version can be specified with “version” argument to indicate that the project version was created especially as result of this task. This type is used to show that the application has created a project with the result of its work. Customization of the project node is not supported and will be ignored. You can only customize the main node with this method.
- Parameters:
- Returns:
Response from the API.
- Return type:
-
add_output_task(output_task_id, task_id=
None, meta=None)[source]¶ Add output type “task” to the workflow node. This type is used to show that the application has created a task with the result of its work.
- check_instance_compatibility()[source]¶
Decorator to check instance compatibility with workflow features. If the instance is not compatible, the function will not be executed.
- Parameters:
- min_instance_version : Optional[str]
Determine the minimum instance version that accepts the workflow method. If not specified, the minimum version will be “6.9.31”.
-
add_input_dataset(dataset, task_id=
- static info_sequence()[source]¶
Sequence of fields that are returned by the API to represent AppInfo.
-
create_task_detached(workspace_id, task_type=
None)[source]¶
-
download_git_archive(ecosystem_item_id, app_id, version, save_path, log_progress=
True, ext_logger=None)[source]¶
-
download_git_file(module_id, save_path, app_id=
None, version=None, file_path=None, file_key=None, log_progress=True, ext_logger=None)[source]¶ Download a file from app repository. File should be added in the app config under
fileskey.- Parameters:
- module_id : int¶
ID of the module
- save_path : str¶
Path to save the file
- app_id : int¶
ID of the app
- version : str¶
Version of the app
- file_path : str¶
Path to the file in the app github repository
- file_key : str¶
Key of the file in the app github repository
- log_progress : bool¶
If True, will log the progress of the download
- ext_logger : Logger¶
Logger to use for logging
- Returns:
None
- Return type:
None
- get_context(id)¶
Get context information by Application Task ID.
- Parameters:
- Returns:
Context information in dict format
- Return type:
- Usage Example:
import os from dotenv import load_dotenv import supervisely as sly # Load secrets and create API object from .env file (recommended) # Learn more here: https://developer.supervisely.com/getting-started/basics-of-authentication if sly.is_development(): load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api.from_env() task_id = 121230 context = api.task.get_context(task_id) print(context) # Output: { # "team": { # "id": 16087, # "name": "alexxx" # }, # "workspace": { # "id": 23821, # "name": "my_super_workspace" # } # }
- get_ecosystem_module_id(slug)[source]¶
Returns ecosystem module id by slug. E.g. slug = “supervisely-ecosystem/export-to-supervisely-format”. Slug can be obtained from the application URL in browser.
- Parameters:
- Returns:
ID of the module
- Return type:
- Raises:
- Usage Example:
import os from dotenv import load_dotenv import supervisely as sly # Load secrets and create API object from .env file (recommended) # Learn more here: https://developer.supervisely.com/getting-started/basics-of-authentication load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api.from_env() slug = "supervisely-ecosystem/export-to-supervisely-format" module_id = api.app.get_ecosystem_module_id(slug) print(f"Module {slug} has id {module_id}") # Module supervisely-ecosystem/export-to-supervisely-format has id 81
-
get_ecosystem_module_info(module_id=
None, version=None, slug=None)[source]¶ Returns ModuleInfo object by module id and version.
- Parameters:
- Raises:
ValueError – if both module_id and slug are None
ValueError – if both module_id and slug are provided
- Returns:
ModuleInfo object
- Return type:
ModuleInfo- Usage Example:
import os from dotenv import load_dotenv import supervisely as sly # Load secrets and create API object from .env file (recommended) # Learn more here: https://developer.supervisely.com/getting-started/basics-of-authentication load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api.from_env() module_id = 81 module_info = api.app.get_ecosystem_module_info(module_id)
-
get_list(team_id, filter=
None, context=None, repository_key=None, show_disabled=False, integrated_into=None, session_tags=None, only_running=False, with_shared=True, force_all_sessions=True)[source]¶ Get list of applications for the specified team.
- Parameters:
- team_id : int¶
Team ID.
- filter : Optional[List[dict]]¶
List of filters.
- context : Optional[List[str]]¶
List of application contexts.
- repository_key : Optional[str]¶
Repository key.
- show_disabled : bool¶
Show disabled applications.
- integrated_into : Optional[List[str]]¶
Destination(s) of the application. Available values:
panelfilesstandalonedata_commanderimage_annotation_toolvideo_annotation_tooldicom_annotation_toolpointcloud_annotation_tool
list of session tags
- only_running : bool¶
show only running applications (status is one of “queued”/”consumed”/”started”/”deployed”)
include shared applications
- force_all_sessions : bool¶
force to get all sessions (tasks) for each application. Works only if only_running is False. Note that it can be a long operation.
- Returns:
list of applications
- Return type:
List[
AppInfo]- Usage Example:
import os from dotenv import load_dotenv import supervisely as sly # Load secrets and create API object from .env file (recommended) # Learn more here: https://developer.supervisely.com/getting-started/basics-of-authentication if sly.is_development(): load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api.from_env() team_id = 447 # Get list of all applications (including all tasks in `tasks` field) apps = api.app.get_list(team_id=team_id) # Get list of all applications (only running tasks included in `tasks` field) apps = api.app.get_list(team_id=team_id, force_all_sessions=False) # Get list of only running applications apps = api.app.get_list(team_id=team_id, only_running=True) # Get list of applications with specific filters filter = [{"field": "moduleId", "operator": "=", "value": 428}] apps = api.app.get_list(team_id=team_id, filter=filter)
-
get_list_all_pages(method, data, progress_cb=
None, convert_json_info_cb=None, limit=None, return_first_response=False)¶ Get list of all or limited quantity entities from the Supervisely server.
- Parameters:
- method : str¶
Request method name
- data : dict¶
Dictionary with request body info
- progress_cb : Progress, optional¶
Function for tracking download progress.
- convert_json_info_cb : Callable, optional¶
Function for convert json info
- limit : int, optional¶
Number of entity to retrieve
- return_first_response : bool, optional¶
Specify if return first response
- Returns:
List of entities.
- Return type:
List[dict]
-
get_list_all_pages_generator(method, data, progress_cb=
None, convert_json_info_cb=None, limit=None, return_first_response=False)¶ This generator function retrieves a list of all or a limited quantity of entities from the Supervisely server, yielding batches of entities as they are retrieved
- Parameters:
- method : str¶
Request method name
- data : dict¶
Dictionary with request body info
- progress_cb : Progress, optional¶
Function for tracking download progress.
- convert_json_info_cb : Callable, optional¶
Function for convert json info
- limit : int, optional¶
Number of entity to retrieve
- return_first_response : bool, optional¶
Specify if return first response
- async get_list_idx_page_async(method, data)¶
Get the list of items for a given page number. Page number is specified in the data dictionary.
-
async get_list_page_generator_async(method, data, pages_count=
None, semaphore=None)¶ Yields list of images in dataset asynchronously page by page.
- Parameters:
- method : str¶
Method to call for listing items.
- data : dict¶
Data to pass to the API method.
- pages_count : int, optional¶
Preferred number of pages to retrieve if used with a
per_pagelimit. Will be automatically adjusted if thepagesCountdiffers from the requested number.- semaphore=
None¶ Semaphore for limiting the number of simultaneous requests.
- Returns:
List of images in dataset.
- Return type:
AsyncGenerator[List[
ImageInfo]]- Usage Example:
import os from dotenv import load_dotenv import supervisely as sly # Load secrets and create API object from .env file (recommended) # Learn more here: https://developer.supervisely.com/getting-started/basics-of-authentication if sly.is_development(): load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api.from_env() method = 'images.list' data = {'datasetId': 123456} loop = sly.utils.get_or_create_event_loop() images = loop.run_until_complete(api.image.get_list_generator_async(method, data))
-
get_logs(task_id, since_time=
None, limit=None)¶ Returns the log entries for the given task ID in JSON format.
- Parameters:
- Returns:
List of log entries in JSON format.
- Return type:
List[Dict]
- Usage Example:
since_time = "2026-03-30T14:28:58.816Z" limit = 100 task_id = 12345 logs = api.task.get_logs(task_id, since_time=since_time, limit=limit) for log_entry in logs: print(log_entry) # {'level': 'info', 'message': "Added object class... 'timestamp': '2026-03-30T14:28:56.525Z', 'task_id': 58595}
-
get_sessions(team_id, module_id, show_disabled=
False, session_name=None, statuses=None, with_shared=False)[source]¶ Get list of sessions (tasks) for the specified team and module.
- Parameters:
- Returns:
List of sessions
- Return type:
List[
SessionInfo]- Usage Example:
import os from dotenv import load_dotenv import supervisely as sly # Load secrets and create API object from .env file (recommended) # Learn more here: https://developer.supervisely.com/getting-started/basics-of-authentication if sly.is_development(): load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api.from_env() team_id = 447 module_id = 428 # Get list of all sessions for the specified team and module ID sessions = api.app.get_sessions(team_id, module_id) # Get list of sessions with specific statuses from supervisely.api.task_api import TaskApi statuses = [TaskApi.Status.STARTED] sessions = api.app.get_sessions(team_id, module_id, statuses=statuses)
- is_ready_for_api_calls(task_id)[source]¶
Checks if app is ready for API calls. :param task_id: ID of the running task. :type task_id: int :returns: True if app is ready for API calls, False otherwise.
-
run_dtl(workspace_id, dtl_graph, agent_id=
None)[source]¶
-
run_inference(agent_id, input_project_id, input_model_id, result_project_name, inference_config=
None)[source]¶
-
run_train(agent_id, input_project_id, input_model_id, result_nn_name, train_config=
None)[source]¶
-
send_request(task_id, method, data, context=
{}, skip_response=False, timeout=60, outside_request=True, retries=10, raise_error=False)¶
- set_output_directory(task_id, file_id, directory_path)¶
-
set_output_error(task_id, title, description=
None, show_logs=True)¶ Set custom error message to the task output.
- Parameters:
- Returns:
Response JSON.
- Return type:
Dict
- Usage Example:
import os from dotenv import load_dotenv import supervisely as sly # Load secrets and create API object from .env file (recommended) # Learn more here: https://developer.supervisely.com/getting-started/basics-of-authentication if sly.is_development(): load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api.from_env() task_id = 12345 title = "Something went wrong" description = "Please check the task logs" show_logs = True api.task.set_output_error(task_id, title, description, show_logs)
- set_output_experiment(task_id, experiment_info)¶
Sets output for the task with experiment info.
- Parameters:
- Returns:
Server response JSON.
- Return type:
- Usage Example:
experiment_info = { "experiment_name": "247 Lemons RT-DETRv2-M", "framework_name": "RT-DETRv2", "model_name": "RT-DETRv2-M", "task_type": "object detection", "project_id": 76, "project_version": {"id": 222, "version": 4}, "task_id": 247, "model_files": {"config": "model_config.yml"}, "checkpoints": [ "checkpoints/best.pth", "checkpoints/checkpoint0025.pth", "checkpoints/checkpoint0050.pth", "checkpoints/last.pth", ], "best_checkpoint": "best.pth", "export": {"ONNXRuntime": "export/best.onnx"}, "app_state": "app_state.json", "model_meta": "model_meta.json", "train_val_split": "train_val_split.json", "train_size": 4, "val_size": 2, "train_collection_id": 530, "val_collection_id": 531, "hyperparameters": "hyperparameters.yaml", "artifacts_dir": "/experiments/76_Lemons/247_RT-DETRv2/", "datetime": "2025-01-22 18:13:43", "evaluation_report_id": 12961, "evaluation_report_link": "https://app.supervisely.com/model-benchmark?id=12961", "evaluation_metrics": {"mAP": 0.994, "AP50": 1.0, "AP75": 1.0}, # and other metrics "primary_metric": "mAP", "logs": {"type": "tensorboard", "link": "/experiments/76_Lemons/247_RT-DETRv2/logs/"}, }
-
set_output_project(task_id, project_id, project_name=
None, project_preview=None)¶
-
set_output_report(task_id, file_id, file_name, description=
'Report')¶
-
set_output_text(task_id, title, description=
None, show_logs=False, zmdi_icon='zmdi-comment-alt-text', icon_color='#33c94c', background_color='#d9f7e4')¶ Set custom text message to the task output.
- Parameters:
- task_id : int¶
Application task ID.
- title : str¶
Text message to be displayed in the task output.
- description : Optional[str]¶
Description to be displayed in the task output.
- show_logs : Optional[bool], default False¶
If True, the link to the task logs will be displayed in the task output.
- zmdi_icon : Optional[str], default "zmdi-comment-alt-text"¶
Icon class name from Material Design Icons set (ZMDI).
- icon_color : Optional[str], default "#33c94c" (nearest Duron Jolly Green)¶
Icon color in HEX format.
- background_color : Optional[str], default "#d9f7e4" (Cosmic Latte)¶
Background color in HEX format.
- Returns:
Response JSON.
- Return type:
Dict
- Usage Example:
import os from dotenv import load_dotenv import supervisely as sly # Load secrets and create API object from .env file (recommended) # Learn more here: https://developer.supervisely.com/getting-started/basics-of-authentication if sly.is_development(): load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api.from_env() task_id = 12345 title = "Task is finished" api.task.set_output_text(task_id, title)
-
start(agent_id, app_id=
None, workspace_id=None, description='', params=None, log_level='info', users_id=None, app_version=None, is_branch=False, task_name='run-from-python', restart_policy='never', proxy_keep_url=False, module_id=None, redirect_requests={}, kubernetes_settings=None, multi_user_session=False)[source]¶ Start a new application session (task).
- Parameters:
- agent_id : int¶
ID of the agent to run the task on. If set None - the task will be run on the any available agent.
- app_id : Optional[int]¶
Deprecated. Use
module_idinstead.- workspace_id : Optional[int]¶
ID of the workspace to run the task in. If not specified, the default workspace will be used.
- description : str¶
Task description which will be shown in UI.
- params : Optional[dict]¶
Task parameters which will be passed to the application.
- log_level : Literal["info", "debug", "warning", "error"]¶
Log level for the task. Default is “info”.
- users_id : Optional[int]¶
User ID for which will be created an instance of the application.
- app_version : Optional[str]¶
Application version e.g. “v1.0.0” or branch name e.g. “dev”.
- is_branch : bool¶
If the application version is a branch name, set this parameter to True.
- task_name : str¶
Task name which will be shown in UI. Default is “run-from-python”.
- restart_policy : str¶
When the app should be restarted: never or if error occurred.
- proxy_keep_url : bool¶
For internal usage only.
- module_id : Optional[int]¶
Module ID. Can be obtained from the apps page in UI.
- redirect_requests : dict¶
For internal usage only in Develop and Debug mode.
- kubernetes_settings=
None¶ Kubernetes settings for the task. If not specified, default settings will be used.
- multi_user_session : bool, default is False¶
If True, the application session will be created as multi-user. In this case, multiple users will be able to connect to the same application session. All users will have separate application states. Available only for applications that support multi-user sessions.
- Returns:
SessionInfo object with information about the started task.
- Return type:
SessionInfo- Raises:
ValueError – If both app_id and module_id are not provided.
ValueError – If both app_id and module_id are provided.
-
update_meta(id, data, agent_storage_folder=
None, relative_app_dir=None)¶ Update given task metadata :param id: int - task id :param data: dict - meta data to update
- update_status(task_id, status)¶
Sets the specified status for the task.
- Parameters:
- Raises:
ValueError – If the status value is not allowed.
-
wait(id, target_status, attempts=
None, attempt_delay_sec=None)[source]¶
-
wait_until_ready_for_api_calls(task_id, attempts=
10, attempt_delay_sec=10)[source]¶ Waits until app is ready for API calls.