Dataset Management#
Dataset is the most basic concept in Graviti SDK. Almost all
operations require a dataset first. Of course, it is necessary to initialize a
Workspace before managing the dataset:
from graviti import Workspace
ws = Workspace(f"{YOUR_ACCESSKEY}")
Create a Dataset#
SDK provides method create() to support creating a
dataset based on the given name:
ws.datasets.create(f"{DATASET_NAME}")
In addition to name, alias and storage config can also be specified:
ws.datasets.create(f"{DATASET_NAME}", f"{DATASET_ALIAS}", f"{STORAGE_CONFIG}")
Note
Unlike the operation on the web page, here SDK will not create an empty draft after creating the dataset.
List Datasets#
SDK provides method list() to support listing datasets
on the workspace:
ws.datasets.list()
Get a Dataset#
SDK provides method get() to support getting a dataset
by name:
ws.datasets.get(f"{DATASET_NAME}")
Delete a Dataset#
SDK provides method delete() to support deleting a
dataset by name:
ws.datasets.delete(f"{DATASET_NAME}")
Edit the Dataset#
SDK provides method edit() to support changing the name,
alias and default branch of the dataset.
dataset = ws.datasets.get(f"{DATASET_NAME}")
dataset.edit(
name=f"{NEW_DATASET_NAME}",
alias=f"{NEW_ALIAS}",
default_branch=f"{NEW_DEFAULT_BRANCH}"
)