Skip to content

Commit

Permalink
feat(Workspaces): list datasets in a workspace (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
cheikhgwane authored Jan 16, 2024
1 parent e83eefb commit 916832a
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions openhexa/sdk/workspaces/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,47 @@ def get_dataset(self, identifier: str) -> Dataset:
description=data["dataset"]["description"],
)

def list_datasets(self) -> list[Dataset]:
"""List datasets in a workspace.
Returns
-------
List of Datasets
"""
response = graphql(
"""
query getWorkspaceDatasets($slug: String!) {
workspace(slug: $slug) {
datasets {
items {
id
dataset {
id
slug
name
description
}
}
}
}
}
""",
{"slug": self.slug},
)
data = response["workspace"]["datasets"]["items"]
datasets = [
Dataset(
id=d["dataset"]["id"],
slug=d["dataset"]["slug"],
name=d["dataset"]["name"],
description=d["dataset"]["description"],
)
for d in data
]

return datasets


# Once we deprecate the `python pipeline.py` command, we can enhance this to only load the workspace
# if we're in a pipeline/jupyter context
Expand Down

0 comments on commit 916832a

Please sign in to comment.