Labeling Job API

class supervisely_lib.api.labeling_job_api.LabelingJobApi(api)[source]

Bases: supervisely_lib.api.module_api.RemoveableModuleApi, supervisely_lib.api.module_api.ModuleWithStatus

API for working with Labeling Jobs. LabelingJobApi 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()

jobs = api.labeling_job.get_list(9) # api usage example
class Status(value)[source]

Bases: supervisely_lib.collection.str_enum.StrEnum

An enumeration.

PENDING = 'pending'
IN_PROGRESS = 'in_progress'
ON_REVIEW = 'on_review'
COMPLETED = 'completed'
STOPPED = 'stopped'
static info_sequence()[source]

NamedTuple LabelingJobInfo information about Labeling Job.

Example
LabelingJobInfo(id=2,
                name='Annotation Job (#1) (#1) (dataset_01)',
                readme='',
                description='',
                team_id=4,
                workspace_id=8,
                workspace_name='First Workspace',
                project_id=58,
                project_name='tutorial_project',
                dataset_id=54,
                dataset_name='dataset_01',
                created_by_id=4,
                created_by_login='anna',
                assigned_to_id=4,
                assigned_to_login='anna',
                reviewer_id=4,
                reviewer_login='anna',
                created_at='2020-04-08T15:10:12.618Z',
                started_at='2020-04-08T15:10:19.833Z',
                finished_at='2020-04-08T15:13:39.788Z',
                status='completed',
                disabled=False,
                images_count=3,
                finished_images_count=0,
                rejected_images_count=1,
                accepted_images_count=2,
                progress_images_count=2,
                classes_to_label=[],
                tags_to_label=[],
                images_range=(1, 5),
                objects_limit_per_image=None,
                tags_limit_per_image=None,
                filter_images_by_tags=[],
                include_images_with_tags=[],
                exclude_images_with_tags=[],
                entities=None)
static info_tuple_name()[source]

NamedTuple name - LabelingJobInfo.

create(name: str, dataset_id: int, user_ids: List[int], readme: str = None, description: str = None, classes_to_label: List[str] = None, objects_limit_per_image: int = None, tags_to_label: List[str] = None, tags_limit_per_image: int = None, include_images_with_tags: List[str] = None, exclude_images_with_tags: List[str] = None, images_range: List[int, int] = None, reviewer_id: int = None) → List[NamedTuple][source]

Creates Labeling Job and assigns given Users to it.

Parameters
  • name (str) – Labeling Job name in Supervisely.

  • dataset_id (int) – Dataset ID in Supervisely.

  • user_ids (List[int]) – User IDs in Supervisely to assign Users as labelers to Labeling Job.

  • readme (str, optional) – Additional information about Labeling Job.

  • description (str, optional) – Description of Labeling Job.

  • 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 Job.

Returns

List of information about new Labeling Job. 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()

user_name = 'alex'
dataset_id = 602
new_label_jobs = api.labeling_job.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_label_jobs)
# Output: [
#     [
#         92,
#         "alex (#1) (#3)",
#         "Readmy text",
#         "Work for labelers",
#         13,
#         29,
#         "Labelling Workspace",
#         494,
#         "Test Dataset",
#         602,
#         "ds1",
#         8,
#         "alex",
#         111,
#         "quantigo273",
#         8,
#         "alex",
#         "2021-03-25T11:04:34.031Z",
#         null,
#         null,
#         "pending",
#         false,
#         3,
#         0,
#         0,
#         0,
#         0,
#         [],
#         [],
#         [
#             null,
#             null
#         ],
#         5,
#         3,
#         [],
#         [],
#         [],
#         [
#             {
#                 "reviewStatus": "none",
#                 "id": 287244,
#                 "name": "IMG_0813"
#             },
#             {
#                 "reviewStatus": "none",
#                 "id": 287246,
#                 "name": "IMG_0432"
#             },
#             {
#                 "reviewStatus": "none",
#                 "id": 287245,
#                 "name": "IMG_0315"
#             }
#         ]
#     ],
#     [
#         93,
#         "alex (#2) (#3)",
#         "Readmy text",
#         "Work for labelers",
#         13,
#         29,
#         "Labelling Workspace",
#         494,
#         "Test Dataset",
#         602,
#         "ds1",
#         8,
#         "alex",
#         222,
#         "quantigo19",
#         8,
#         "alex",
#         "2021-03-25T11:04:34.031Z",
#         null,
#         null,
#         "pending",
#         false,
#         3,
#         0,
#         0,
#         0,
#         0,
#         [],
#         [],
#         [
#             null,
#             null
#         ],
#         5,
#         3,
#         [],
#         [],
#         [],
#         [
#             {
#                 "reviewStatus": "none",
#                 "id": 287248,
#                 "name": "IMG_8454"
#             },
#             {
#                 "reviewStatus": "none",
#                 "id": 287249,
#                 "name": "IMG_6896"
#             },
#             {
#                 "reviewStatus": "none",
#                 "id": 287247,
#                 "name": "IMG_1942"
#             }
#         ]
#     ]
# ]
get_list(team_id: int, created_by_id: Optional[int] = None, assigned_to_id: Optional[int] = None, project_id: Optional[int] = None, dataset_id: Optional[int] = None, show_disabled: bool = False) → List[NamedTuple][source]

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

