LabelingQueueApi

class LabelingQueueApi[source]

Bases: supervisely.api.module_api.RemoveableBulkModuleApi, supervisely.api.module_api.ModuleWithStatus

API for working with Labeling Queues. LabelingQueueApi object is immutable.

Parameters
api : Api

API connection to the server.

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()

# Pass values into the API constructor (optional, not recommended)
# api = sly.Api(server_address="https://app.supervisely.com", token="4r47N...xaTatb")

queue = api.labeling_queues.get_info_by_id(2) # api usage example

Methods

convert_info_to_json

_convert_info_to_json

create

Creates Labeling Queue and assigns given Users to it.

exists

Checks if an entity with the given parent_id and name exists

get_entities_all_pages

Get list of all or limited quantity entities from the Supervisely server.

get_entities_count_by_status

Get count of entities in the given Labeling Queue with given status. :type id: int :param id: Labeling Queue ID in Supervisely. :type id: int :type status: Union[List, Literal['none', 'done', 'accepted', 'null'], None] :param status: Status of entities to filter. "null" - pending (in queue). "none" - annotating (not in queue), "done" - on review, "accepted" - accepted, :type status: str or List[str], optional :type filter_by: Optional[List[Dict]] :param filter_by: Filter for entities. e.g. [{"field": "name", "operator": "in", "value": ["image_01", "image_02"]}] - field - field name to filter by ("id", "name", "reviewedAt") - operator - operator to use for filtering ("=", ">", "<", ">=", "<=") - value - value to filter by :type filter_by: List[Dict], optional :return: Count of entities in the Labeling Queue with given status. :rtype: int :Usage example:.

get_free_name

Generates a free name for an entity with the given parent_id and name.

get_info_by_id

Get Labeling Queue information by ID.

get_info_by_name

Get information about an entity by its name from the Supervisely server.

get_list

Get list of information about Labeling Queues in the given Team.

get_list_all_pages

Get list of all or limited quantity entities from the Supervisely server.

get_list_all_pages_generator

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_idx_page_async

Get the list of items for a given page number.

get_list_page_generator_async

Yields list of images in dataset asynchronously page by page.

get_project_meta

Returns project meta with classes and tags used in the labeling queue with given id.

get_status

Get status of Labeling Job with given ID.

info_sequence

NamedTuple LabelingQueueInfo information about Labeling Queue.

info_tuple_name

NamedTuple name - LabelingQueueInfo.

raise_for_status

remove

Remove an entity with the specified ID from the Supervisely server.

remove_batch

Remove entities in batches from the Supervisely server.

set_status

Sets Labeling Queue status.

Attributes

MAX_WAIT_ATTEMPTS

Maximum number of attempts that will be made to wait for a certain condition to be met.

WAIT_ATTEMPT_TIMEOUT_SEC

Number of seconds for intervals between attempts.

InfoType

alias of supervisely.api.module_api.LabelingQueueInfo

classmethod convert_info_to_json(info)

_convert_info_to_json

Return type

Dict

create(name, user_ids, reviewer_ids, dataset_id=None, collection_id=None, readme=None, classes_to_label=None, objects_limit_per_image=None, tags_to_label=None, tags_limit_per_image=None, include_images_with_tags=None, exclude_images_with_tags=None, images_range=None, reviewer_id=None, images_ids=None, dynamic_classes=False, dynamic_tags=False, disable_confirm=None, disable_submit=None, toolbox_settings=None, hide_figure_author=False, allow_review_own_annotations=False, skip_complete_job_on_empty=False, enable_quality_check=None, quality_check_user_ids=None)[source]

Creates Labeling Queue and assigns given Users to it.

Parameters
name : str

Labeling Queue name in Supervisely.

dataset_id : int

Dataset ID in Supervisely.

collection_id : int, optional

Entities Collection ID in Supervisely.

user_ids : List[int]

User IDs in Supervisely to assign Users as labelers to Labeling Queue.

reviewer_ids : List[int]

User IDs in Supervisely to assign Users as reviewers to Labeling Queue.

readme : str, optional

Additional information about Labeling Queue.

description : str, optional

Description of Labeling Queue.

classes_to_label : List[str], optional

List of classes to label in Dataset.

objects_limit_per_image : int, optional

Limit the number of objects that the labeler can create on each image.

tags_to_label : List[str], optional

List of tags to label in Dataset.

tags_limit_per_image : int, optional

Limit the number of tags that the labeler can create on each image.

include_images_with_tags : List[str], optional

Include images with given tags for processing by labeler.

exclude_images_with_tags : List[str], optional

Exclude images with given tags for processing by labeler.

images_range : List[int, int], optional

Limit number of images to be labeled for each labeler.

