Skip to content

Commit 23c97f0

Browse files
authored
Merge pull request #169 from fastlabel/feature/add-new-api-to-get-and-delete-tags
[EVERSTEEL]タグ取得・タグ削除のsdk
2 parents c6aaadc + 5859e9e commit 23c97f0

File tree

2 files changed

+91
-1
lines changed

2 files changed

+91
-1
lines changed

README.md

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2335,6 +2335,57 @@ Copy a project.
23352335
project_id = client.copy_project(project_id="YOUR_PROJECT_ID")
23362336
```
23372337

2338+
## Tags
2339+
2340+
### Get Tags
2341+
2342+
Get tags. (Up to 1000 tags)
2343+
2344+
keyword are search terms in the tag name (Optional).
2345+
offset is the starting position number to fetch (Optional).
2346+
limit is the max number to fetch (Optional).
2347+
2348+
If you need to fetch more than 1000 tags, please loop this method using offset and limit.
2349+
In the sample code below, you can fetch 1000 tags starting from the 2001st position.
2350+
2351+
```python
2352+
projects = client.get_tags(
2353+
project="YOUR_PROJECT_SLUG",
2354+
keyword="dog", # (Optional)
2355+
offset=2000, # (Optional)
2356+
limit=1000, # (Optional. Default is 100.)
2357+
)
2358+
```
2359+
2360+
### Response
2361+
2362+
Example of tags object
2363+
2364+
```python
2365+
[
2366+
{
2367+
"id": "YOUR_TAG_ID",
2368+
"name": "YOUR_TAG_NAME",
2369+
"order": 1,
2370+
"createdAt": "2023-08-14T11: 32: 36.462Z",
2371+
"updatedAt": "2023-08-14T11: 32: 36.462Z"
2372+
}
2373+
]
2374+
```
2375+
2376+
### Delete Tags
2377+
2378+
Delete tags.
2379+
2380+
```python
2381+
client.delete_tags(
2382+
tag_ids=[
2383+
"YOUR_TAG_ID_1",
2384+
"YOUR_TAG_ID_2",
2385+
],
2386+
)
2387+
```
2388+
23382389
## Dataset
23392390

23402391
### Create Dataset
@@ -2914,7 +2965,7 @@ Supported bbox annotation type.
29142965

29152966
Convert annotation file of YOLO format as a Fastlabel format and create task.
29162967

2917-
classes_file_path: YOLO classes text file path
2968+
classes_file_path: YOLO classes text file path
29182969
dataset_folder_path: Folder path containing YOLO Images and annotation
29192970

29202971
```python

fastlabel/__init__.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3780,6 +3780,45 @@ def copy_project(self, project_id: str) -> None:
37803780
endpoint = "projects/copy"
37813781
return self.api.post_request(endpoint, payload=payload)
37823782

3783+
# Tags
3784+
3785+
def get_tags(
3786+
self,
3787+
project: str,
3788+
keyword: str = None,
3789+
offset: int = None,
3790+
limit: int = 100,
3791+
) -> list:
3792+
"""
3793+
Returns a list of tags.
3794+
Returns up to 1000 at a time, to get more,
3795+
project is slug of your project (Required).
3796+
keyword are search terms in the tag name (Optional).
3797+
offset is the starting position number to fetch (Optional).
3798+
limit is the max number to fetch (Optional).
3799+
"""
3800+
if limit > 1000:
3801+
raise FastLabelInvalidException(
3802+
"Limit must be less than or equal to 1000.", 422
3803+
)
3804+
endpoint = "tags"
3805+
params = {"project": project}
3806+
if keyword:
3807+
params["keyword"] = keyword
3808+
if offset:
3809+
params["offset"] = offset
3810+
if limit:
3811+
params["limit"] = limit
3812+
return self.api.get_request(endpoint, params=params)
3813+
3814+
def delete_tags(self, tag_ids: List[str]) -> None:
3815+
"""
3816+
Delete a tags.
3817+
"""
3818+
endpoint = "tags/delete/multi"
3819+
payload = {"tagIds": tag_ids}
3820+
self.api.post_request(endpoint, payload=payload)
3821+
37833822
# Dataset
37843823

37853824
def find_dataset(self, dataset_id: str) -> dict:

0 commit comments

Comments
 (0)