Parameters
  • team_id (int) – Team ID in Supervisely.

  • created_by_id (int, optional) – ID of the User who created the LabelingJob.

  • assigned_to_id (int, optional) – ID of the assigned User.

  • project_id (int, optional) – Project ID in Supervisely.

  • dataset_id (int, optional) – Dataset ID in Supervisely.

  • show_disabled (bool, optional) – Show disabled Labeling Jobs.

Returns

List of information about Labeling Jobs. 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()

label_jobs = api.labeling_job.get_list(4)
print(label_jobs)
# Output: [
#     [
#         2,
#         "Annotation Job (#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,
#         [],
#         [],
#         [],
#         null
#     ],
#     [
#         3,
#         "Annotation Job (#1) (#2) (dataset_02)",
#         "",
#         "",
#         4,
#         8,
#         "First Workspace",
#         58,
#         "tutorial_project",
#         55,
#         "dataset_02",
#         4,
#         "anna",
#         4,
#         "anna",
#         4,
#         "anna",
#         "2020-04-08T15:10:12.618Z",
#         "2020-04-08T15:15:46.749Z",
#         "2020-04-08T15:17:33.572Z",
#         "completed",
#         false,
#         2,
#         0,
#         0,
#         2,
#         2,
#         [],
#         [],
#         [
#             1,
#             5
#         ],
#         null,
#         null,
#         [],
#         [],
#         [],
#         null
#     ]
# ]
stop(id: int) → None[source]

Makes Labeling Job unavailable for labeler with given User ID.

Parameters

id (int) – User ID in Supervisely.

Returns

None

Return type

NoneType

Usage example
os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly'
os.environ['API_TOKEN'] = 'Your Supervisely API Token'
api = sly.Api.from_env()

api.labeling_job.stop(9)
get_info_by_id(id: int) → NamedTuple[source]

Get Labeling Job information by ID.

Parameters

id (int) – Labeling Job ID in Supervisely.

Returns

Information about Labeling Job. 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()

label_job_info = api.labeling_job.get_info_by_id(2)
print(label_job_info)
# Output: [
#     2,
#     "Annotation Job (#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"
#         }
#     ]
# ]
archive(id: int) → None[source]

Archives Labeling Job with given ID.

Parameters

id (int) – Labeling Job ID in Supervisely.

Returns

None

Return type

NoneType

Usage example
os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly'
os.environ['API_TOKEN'] = 'Your Supervisely API Token'
api = sly.Api.from_env()

api.labeling_job.archive(23)
get_status(id: int)Status[source]

Get status of Labeling Job with given ID.

Parameters

id (int) – Labeling job ID in Supervisely.

Returns

Status object

Return type

Status

Usage example
os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly'
os.environ['API_TOKEN'] = 'Your Supervisely API Token'
api = sly.Api.from_env()

job_status = api.labeling_job.get_status(4)
print(job_status) # pending
wait(id: int, target_status: str, wait_attempts: Optional[int] = None, wait_attempt_timeout_sec: Optional[int] = None) → None[source]

Wait for a Labeling Job to change to the expected target status.

Parameters
  • id (int) – Labeling Job ID in Supervisely.

  • target_status (str) – Expected result status of Labeling Job.

  • wait_attempts (int, optional) – Number of attempts to retry, when WaitingTimeExceeded raises.

  • wait_attempt_timeout_sec (int, optional) – Time between attempts.

Raises

WaitingTimeExceeded, if waiting time exceeded

Returns

None

Return type

NoneType

Usage example
os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly'
os.environ['API_TOKEN'] = 'Your Supervisely API Token'
api = sly.Api.from_env()

api.labeling_job.wait(4, 'completed', wait_attempts=2, wait_attempt_timeout_sec=1)
# supervisely_lib.api.module_api.WaitingTimeExceeded: Waiting time exceeded
get_stats(id: int) → dict[source]

Get stats of given Labeling Job ID.

Parameters

id (int) – Labeling Job ID in Supervisely.

Returns

Dict with information about given Labeling Job

Return type

dict

Usage example
os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly'
os.environ['API_TOKEN'] = 'Your Supervisely API Token'
api = sly.Api.from_env()

