Last active
July 26, 2023 07:25
-
-
Save gustavz/b317aa89aefcf509d92691201bf301e7 to your computer and use it in GitHub Desktop.
List all available Deep Lake cloud datasets for a given user / orgnaization.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from deeplake.util.bugout_reporter import deeplake_reporter | |
from deeplake.client.client import DeepLakeBackendClient | |
def list_deeplake_datasets( | |
org_id: str = "", | |
token: str = None, | |
) -> None: | |
"""List all available Deep Lake cloud datasets. | |
Removed from deeplake in: https://github.com/activeloopai/deeplake/pull/2182/files | |
""" | |
deeplake_reporter.feature_report( | |
feature_name="list", | |
parameters={"org_id": org_id}, | |
) | |
def get_datasets(self, workspace: str): | |
LIST_DATASETS = "/api/datasets/{}" | |
suffix_public = LIST_DATASETS.format("public") | |
suffix_user = LIST_DATASETS.format("all") | |
if workspace: | |
res_datasets = self.get_workspace_datasets( | |
workspace, suffix_public, suffix_user | |
) | |
else: | |
public_datasets = self.request( | |
"GET", | |
suffix_public, | |
endpoint=self.endpoint(), | |
).json() | |
user_datasets = self.request( | |
"GET", | |
suffix_user, | |
endpoint=self.endpoint(), | |
).json() | |
res_datasets = public_datasets + user_datasets | |
return [ds["_id"] for ds in res_datasets] | |
client = DeepLakeBackendClient(token=token) | |
client.get_datasets = get_datasets | |
datasets = client.get_datasets(client, workspace=org_id) | |
return datasets |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment