Workspace API¶
-
class
supervisely_lib.api.workspace_api.
WorkspaceApi
(api)[source]¶ Bases:
supervisely_lib.api.module_api.ModuleApi
,supervisely_lib.api.module_api.UpdateableModule
API for working with Workspace.
WorkspaceApi
object is immutable.- Parameters
api (Api) – API connection to the server.
- Usage example
# You can connect to API directly address = 'https://app.supervise.ly/' token = 'Your Supervisely API Token' api = sly.Api(address, token) # Or you can use API from environment os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly' os.environ['API_TOKEN'] = 'Your Supervisely API Token' api = sly.Api.from_env() workspace_info = api.worksapce.get_info_by_id(workspace_id) # api usage example
-
static
info_sequence
()[source]¶ NamedTuple WorkspaceInfo containing information about Workspace.
- Example
WorkspaceInfo(id=15, name='Cars', description='Workspace contains Project with annotated Cars', team_id=8, created_at='2020-04-15T10:50:41.926Z', updated_at='2020-04-15T10:50:41.926Z')
-
get_list
(team_id: int, filters: Optional[List[dict]] = None) → List[NamedTuple][source]¶ List of Workspaces in the given Team.
- Parameters
team_id (int) – Team ID in which the Workspaces are located.
filters (List[dict], optional) – List of params to sort output Workspaces.
- Returns
List of all Workspaces with information for the given Team. See
info_sequence
- Return type
List[NamedTuple]
- Usage example
os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly' os.environ['API_TOKEN'] = 'Your Supervisely API Token' api = sly.Api.from_env() workspace_infos = api.workspace.get_list(8) print(workspace_infos) # Output: [ # WorkspaceInfo(id=15, # name='Cars', # description='', # team_id=8, # created_at='2020-04-15T10:50:41.926Z', # updated_at='2020-04-15T10:50:41.926Z'), # WorkspaceInfo(id=18, # name='Heart', # description='', # team_id=8, # created_at='2020-05-20T15:01:54.172Z', # updated_at='2020-05-20T15:01:54.172Z'), # WorkspaceInfo(id=20, # name='PCD', # description='', # team_id=8, # created_at='2020-06-24T11:51:11.336Z', # updated_at='2020-06-24T11:51:11.336Z') # ] # Filtered Workspace list workspace_infos = api.workspace.get_list(8, filters=[{ 'field': 'name', 'operator': '=', 'value': 'Heart'}]) print(workspace_infos) # Output: [WorkspaceInfo(id=18, # name='Heart', # description='', # team_id=8, # created_at='2020-05-20T15:01:54.172Z', # updated_at='2020-05-20T15:01:54.172Z') # ]
-
get_info_by_id
(id: int) → NamedTuple[source]¶ Get Workspace information by ID.
- Parameters
id (int) – Workspace ID in Supervisely.
- Returns
Information about Workspace. See
info_sequence
- Return type
NamedTuple
- Usage example
os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly' os.environ['API_TOKEN'] = 'Your Supervisely API Token' api = sly.Api.from_env() workspace_info = api.workspace.get_info_by_id(58) print(workspace_info) # Output: WorkspaceInfo(id=58, # name='Test', # description='', # team_id=8, # created_at='2020-11-09T18:21:08.202Z', # updated_at='2020-11-09T18:21:08.202Z')
-
create
(team_id: int, name: str, description: str = '', change_name_if_conflict: bool = False) → NamedTuple[source]¶ Create Workspace with given name in the given Team.
- Parameters
team_id (int) – Team ID in Supervisely where Workspace will be created.
name (str) – Workspace Name.
description (str, optional) – Workspace description.
change_name_if_conflict (bool, optional) – Checks if given name already exists and adds suffix to the end of the name.
- Returns
Information about Workspace. See
info_sequence
- Return type
NamedTuple
- Usage example
os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly' os.environ['API_TOKEN'] = 'Your Supervisely API Token' api = sly.Api.from_env() new_workspace = api.workspace.create(8, "Vehicle Detection") print(new_workspace) # Output: WorkspaceInfo(id=274, # name='Vehicle Detection"', # description='', # team_id=8, # created_at='2021-03-11T12:24:21.773Z', # updated_at='2021-03-11T12:24:21.773Z')
-
InfoType
¶ alias of
supervisely_lib.api.module_api.WorkspaceInfo