Skip to content

Commit 9c63c2c

Browse files
authored
Merge pull request #89 from fastlabel/develop
Merge to main
2 parents ba33581 + 172e244 commit 9c63c2c

File tree

3 files changed

+74
-3
lines changed

3 files changed

+74
-3
lines changed

README.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,34 @@ while True:
159159

160160
> Please wait a second before sending another requests!
161161
162+
#### Update Tasks
163+
164+
Update a signle task.
165+
166+
```python
167+
task_id = client.update_image_task(
168+
task_id="YOUR_TASK_ID",
169+
status="approved",
170+
assignee="USER_SLUG",
171+
tags=["tag1", "tag2"],
172+
annotations=[
173+
{
174+
"type": "bbox",
175+
"value": "cat"
176+
"attributes": [
177+
{ "key": "kind", "value": "Scottish field" }
178+
],
179+
"points": [
180+
100, # top-left x
181+
100, # top-left y
182+
200, # bottom-right x
183+
200 # bottom-right y
184+
]
185+
}
186+
],
187+
)
188+
```
189+
162190
#### Response
163191

164192
Example of a single image task object
@@ -678,13 +706,14 @@ APIs for update and delete are same over all tasks.
678706

679707
#### Update Task
680708

681-
Update a single task status and tags.
709+
Update a single task status, tags and assignee.
682710

683711
```python
684712
task_id = client.update_task(
685713
task_id="YOUR_TASK_ID",
686714
status="approved",
687-
tags=["tag1", "tag2"]
715+
tags=["tag1", "tag2"],
716+
assignee="USER_SLUG"
688717
)
689718
```
690719

fastlabel/__init__.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,48 @@ def update_task(
633633

634634
return self.api.put_request(endpoint, payload=payload)
635635

636+
def update_image_task(
637+
self,
638+
task_id: str,
639+
status: str = None,
640+
external_status: str = None,
641+
tags: list = [],
642+
annotations: list[dict] = [],
643+
**kwargs,
644+
) -> str:
645+
"""
646+
Update a single image task.
647+
648+
task_id is an id of the task. (Required)
649+
status can be 'registered', 'completed', 'skipped', 'reviewed', 'sent_back', 'approved', 'declined'. (Optional)
650+
external_status can be 'registered', 'completed', 'skipped', 'reviewed', 'sent_back', 'approved', 'declined', 'customer_declined'. (Optional)
651+
tags is a list of tag to be set. (Optional)
652+
annotations is a list of annotation to be set. (Optional)
653+
assignee is slug of assigned user. (Optional)
654+
reviewer is slug of review user. (Optional)
655+
approver is slug of approve user. (Optional)
656+
external_assignee is slug of external assigned user. (Optional)
657+
external_reviewer is slug of external review user. (Optional)
658+
external_approver is slug of external approve user. (Optional)
659+
"""
660+
endpoint = "tasks/image/" + task_id
661+
payload = {}
662+
if status:
663+
payload["status"] = status
664+
if external_status:
665+
payload["externalStatus"] = external_status
666+
if tags:
667+
payload["tags"] = tags
668+
if annotations:
669+
for annotation in annotations:
670+
# Since the content name is not passed in the sdk update api, the content will be filled on the server side.
671+
annotation["content"] = ""
672+
payload["annotations"] = annotations
673+
674+
self.__fill_assign_users(payload, **kwargs)
675+
676+
return self.api.put_request(endpoint, payload=payload)
677+
636678
def update_image_classification_task(
637679
self,
638680
task_id: str,

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setuptools.setup(
1010
name="fastlabel",
11-
version="0.11.9",
11+
version="0.11.10",
1212
author="eisuke-ueta",
1313
author_email="[email protected]",
1414
description="The official Python SDK for FastLabel API, the Data Platform for AI",

0 commit comments

Comments
 (0)