Graviti Python SDK
Project description
Graviti Python SDK
Graviti Python SDK is a python library to access Graviti workspace 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.
Installation
Graviti can be installed from PyPI:
pip3 install graviti
Or from source:
git clone https://github.com/Graviti-AI/graviti-python-sdk.git
cd graviti-python-sdk
pip install -e .
Documentation
More information can be found on the documentation site
Usage
Before using Graviti SDK, please finish the following registration steps:
- Please visit Graviti to sign up.
- Please visit Graviti Developer Tools to get an AccessKey.
Get a Dataset
Workspace initialization:
from graviti import Workspace
ws = 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")
>>> dataset
Dataset("graviti-example/Graviti-dataset-demo")(
(alias): '',
(default_branch): 'main',
(created_at): '2022-05-26T02:55:36Z',
(updated_at): '2022-05-26T02:57:55Z',
(is_public): False,
(config): 'AmazonS3-us-west-1'
)
Switch Between Different Versions
View the current version of the dataset:
>>> dataset.HEAD
Branch("main")(
(commit_id): '47293b32f28c4008bc0f25b847b97d6f',
(parent_commit_id): None,
(title): 'Commit-1',
(committer): 'graviti-example',
(committed_at): '2022-05-26T02:57:00Z'
)
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.HEAD
Commit("47293b32f28c4008bc0f25b847b97d6f")(
(parent_commit_id): None,
(title): 'Commit-1',
(committer): 'graviti-example',
(committed_at): '2022-05-26T02:57:00Z'
)
>>> dataset.checkout("dev") # branch name
>>> dataset.HEAD
Branch("dev")(
(commit_id): '47293b32f28c4008bc0f25b847b97d6f',
(parent_commit_id): None,
(title): 'Commit-1',
(committer): 'graviti-example',
(committed_at): '2022-05-26T02:57:00Z'
)
>>> dataset.checkout("v1.0") # tag name
>>> dataset.HEAD
Commit("47293b32f28c4008bc0f25b847b97d6f")(
(parent_commit_id): None,
(title): 'Commit-1',
(committer): 'graviti-example',
(committed_at): '2022-05-26T02:57:00Z'
)
Get a Sheet
List all sheets:
>>> list(dataset.keys())
['train']
Get a sheet:
>>> dataset["train"]
filename box2ds
0 a.jpg DataFrame(1, 6)
1 b.jpg DataFrame(1, 6)
2 c.jpg DataFrame(1, 6)
Get the Data
Get the DataFrame:
>>> df = dataset["train"]
>>> df
filename box2ds
0 a.jpg DataFrame(1, 6)
1 b.jpg DataFrame(1, 6)
2 c.jpg DataFrame(1, 6)
View the schema of the sheet:
>>> df.schema
record(
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]
filename a.jpg
box2ds DataFrame(1, 6)
>>> df["box2ds"]
0 DataFrame(1, 6)
1 DataFrame(1, 6)
2 DataFrame(1, 6)
>>> df.loc[0]["box2ds"]
xmin ymin xmax ymax category attribute
difficult occluded
0 1.0 1.0 4.0 5.0 boat False False
>>> df["box2ds"][0]
xmin ymin xmax ymax category attribute
difficult occluded
0 1.0 1.0 4.0 5.0 boat False False
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file graviti-0.6.0rc1.tar.gz
.
File metadata
- Download URL: graviti-0.6.0rc1.tar.gz
- Upload date:
- Size: 85.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d058f89edd768a6d0eaab41639c8830b12685d20b971d0b5bf10e3b30a72d15a |
|
MD5 | cf793829426aad4aac477e779747878d |
|
BLAKE2b-256 | 82b199d9715a497c70d4d7d210b8f4a39fa3fe45a0a817eadcfb42025d7f592e |
File details
Details for the file graviti-0.6.0rc1-py2.py3-none-any.whl
.
File metadata
- Download URL: graviti-0.6.0rc1-py2.py3-none-any.whl
- Upload date:
- Size: 124.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d5583b107065126cf4048db32f148402b53dd9601fcf6bc2a2a201b32dae6c8 |
|
MD5 | 48878c5aa16fa85aa5c554bc2112f47d |
|
BLAKE2b-256 | e77019c83adb794e9588392c68f6a59afb5cfcce92344b3a043a999db28d1c2f |