status = api.labeling_job.get_stats(3)
print(status)
# Output: {
#     "job": {
#         "editingDuration": 0,
#         "annotationDuration": 720,
#         "id": 3,
#         "name": "Annotation Job (#1) (#2) (dataset_02)",
#         "startedAt": "2020-04-08T15:15:46.749Z",
#         "finishedAt": "2020-04-08T15:17:33.572Z",
#         "imagesCount": 2,
#         "finishedImagesCount": 2,
#         "tagsStats": [
#             {
#                 "id": 24,
#                 "color": "#ED68A1",
#                 "images": 1,
#                 "figures": 1,
#                 "name": "car_color"
#             },
#             {
#                 "id": 19,
#                 "color": "#A0A08C",
#                 "images": 0,
#                 "figures": 1,
#                 "name": "cars_number"
#             },
#             {
#                 "id": 20,
#                 "color": "#D98F7E",
#                 "images": 1,
#                 "figures": 1,
#                 "name": "like"
#             },
#             {
#                 "id": 23,
#                 "color": "#65D37C",
#                 "images": 0,
#                 "figures": 1,
#                 "name": "person_gender"
#             },
#             {
#                 "parentId": 23,
#                 "color": "#65D37C",
#                 "images": 0,
#                 "figures": 1,
#                 "name": "person_gender (male)"
#             },
#             {
#                 "parentId": 23,
#                 "color": "#65D37C",
#                 "images": 0,
#                 "figures": 0,
#                 "name": "person_gender (female)"
#             },
#             {
#                 "id": 21,
#                 "color": "#855D79",
#                 "images": 1,
#                 "figures": 1,
#                 "name": "situated"
#             },
#             {
#                 "parentId": 21,
#                 "color": "#855D79",
#                 "images": 1,
#                 "figures": 1,
#                 "name": "situated (inside)"
#             },
#             {
#                 "parentId": 21,
#                 "color": "#855D79",
#                 "images": 0,
#                 "figures": 0,
#                 "name": "situated (outside)"
#             },
#             {
#                 "id": 22,
#                 "color": "#A2B4FA",
#                 "images": 0,
#                 "figures": 1,
#                 "name": "vehicle_age"
#             },
#             {
#                 "parentId": 22,
#                 "color": "#A2B4FA",
#                 "images": 0,
#                 "figures": 1,
#                 "name": "vehicle_age (modern)"
#             },
#             {
#                 "parentId": 22,
#                 "color": "#A2B4FA",
#                 "images": 0,
#                 "figures": 0,
#                 "name": "vehicle_age (vintage)"
#             }
#         ]
#     },
#     "classes": [
#         {
#             "id": 43,
#             "color": "#F6FF00",
#             "shape": "rectangle",
#             "totalDuration": 0,
#             "imagesCount": 0,
#             "avgDuration": null,
#             "name": "bike",
#             "labelsCount": 0
#         },
#         {
#             "id": 42,
#             "color": "#BE55CE",
#             "shape": "polygon",
#             "totalDuration": 0,
#             "imagesCount": 0,
#             "avgDuration": null,
#             "name": "car",
#             "labelsCount": 0
#         },
#         {
#             "id": 41,
#             "color": "#FD0000",
#             "shape": "polygon",
#             "totalDuration": 0,
#             "imagesCount": 0,
#             "avgDuration": null,
#             "name": "dog",
#             "labelsCount": 0
#         },
#         {
#             "id": 40,
#             "color": "#00FF12",
#             "shape": "bitmap",
#             "totalDuration": 0,
#             "imagesCount": 0,
#             "avgDuration": null,
#             "name": "person",
#             "labelsCount": 0
#         }
#     ],
#     "images": {
#         "total": 2,
#         "images": [
#             {
#                 "id": 285,
#                 "reviewStatus": "accepted",
#                 "annotationDuration": 0,
#                 "totalDuration": 0,
#                 "name": "image_01",
#                 "labelsCount": 0
#             },
#             {
#                 "id": 284,
#                 "reviewStatus": "accepted",
#                 "annotationDuration": 0,
#                 "totalDuration": 0,
#                 "name": "image_02",
#                 "labelsCount": 0
#             }
#         ]
#     }
# }
get_activity(id: int) → pandas.core.frame.DataFrame[source]

Get all activity for given Labeling Job by ID.

Parameters

id (int) – Labeling Job ID in Supervisely.

Returns

Activity data as pd.DataFrame

Return type

pd.DataFrame

Usage example
os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly'
os.environ['API_TOKEN'] = 'Your Supervisely API Token'
api = sly.Api.from_env()

activity = api.labeling_job.get_activity(3)
print(activity)
# Output:
#   userId         action  ... tagId                 meta
# 0       4  update_figure  ...   NaN                   {}
# 1       4  create_figure  ...   NaN                   {}
# 2       4     attach_tag  ...  20.0                   {}
# 3       4     attach_tag  ...  21.0  {'value': 'inside'}
# 4       4     attach_tag  ...  24.0      {'value': '12'}
# 5       4  update_figure  ...   NaN                   {}
# 6       4  update_figure  ...   NaN                   {}
# 7       4  update_figure  ...   NaN                   {}
# 8       4  create_figure  ...   NaN                   {}
# 9       4  update_figure  ...   NaN                   {}
# [10 rows x 18 columns]
InfoType

alias of supervisely_lib.api.module_api.LabelingJobInfo