reviewer_id : int, optional

User ID in Supervisely to assign User as Reviewer to Labeling Queue.

images_ids : List[int], optional

List of images ids to label in dataset

dynamic_classes : bool, optional

If True, classes created after creating the queue will be available for annotators

dynamic_tags : bool, optional

If True, tags created after creating the queue will be available for annotators

disable_confirm : bool, optional

If True, the Confirm button will be disabled in the labeling tool. It will remain disabled until the next API call sets the parameter to False, re-enabling the button.

disable_submit : bool, optional

If True, the Submit button will be disabled in the labeling tool. It will remain disabled until the next API call sets the parameter to False, re-enabling the button.

toolbox_settings : Dict, optional

Settings for the labeling tool. Only video projects are supported.

hide_figure_author : bool, optional

If True, hides the author of the figure in the labeling tool.

allow_review_own_annotations : bool, optional

If True, allows labelers to review their own annotations.

skip_complete_job_on_empty : bool, optional

If True, skips completing the Labeling Queue if there are no images to label.

enable_quality_check : bool, optional

If True, adds an intermediate step between “review” and completing the Labeling Queue.

quality_check_user_ids : List[int], optional

List of User IDs in Supervisely to assign Users as Quality Checkers to Labeling Queue.

Returns

Labeling Queue ID in Supervisely.

Return type

int

Usage example
import supervisely as sly

os.environ['SERVER_ADDRESS'] = 'https://app.supervisely.com'
os.environ['API_TOKEN'] = 'Your Supervisely API Token'
api = sly.Api.from_env()

user_name = 'alex'
dataset_id = 602
new_labeling_queue_id = api.labeling_queue.create(
    user_name,
    dataset_id,
    user_ids=[111, 222],
    readme='Readmy text',
    description='Work for labelers',
    objects_limit_per_image=5,
    tags_limit_per_image=3
)
print(new_labeling_queue_id)

# >>> 2

# Create video labeling job with toolbox settings

user_id = 4
dataset_id = 277
video_id = 24897
toolbox_settings = {"playbackRate": 32, "skipFramesSize": 15, "showVideoTime": True}

new_labeling_queue_id = api.labeling_queue.create(
    name="Labeling Queue name",
    dataset_id=dataset_id,
    user_ids=[user_id],
    readme="Labeling Queue readme",
    description="Some description",
    classes_to_label=["car", "animal"],
    tags_to_label=["animal_age_group"],
    images_ids=[video_id],
    toolbox_settings=toolbox_settings,
)
print(new_labeling_queue_id)

# >>> 3
exists(parent_id, name)

Checks if an entity with the given parent_id and name exists

Parameters
parent_id : int

ID of the parent entity.

name : str

Name of the entity.

Returns

Returns True if entity exists, and False if not

Return type

bool

Usage example
import supervisely as sly

# You can connect to API directly
address = 'https://app.supervisely.com/'
token = 'Your Supervisely API Token'
api = sly.Api(address, token)

# Or you can use API from environment
os.environ['SERVER_ADDRESS'] = 'https://app.supervisely.com'
os.environ['API_TOKEN'] = 'Your Supervisely API Token'
api = sly.Api.from_env()


name = "IMG_0315.jpeg"
dataset_id = 55832
exists = api.image.exists(dataset_id, name)
print(exists) # True
get_entities_all_pages(id, collection_id=None, per_page=25, sort='name', sort_order='asc', status=None, limit=None, filter_by=None)[source]

Get list of all or limited quantity entities from the Supervisely server.

Parameters
id : int

Labeling Queue ID in Supervisely.

collection_id : int, optional

Collection ID in Supervisely.

per_page : int, optional

Number of entities per page.

sort : str, optional

Sorting field.

sort_order : str, optional

Sorting order.

status : str or List[str], optional

Status of entities to filter. “null” - pending (in queue). “none” - annotating (not in queue), “done” - on review, “accepted” - accepted,

limit : int, optional

Limit the number of entities to return. If limit is None, all entities will be returned.

filter_by : List[Dict], optional

Filter for entities. e.g. [{“field”: “name”, “operator”: “in”, “value”: [“image_01”, “image_02”]}]

  • field - field name to filter by (“id”, “name”, “reviewedAt”)

  • operator - operator to use for filtering (“=”, “>”, “<”, “>=”, “<=”)

  • value - value to filter by

return_first_response : bool, optional

Specify if return first response

Return type

Dict[str, Union[List[Dict], int]]

get_entities_count_by_status(id, status=None, filter_by=None)[source]

Get count of entities in the given Labeling Queue with given status. :type id: int :param id: Labeling Queue ID in Supervisely. :type id: int :type status: Union[List, Literal[‘none’, ‘done’, ‘accepted’, ‘null’], None] :param status: Status of entities to filter.

