From fda7ec6f2b339fa38f9df23039a98f52f3e2e6f8 Mon Sep 17 00:00:00 2001 From: Jiei-S Date: Thu, 31 Aug 2023 11:44:37 +0900 Subject: [PATCH 1/5] feat: dataset api - create --- README.md | 4 ++++ fastlabel/__init__.py | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/README.md b/README.md index f81d95a..70ed379 100644 --- a/README.md +++ b/README.md @@ -2393,6 +2393,8 @@ Create a new dataset. ```python dataset = client.create_dataset( name="object-detection", # Only lowercase alphanumeric characters + hyphen is available + tags=["cat", "dog"], + visibility="workspace", # visibility can be 'workspace' or 'public'. workspace is only visible to your workspace members. public is visible to all users. ) ``` @@ -2404,6 +2406,8 @@ See API docs for details. { 'id': 'YOUR_DATASET_ID', 'name': 'object-detection', + 'tags': ['cat', 'dog'], + 'visibility': 'workspace', 'createdAt': '2022-10-31T02:20:00.248Z', 'updatedAt': '2022-10-31T02:20:00.248Z' } diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index b0be554..4828818 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -3863,16 +3863,24 @@ def get_datasets( def create_dataset( self, name: str, + tags: List[str] = [], + visibility: str = None, ) -> dict: """ Create a dataset. name is name of your dataset. Only lowercase alphanumeric characters + hyphen is available (Required). + tags is a list of tag (Optional). + visibility is visibility of your dataset. visibility can be 'workspace' or 'public' (Optional). """ endpoint = "datasets" payload = { "name": name, } + if tags: + payload["tags"] = tags + if visibility: + payload["visibility"] = visibility return self.api.post_request(endpoint, payload=payload) def update_dataset( From f7048bfd3ae9a398df7396acb7f9943030266d84 Mon Sep 17 00:00:00 2001 From: Jiei-S Date: Thu, 31 Aug 2023 11:51:23 +0900 Subject: [PATCH 2/5] feat: dataset api - update --- README.md | 2 +- fastlabel/__init__.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 70ed379..9044fcb 100644 --- a/README.md +++ b/README.md @@ -2449,7 +2449,7 @@ Update a single dataset. ```python dataset = client.update_dataset( - dataset_id="YOUR_DATASET_ID", name="object-detection" + dataset_id="YOUR_DATASET_ID", name="object-detection", tags=["cat", "dog"] ) ``` diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index 4828818..e6bf0a3 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -3887,15 +3887,19 @@ def update_dataset( self, dataset_id: str, name: str = None, + tags: List[str] = [], ) -> dict: """ Update a dataset. dataset_id is an id of the dataset (Required). name is name of your dataset (Required). + tags is a list of tag (Optional). """ endpoint = "datasets/" + dataset_id payload = {"name": name} + if tags: + payload["tags"] = tags return self.api.put_request(endpoint, payload=payload) def delete_dataset(self, dataset_id: str) -> None: From 335c7068f1a93ee652f10632a480cc90dcd5f7ef Mon Sep 17 00:00:00 2001 From: Jiei-S Date: Thu, 31 Aug 2023 12:30:31 +0900 Subject: [PATCH 3/5] feat: dataset api - get --- README.md | 6 ++++-- fastlabel/__init__.py | 27 +++++++++------------------ 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 9044fcb..d090999 100644 --- a/README.md +++ b/README.md @@ -2433,11 +2433,13 @@ datasets = client.get_datasets() The success response is the same as when created, but it is an array. -You can filter by type and keywords. +You can filter by keywords and visibility, tags. ```python datasets = client.get_datasets( - keyword="dog" + keyword="dog", + tags=["cat", "dog"], + visibility="workspace", # visibility can be 'workspace' or 'public'. ) ``` diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index e6bf0a3..f0175f0 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -3831,33 +3831,24 @@ def find_dataset(self, dataset_id: str) -> dict: def get_datasets( self, keyword: str = None, - offset: int = None, - limit: int = 100, + tags: List[str] = [], + visibility: str = None, ) -> list: """ - Returns a list of datasets with latest version. - - Returns up to 1000 at a time, to get more, set offset as the starting position - to fetch. + Returns a list of datasets. keyword are search terms in the dataset slug (Optional). - offset is the starting position number to fetch (Optional). - limit is the max number to fetch (Optional). + tags are search terms in the dataset tags (Optional). + visibility are search terms in the dataset visibility. visibility can be 'workspace' or 'public' (Optional). """ - if limit > 1000: - raise FastLabelInvalidException( - "Limit must be less than or equal to 1000.", 422 - ) endpoint = "datasets" params = {} if keyword: params["keyword"] = keyword - if type: - params["type"] = type - if offset: - params["offset"] = offset - if limit: - params["limit"] = limit + if tags: + params["tags"] = tags + if visibility: + params["visibility"] = visibility return self.api.get_request(endpoint, params=params) def create_dataset( From fd0881fa907d66d35af8937816ba22e105bae75a Mon Sep 17 00:00:00 2001 From: Jiei-S Date: Fri, 1 Sep 2023 14:11:31 +0900 Subject: [PATCH 4/5] feat: dataset api - mod README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 45ba00f..a439ee9 100644 --- a/README.md +++ b/README.md @@ -2393,7 +2393,7 @@ Create a new dataset. ```python dataset = client.create_dataset( name="object-detection", # Only lowercase alphanumeric characters + hyphen is available - tags=["cat", "dog"], + tags=["cat", "dog"], # max 5 tags per dataset. visibility="workspace", # visibility can be 'workspace' or 'public'. workspace is only visible to your workspace members. public is visible to all users. license="The MIT License" # Optional ) @@ -2440,7 +2440,7 @@ You can filter by keywords and visibility, tags. ```python datasets = client.get_datasets( keyword="dog", - tags=["cat", "dog"], + tags=["cat", "dog"], # max 5 tags per dataset. visibility="workspace", # visibility can be 'workspace' or 'public'. ) ``` From c06a66b6322cc704b6a4500c79e25a66a037211c Mon Sep 17 00:00:00 2001 From: Jiei-S Date: Fri, 1 Sep 2023 14:37:40 +0900 Subject: [PATCH 5/5] feat: dataset api - remove unnecessary comment --- fastlabel/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index f6c899d..5dc4735 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -3839,7 +3839,7 @@ def get_datasets( keyword are search terms in the dataset slug (Optional). tags are search terms in the dataset tags (Optional). - visibility are search terms in the dataset visibility. visibility can be 'workspace' or 'public' (Optional). + visibility are search terms in the dataset visibility.(Optional). """ endpoint = "datasets" params = {} @@ -3859,7 +3859,7 @@ def create_dataset( name is name of your dataset. Only lowercase alphanumeric characters + hyphen is available (Required). tags is a list of tag (Optional). - visibility is visibility of your dataset. visibility can be 'workspace' or 'public' (Optional). + visibility are search terms in the dataset visibility.(Optional). license is a license name of your dataset. (Optional) """ endpoint = "datasets"