From 7d6e364be060f2d4719605193f238b65acc45b8b Mon Sep 17 00:00:00 2001 From: tacorice <56864863+tacorice@users.noreply.github.com> Date: Mon, 14 Aug 2023 21:02:52 +0900 Subject: [PATCH 1/4] add new api to get and delete tags --- fastlabel/__init__.py | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index cfc0c09..59fdd81 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -3772,6 +3772,45 @@ def copy_project(self, project_id: str) -> None: endpoint = "projects/copy" return self.api.post_request(endpoint, payload=payload) + # Project Tags + + def get_tags( + self, + project: str, + keyword: str = None, + offset: int = None, + limit: int = 100, + ) -> list: + """ + Returns a list of project tags. + Returns up to 1000 at a time, to get more, + project is slug of your project (Required). + keyword are search terms in the tag name (Optional). + offset is the starting position number to fetch (Optional). + limit is the max number to fetch (Optional). + """ + if limit > 1000: + raise FastLabelInvalidException( + "Limit must be less than or equal to 1000.", 422 + ) + endpoint = "tags" + params = {"project": project} + if keyword: + params["keyword"] = keyword + if offset: + params["offset"] = offset + if limit: + params["limit"] = limit + return self.api.get_request(endpoint, params=params) + + def delete_tags(self, tag_ids: List[str]) -> None: + """ + Delete a tags. + """ + endpoint = "tags/delete/multi" + payload = {"tagIds": tag_ids} + self.api.post_request(endpoint, payload=payload) + # Dataset def find_dataset(self, dataset_id: str) -> dict: @@ -4195,4 +4234,3 @@ def get_histories( params["limit"] = limit return self.api.get_request(endpoint, params=params) - From f93039615261fa0818653ccde7a417c4f7f5968d Mon Sep 17 00:00:00 2001 From: tacorice <56864863+tacorice@users.noreply.github.com> Date: Tue, 15 Aug 2023 11:44:06 +0900 Subject: [PATCH 2/4] change comment --- fastlabel/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index 59fdd81..38d7b92 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -3772,7 +3772,7 @@ def copy_project(self, project_id: str) -> None: endpoint = "projects/copy" return self.api.post_request(endpoint, payload=payload) - # Project Tags + # Tags def get_tags( self, From 1f00fe92378a136cd85a2ae592e9523492327057 Mon Sep 17 00:00:00 2001 From: tacorice <56864863+tacorice@users.noreply.github.com> Date: Tue, 15 Aug 2023 12:28:53 +0900 Subject: [PATCH 3/4] add new api to README --- README.md | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 658366d..3fd3472 100644 --- a/README.md +++ b/README.md @@ -2335,6 +2335,57 @@ Copy a project. project_id = client.copy_project(project_id="YOUR_PROJECT_ID") ``` +## Tags + +### Get Tags + +Get tags. (Up to 1000 tags) + +keyword are search terms in the tag name (Optional). +offset is the starting position number to fetch (Optional). +limit is the max number to fetch (Optional). + +If you need to fetch more than 1000 tags, please loop this method using offset and limit. +In the sample code below, you can fetch 1000 tags starting from the 2001st position. + +```python +projects = client.get_tags( + project="YOUR_PROJECT_SLUG", + keyword="dog", # (Optional) + offset=2000, # (Optional) + limit=1000, # (Optional. Default is 100.) +) +``` + +### Response + +Example of tags object + +```python +[ + { + "id": "YOUR_TAG_ID", + "name": "YOUR_TAG_NAME", + "order": 1, + "createdAt": "2023-08-14T11: 32: 36.462Z", + "updatedAt": "2023-08-14T11: 32: 36.462Z" + } +] +``` + +### Delete Tags + +Delete tags. + +```python +client.delete_tags( + tag_ids=[ + "YOUR_TAG_ID_1", + "YOUR_TAG_ID_2", + ], +) +``` + ## Dataset ### Create Dataset @@ -2697,7 +2748,7 @@ Supported bbox annotation type. Convert annotation file of YOLO format as a Fastlabel format and create task. -classes_file_path: YOLO classes text file path +classes_file_path: YOLO classes text file path dataset_folder_path: Folder path containing YOLO Images and annotation ```python From 5859e9ecf791e08fc1df5ba62c3ae6ba10508a2d Mon Sep 17 00:00:00 2001 From: tacorice <56864863+tacorice@users.noreply.github.com> Date: Tue, 15 Aug 2023 13:14:31 +0900 Subject: [PATCH 4/4] fix the point pointed out --- fastlabel/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index 38d7b92..3d36208 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -3782,7 +3782,7 @@ def get_tags( limit: int = 100, ) -> list: """ - Returns a list of project tags. + Returns a list of tags. Returns up to 1000 at a time, to get more, project is slug of your project (Required). keyword are search terms in the tag name (Optional).