From 16b283f29e73fcbe04c26d34df3210c02dbd9cba Mon Sep 17 00:00:00 2001 From: ryoKaz Date: Thu, 2 Dec 2021 17:40:48 +0900 Subject: [PATCH 1/2] add update image task api --- README.md | 33 +++++++++++++++++++++++++++++++-- fastlabel/__init__.py | 41 +++++++++++++++++++++++++++++++++++++++++ setup.py | 2 +- 3 files changed, 73 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d0f7179..28ccca2 100644 --- a/README.md +++ b/README.md @@ -159,6 +159,34 @@ while True: > Please wait a second before sending another requests! +#### Update Tasks + +Update a signle task. + +```python +task_id = client.update_image_task( + task_id="YOUR_TASK_ID", + status="approved", + assignee="USER_SLUG", + tags=["tag1", "tag2"], + annotations=[ + { + "type": "bbox", + "value": "cat" + "attributes": [ + { "key": "kind", "value": "Scottish field" } + ], + "points": [ + 100, # top-left x + 100, # top-left y + 200, # bottom-right x + 200 # bottom-right y + ] + } + ], +) +``` + #### Response Example of a single image task object @@ -678,13 +706,14 @@ APIs for update and delete are same over all tasks. #### Update Task -Update a single task status and tags. +Update a single task status, tags and assignee. ```python task_id = client.update_task( task_id="YOUR_TASK_ID", status="approved", - tags=["tag1", "tag2"] + tags=["tag1", "tag2"], + assignee="USER_SLUG" ) ``` diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index 728adb1..53a0155 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -633,6 +633,47 @@ def update_task( return self.api.put_request(endpoint, payload=payload) + def update_image_task( + self, + task_id: str, + status: str = None, + external_status: str = None, + tags: list = [], + annotations: list[dict] = [], + **kwargs, + ) -> str: + """ + Update a single image task. + + task_id is an id of the task. (Required) + status can be 'registered', 'completed', 'skipped', 'reviewed', 'sent_back', 'approved', 'declined'. (Optional) + external_status can be 'registered', 'completed', 'skipped', 'reviewed', 'sent_back', 'approved', 'declined', 'customer_declined'. (Optional) + tags is a list of tag to be set. (Optional) + annotations is a list of annotation to be set. (Optional) + assignee is slug of assigned user. (Optional) + reviewer is slug of review user. (Optional) + approver is slug of approve user. (Optional) + external_assignee is slug of external assigned user. (Optional) + external_reviewer is slug of external review user. (Optional) + external_approver is slug of external approve user. (Optional) + """ + endpoint = "tasks/image/" + task_id + payload = {} + if status: + payload["status"] = status + if external_status: + payload["externalStatus"] = external_status + if tags: + payload["tags"] = tags + if annotations: + for annotation in annotations: + annotation["content"] = "" + payload["annotations"] = annotations + + self.__fill_assign_users(payload, **kwargs) + + return self.api.put_request(endpoint, payload=payload) + def update_image_classification_task( self, task_id: str, diff --git a/setup.py b/setup.py index e9c2523..bcf9fc4 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setuptools.setup( name="fastlabel", - version="0.11.9", + version="0.11.10", author="eisuke-ueta", author_email="eisuke.ueta@fastlabel.ai", description="The official Python SDK for FastLabel API, the Data Platform for AI", From 7f2143c037d0f1f9f596632d524bb42054cce410 Mon Sep 17 00:00:00 2001 From: ryoKaz Date: Thu, 2 Dec 2021 18:47:23 +0900 Subject: [PATCH 2/2] add comment --- fastlabel/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index 53a0155..1f6cf1a 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -667,6 +667,7 @@ def update_image_task( payload["tags"] = tags if annotations: for annotation in annotations: + # Since the content name is not passed in the sdk update api, the content will be filled on the server side. annotation["content"] = "" payload["annotations"] = annotations