Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"], # 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
)
```
Expand All @@ -2405,6 +2407,8 @@ See API docs for details.
{
'id': 'YOUR_DATASET_ID',
'name': 'object-detection',
'tags': ['cat', 'dog'],
'visibility': 'workspace',
'license': 'The MIT License',
'createdAt': '2022-10-31T02:20:00.248Z',
'updatedAt': '2022-10-31T02:20:00.248Z'
Expand All @@ -2431,11 +2435,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"], # max 5 tags per dataset.
visibility="workspace", # visibility can be 'workspace' or 'public'.
)
```

Expand All @@ -2447,7 +2453,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"]
)
```

Expand Down
41 changes: 22 additions & 19 deletions fastlabel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3831,59 +3831,62 @@ 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.(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(self, name: str, license: str = "") -> dict:
def create_dataset(
self, name: str, tags: List[str] = [], visibility: str = None, license: str = ""
) -> 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 are search terms in the dataset visibility.(Optional).
license is a license name of your dataset. (Optional)
"""
endpoint = "datasets"
payload = {"name": name, "license": license}
if tags:
payload["tags"] = tags
if visibility:
payload["visibility"] = visibility
return self.api.post_request(endpoint, payload=payload)

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:
Expand Down