Package: graviti
Graviti Python SDKGraviti Python SDK is a python library to accessGravitiworkspace and
manage your datasets. It provides a pythonic way to access your datasets by Graviti OpenAPI.NOTE: This project is still on pre-alpha stage, may have breaking changes in the future.InstallationGraviti can be installed from PyPI:pip3 install gravitiOr from source:git clone https://github.com/Graviti-AI/graviti-python-sdk.gitcd graviti-python-sdkpip install -e .DocumentationMore information can be found on thedocumentation siteUsageBefore using Graviti SDK, please finish the following registration steps:Please visitGravitito sign up.Please visitGraviti Developer Toolsto get anAccessKey.Get a DatasetWorkspace initialization:fromgravitiimportWorkspacews=Workspace(f"{YOUR_ACCESSKEY}")List datasets on the workspace:>>>ws.datasets.list()LazyPagingList[Dataset("graviti-example/Graviti-dataset-demo")]Get one dataset:>>>dataset=ws.datasets.get("Graviti-dataset-demo")>>>datasetDataset("graviti-example/Graviti-dataset-demo")((alias):'',(default_branch):'main',(created_at):2022-07-2004:22:35+00:00,(updated_at):2022-07-2004:23:45+00:00,(is_public):False,(storage_config):'AmazonS3-us-west-1')Switch Between Different VersionsView the current version of the dataset:>>>dataset.HEADBranch("main")((commit_id):'47293b32f28c4008bc0f25b847b97d6f',(parent):None,(title):'Commit-1',(committer):'graviti-example',(committed_at):2022-07-2004:22:35+00:00,)List history commits:>>>dataset.commits.list()LazyPagingList[Commit("47293b32f28c4008bc0f25b847b97d6f")]List all branches:>>>dataset.branches.list()LazyPagingList[Branch("main"),Branch("dev")]List all tags:>>>dataset.tags.list()LazyPagingList[Tag("v1.0")]Checkout commit/branch/tag:>>>dataset.checkout("47293b32f28c4008bc0f25b847b97d6f")# commit id>>>dataset.HEADCommit("47293b32f28c4008bc0f25b847b97d6f")((parent):None,(title):'Commit-1',(committer):'graviti-example',(committed_at):2022-07-2004:22:35+00:00,)>>>dataset.checkout("dev")# branch name>>>dataset.HEADBranch("dev")((commit_id):'47293b32f28c4008bc0f25b847b97d6f',(parent):None,(title):'Commit-1',(committer):'graviti-example',(committed_at):2022-07-2004:22:35+00:00,)>>>dataset.checkout("v1.0")# tag name>>>dataset.HEADCommit("47293b32f28c4008bc0f25b847b97d6f")((parent):None,(title):'Commit-1',(committer):'graviti-example',(committed_at):2022-07-2004:22:35+00:00,)Get a SheetList all sheets:>>>list(dataset.keys())['train']Get a sheet:>>>dataset["train"]filenamebox2ds0a.jpgDataFrame(1,6)1b.jpgDataFrame(1,6)2c.jpgDataFrame(1,6)Get the DataGet the DataFrame:>>>df=dataset["train"]>>>dffilenamebox2ds0a.jpgDataFrame(1,6)1b.jpgDataFrame(1,6)2c.jpgDataFrame(1,6)View the schema of the sheet:>>>df.schemarecord(fields={'filename':string(),'box2ds':array(items=label.Box2D(coords=float32(),categories=['boat','car'],attributes={'difficult':boolean(),'occluded':boolean(),},),),},)Get the data by rows or columns:>>>df.loc[0]filenamea.jpgbox2dsDataFrame(1,6)>>>df["box2ds"]0DataFrame(1,6)1DataFrame(1,6)2DataFrame(1,6)>>>df.loc[0]["box2ds"]xminyminxmaxymaxcategoryattributedifficultoccluded01.01.04.05.0boatFalseFalse>>>df["box2ds"][0]xminyminxmaxymaxcategoryattributedifficultoccluded01.01.04.05.0boatFalseFalse