“null” - pending (in queue). “none” - annotating (not in queue), “done” - on review, “accepted” - accepted,

Parameters
filter_by : List[Dict], optional

Filter for entities. e.g. [{“field”: “name”, “operator”: “in”, “value”: [“image_01”, “image_02”]}]

  • field - field name to filter by (“id”, “name”, “reviewedAt”)

  • operator - operator to use for filtering (“=”, “>”, “<”, “>=”, “<=”)

  • value - value to filter by

Returns

Count of entities in the Labeling Queue with given status.

Return type

int

Usage example
import supervisely as sly

os.environ['SERVER_ADDRESS'] = 'https://app.supervisely.com'
os.environ['API_TOKEN'] = 'Your Supervisely API Token'
api = sly.Api.from_env()

entities_count = api.labeling_queue.get_entities_count_by_status(4, status="none")
print(entities_count)
# Output: 3
get_free_name(parent_id, name)

Generates a free name for an entity with the given parent_id and name. Adds an increasing suffix to original name until a unique name is found.

Parameters
parent_id : int

ID of the parent entity.

name : str

Name of the entity.

Returns

Returns free name.

Return type

str

Usage example
import supervisely as sly

# You can connect to API directly
address = 'https://app.supervisely.com/'
token = 'Your Supervisely API Token'
api = sly.Api(address, token)

# Or you can use API from environment
os.environ['SERVER_ADDRESS'] = 'https://app.supervisely.com'
os.environ['API_TOKEN'] = 'Your Supervisely API Token'
api = sly.Api.from_env()


name = "IMG_0315.jpeg"
dataset_id = 55832
free_name = api.image.get_free_name(dataset_id, name)
print(free_name) # IMG_0315_001.jpeg
get_info_by_id(id)[source]

Get Labeling Queue information by ID.

Parameters
id : int

Labeling Queue ID in Supervisely.

Returns

Information about Labeling Queue. See info_sequence

Return type

LabelingJobInfo

Usage example
import supervisely as sly

os.environ['SERVER_ADDRESS'] = 'https://app.supervisely.com'
os.environ['API_TOKEN'] = 'Your Supervisely API Token'
api = sly.Api.from_env()

label_job_info = api.labeling_queue.get_info_by_id(2)
print(label_job_info)
# Output: [
#     2,
#     "Annotation Queue (#1) (#1) (dataset_01)",
#     "",
#     "",
#     4,
#     8,
#     "First Workspace",
#     58,
#     "tutorial_project",
#     54,
#     "dataset_01",
#     4,
#     "anna",
#     4,
#     "anna",
#     4,
#     "anna",
#     "2020-04-08T15:10:12.618Z",
#     "2020-04-08T15:10:19.833Z",
#     "2020-04-08T15:13:39.788Z",
#     "completed",
#     false,
#     3,
#     0,
#     1,
#     2,
#     2,
#     [],
#     [],
#     [
#         1,
#         5
#     ],
#     null,
#     null,
#     [],
#     [],
#     [],
#     [
#         {
#             "reviewStatus": "rejected",
#             "id": 283,
#             "name": "image_03"
#         },
#         {
#             "reviewStatus": "accepted",
#             "id": 282,
#             "name": "image_02"
#         },
#         {
#             "reviewStatus": "accepted",
#             "id": 281,
#             "name": "image_01"
#         }
#     ]
# ]
get_info_by_name(parent_id, name, fields=[])

Get information about an entity by its name from the Supervisely server.

Parameters
parent_id : int

ID of the parent entity.

name : str

Name of the entity for which the information is being retrieved.

fields : List[str]

The list of api fields which will be returned with the response.

Usage example
import supervisely as sly

# You can connect to API directly
address = 'https://app.supervisely.com/'
token = 'Your Supervisely API Token'
api = sly.Api(address, token)

# Or you can use API from environment
os.environ['SERVER_ADDRESS'] = 'https://app.supervisely.com'
os.environ['API_TOKEN'] = 'Your Supervisely API Token'
api = sly.Api.from_env()


dataset_id = 55832
name = "IMG_0315.jpeg"
info = api.image.get_info_by_name(dataset_id, name)
print(info)
# Output: ImageInfo(id=19369643, name='IMG_0315.jpeg', ...)
get_list(team_id, dataset_id=None, project_id=None, ids=None, names=None, show_disabled=False)[source]

Get list of information about Labeling Queues in the given Team.

Parameters
team_id : int

Team ID in Supervisely.

dataset_id : int, optional

Dataset ID in Supervisely.

project_id : int, optional

Project ID in Supervisely.

ids : List[int], optional

