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-07-20 04:22:35+00:00,
(updated_at): 2022-07-20 04:23:45+00:00,
(is_public): False,
(storage_config): 'AmazonS3-us-west-1'
)
Switch Between Different Versions
View the current version of the dataset:
>>> dataset.HEAD
Branch("main")(
(commit_id): '47293b32f28c4008bc0f25b847b97d6f',
(parent): None,
(title): 'Commit-1',
(committer): 'graviti-example',
(committed_at): 2022-07-20 04: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.HEAD
Commit("47293b32f28c4008bc0f25b847b97d6f")(
(parent): None,
(title): 'Commit-1',
(committer): 'graviti-example',
(committed_at): 2022-07-20 04:22:35+00:00,
)
>>> dataset.checkout("dev") # branch name
>>> dataset.HEAD
Branch("dev")(
(commit_id): '47293b32f28c4008bc0f25b847b97d6f',
(parent): None,
(title): 'Commit-1',
(committer): 'graviti-example',
(committed_at): 2022-07-20 04:22:35+00:00,
)
>>> dataset.checkout("v1.0") # tag name
>>> dataset.HEAD
Commit("47293b32f28c4008bc0f25b847b97d6f")(
(parent): None,
(title): 'Commit-1',
(committer): 'graviti-example',
(committed_at): 2022-07-20 04:22:35+00:00,
)
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
Metadata
Release files for graviti 0.13.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| graviti-0.13.1.tar.gz | 108.2 kB | Without provenance | Details for graviti-0.13.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| graviti-0.13.1-py3-none-any.whl | Python 3 | none | any | Details for graviti-0.13.1-py3-none-any.whl |
Total release size: 263.9 kB
Release files / graviti-0.13.1.tar.gz
| Download URL | graviti-0.13.1.tar.gz |
|---|---|
| Size | 108.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4a59a4344b327b48a2004e83e50f8fdeb9f4c67c0097a455202cae2258a36b1a
|
|
BLAKE2b-256 checksum How to use checksums |
5a26d30411ac4209fc8c7edb9c423edc0b0e10aba1650b80d470f2611493f9e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|
Release files / graviti-0.13.1-py3-none-any.whl
| Download URL | graviti-0.13.1-py3-none-any.whl |
|---|---|
| Size | 155.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1fb8820337c865e49ba6689878f2d3ab95348a926798fefa28ec98ff7d65fa3c
|
|
BLAKE2b-256 checksum How to use checksums |
fc98b41e53762f01f13f3b375fb2968bb497be712371d0a2d24661114d7e66fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|
Security for graviti 0.13.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.