Skip to content

Commit 75788e2

Browse files
authored
Merge pull request #238 from fastlabel/feature/8427_get-auto-annotation-jobs-by-sdk
#8427 SDKで自動アノテーションの実行結果を取得できる
2 parents ede99a6 + 9c812bd commit 75788e2

File tree

3 files changed

+86
-0
lines changed

3 files changed

+86
-0
lines changed

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3481,6 +3481,55 @@ training_job = client.execute_evaluation_job(
34813481

34823482
```
34833483

3484+
### Get auto-annotation jobs
3485+
3486+
Get auto-annotation jobs.
3487+
3488+
```python
3489+
def get_auto_annotation_jobs() -> list[dict]:
3490+
all_auto_annotation_jobs = []
3491+
offset = None
3492+
while True:
3493+
time.sleep(1)
3494+
3495+
auto_annotation_jobs = client.get_auto_annotation_jobs(project="YOUR_PROJECT_SLUG", offset=offset)
3496+
all_auto_annotation_jobs.extend(auto_annotation_jobs)
3497+
3498+
if len(auto_annotation_jobs) > 0:
3499+
offset = len(all_auto_annotation_jobs)
3500+
else:
3501+
break
3502+
return all_auto_annotation_jobs
3503+
3504+
```
3505+
3506+
#### Response
3507+
3508+
Example of a single auto-annotation job.
3509+
3510+
```python
3511+
3512+
[
3513+
{
3514+
'audioSeconds': 0,
3515+
'autoAnnotationType': 'image_bbox',
3516+
'completedAt': '2024-09-24T03:27:41.000Z',
3517+
'contentCount': 1000,
3518+
'createdAt': '2024-09-24T03:14:26.607Z',
3519+
'duration': 793,
3520+
'id': 'YOUR_AUTO_ANNOTATION_JOB_ID',
3521+
'modelName': 'Computer Vision - 汎用',
3522+
'msgCode': 'none',
3523+
'status': 'completed',
3524+
'taskAnnotationCount': 2598,
3525+
'updatedAt': '2024-09-24T03:27:40.914Z',
3526+
'userName': 'USER_NAME',
3527+
'version': 1
3528+
}
3529+
]
3530+
3531+
```
3532+
34843533
### Execute auto-annotation job
34853534

34863535
Execute auto-annotation job.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from pprint import pprint
2+
3+
import fastlabel
4+
5+
client = fastlabel.Client()
6+
7+
auto_annotation_jobs = client.get_auto_annotation_jobs(project="YOUR_PROJECT_SLUG")
8+
pprint(auto_annotation_jobs)

fastlabel/__init__.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4738,6 +4738,35 @@ def execute_evaluation_job(
47384738
payload={key: value for key, value in payload.items() if value is not None},
47394739
)
47404740

4741+
def get_auto_annotation_jobs(
4742+
self,
4743+
project: str,
4744+
offset: int = None,
4745+
limit: int = 1000,
4746+
) -> list:
4747+
"""
4748+
Returns a list of auto-annotation jobs.
4749+
Returns up to 1000 at a time, to get more, set offset as the starting position
4750+
to fetch.
4751+
project is slug of your project (Required).
4752+
offset is the starting position number to fetch (Optional).
4753+
limit is the max number to fetch (Optional).
4754+
"""
4755+
if project is None:
4756+
raise FastLabelInvalidException("Project is required.", 422)
4757+
if limit > 1000:
4758+
raise FastLabelInvalidException(
4759+
"Limit must be less than or equal to 1000.", 422
4760+
)
4761+
endpoint = "auto-annotations"
4762+
params = {"project": project}
4763+
if offset:
4764+
params["offset"] = offset
4765+
if limit:
4766+
params["limit"] = limit
4767+
4768+
return self.api.get_request(endpoint, params=params)
4769+
47414770
def execute_auto_annotation_job(
47424771
self,
47434772
project: str,

0 commit comments

Comments
 (0)