List of Labeling Queue IDs in Supervisely.

names : List[str], optional

List of Labeling Queue names in Supervisely.

show_disabled : bool, optional

Show disabled Labeling Queues.

Returns

List of information about Labeling Queues. See info_sequence

Return type

List[LabelingQueueInfo]

Usage example
import supervisely as sly

os.environ['SERVER_ADDRESS'] = 'https://app.supervisely.com'
os.environ['API_TOKEN'] = 'Your Supervisely API Token'
api = sly.Api.from_env()

label_jobs = api.labeling_queue.get_list(4)
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

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.

Parameters
method : str

Method to call for listing items.

data : dict

Data to pass to the API method.

Returns

List of items.

Return type

Tuple[int, List[NamedTuple]]

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_page limit. Will be automatically adjusted if the pagesCount differs from the requested number.

semaphore : asyncio.Semaphore, optional

Semaphore for limiting the number of simultaneous requests.

kwargs

Additional arguments.

Returns

List of images in dataset.

Return type

AsyncGenerator[List[ImageInfo]]

Usage example
import supervisely as sly
import asyncio

os.environ['SERVER_ADDRESS'] = 'https://app.supervisely.com'
os.environ['API_TOKEN'] = 'Your Supervisely API Token'
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_project_meta(id)[source]

Returns project meta with classes and tags used in the labeling queue with given id.

Parameters
id : int

Labeling Queue ID in Supervisely.

Returns

Project meta of the labeling queue with given id.

Return type

ProjectMeta

get_status(id)[source]

Get status of Labeling Job with given ID.

Parameters
id : int

Labeling job ID in Supervisely.

Returns

Labeling Job Status

Return type

Status

Usage example
import supervisely as sly

os.environ['SERVER_ADDRESS'] = 'https://app.supervisely.com'
os.environ['API_TOKEN'] = 'Your Supervisely API Token'
api = sly.Api.from_env()

job_status = api.labeling_queue.get_status(4)
print(job_status) # pending
static info_sequence()[source]

NamedTuple LabelingQueueInfo information about Labeling Queue.

Example
LabelingQueueInfo(
    id=2,
    name='Annotation Queue (#1)',
    team_id=4,
    project_id=58,
    dataset_id=54,
    created_by_id=4,
    labelers=[4],
    reviewers=[4],
    created_at='2020-04-08T15:10:12.618Z',
    finished_at='2020-04-08T15:13:39.788Z',
    status='completed',
    jobs=[283, 282, 281],
    entities_count=3,
    accepted_count=2,
    annotated_count=3,
    in_progress_count=2,
    pending_count=1,
    meta={}
)
static info_tuple_name()[source]

NamedTuple name - LabelingQueueInfo.

raise_for_status(status)
remove(id)

Remove an entity with the specified ID from the Supervisely server.

Parameters
id : int

Entity ID in Supervisely.

Usage example
import supervisely as sly

# You can connect to API directly
address = 'https://app.supervisely.com/'
token = 'Your Supervisely API Token'
api = sly.Api(address, token)

# Or you can use API from environment
os.environ['SERVER_ADDRESS'] = 'https://app.supervisely.com'
os.environ['API_TOKEN'] = 'Your Supervisely API Token'
api = sly.Api.from_env()


image_id = 19369643
api.image.remove(image_id)
remove_batch(ids, progress_cb=None, batch_size=50)

Remove entities in batches from the Supervisely server. All entity IDs must belong to the same nesting (for example team, or workspace, or project, or dataset). Therefore, it is necessary to sort IDs before calling this method.

Parameters
ids : List[int]

IDs of entities in Supervisely.

progress_cb : Callable

Function for control remove progress.

Usage example
import supervisely as sly

# You can connect to API directly
address = 'https://app.supervisely.com/'
token = 'Your Supervisely API Token'
api = sly.Api(address, token)

# Or you can use API from environment
os.environ['SERVER_ADDRESS'] = 'https://app.supervisely.com'
os.environ['API_TOKEN'] = 'Your Supervisely API Token'
api = sly.Api.from_env()


image_ids = [19369645, 19369646, 19369647]
api.image.remove_batch(image_ids)
set_status(id, status)[source]

Sets Labeling Queue status.

Parameters
id : int

Labeling Queue ID in Supervisely.

status : str

New Labeling Queue status

Returns

None

Return type

NoneType

Usage example
import supervisely as sly
from supervisely.api.labeling_job_api.LabelingJobApi.Status import COMPLETED

os.environ['SERVER_ADDRESS'] = 'https://app.supervisely.com'
os.environ['API_TOKEN'] = 'Your Supervisely API Token'
api = sly.Api.from_env()

api.labeling_queue.set_status(id=9, status="completed")