Graviti datacenter python SDK
Project description
Graviti python SDK
Installation
pip3 install graviti
Usage
Get accessKey
AccessKey is required when upload data.
Use your username and password to login to Graviti website, and get accessKey on profile page.
Upload data
This sample is for uploading dataset which only contains data collected from a single sensor.
#!/usr/bin/env python3
from graviti import GAS
ACCESS_KEY = "Accesskey-****"
DATA_SET_NAME = "TestDataSet"
gas = GAS(ACCESS_KEY)
data_set = gas.get_or_create_data_set(DATA_SET_NAME) # create dataset
# single-thread upload
for filename in FILE_LIST:
data_set.upload_data(filename, "remote_path")
# # multi-thread uploading
# # when use multi-thread uploading
# # uncomment the following code and comment single-thread uploading code
# from concurrent.futures import ThreadPoolExecutor
# THREAD_NUM = 8 # number of threads
# with ThreadPoolExecutor(THREAD_NUM) as executor:
# for filename in FILE_LIST:
# executor.submit(data_set.upload_data, filename, "remote_path")
Upload multisensor data
This sample is for uploading dataset which contains data collected from multi sensors.
#!/usr/bin/env python3
from graviti import GAS
from graviti import Sensor, Frame
ACCESS_KEY = "Accesskey-****"
DATA_SET_NAME = "TestMultisensorDataSet"
gas = GAS(ACCESS_KEY)
data_set = gas.get_or_create_data_set(DATA_SET_NAME, is_multisensor=True) # create multisensor dataset
for sensor_name in SENSOR_LIST:
sensor = Sensor(sensor_name, Sensor.CAMERA)
sensor.set_description("This is a camera")
sensor.set_translation(x=1.1, y=2.2, z=3.3)
sensor.set_rotation(w=1.1, x=2.2, y=3.3, z=4.4)
sensor.set_camera_matrix(fx=1.1, fy=2.2, cx=3.3, cy=4.4)
sensor.set_distortion_coefficient(p1=1.1, p2=2.2, k1=3.3, k2=4.4, k3=5.5)
data_set.upload_sensor(sensor)
# single-thread uploading
for frame_info in FRAME_LIST:
frame = Frame()
for sensor_name in SENSOR_LIST:
frame.add_data(sensor_name, frame_info.filename, "remote_path", frame_info.timestamp)
data_set.upload_frame(frame)
# # multi-thread uploading
# # when use multi-thread uploading
# # uncomment the following code and comment single-thread uploading code
# from concurrent.futures import ThreadPoolExecutor
# THREAD_NUM = 8 # number of threads
# with ThreadPoolExecutor(THREAD_NUM) as executor:
# for frame_info in FRAME_LIST:
# frame = Frame()
# for sensor_name in SENSOR_LIST:
# frame.add_data(sensor_name, frame_info.filename, "remote_path", frame_info.timestamp)
# executor.submit(data_set.upload_frame, frame)
Command line
We also provide gas
command to call SDK APIs.
Use gas
in terminal to see the available commands as follows.
gas config
gas create
gas delete
gas publish
gas ls
gas cp
gas rm
accessKey config
gas config [accessKey]
# this command writes accesskey into config file
create dataset
gas create [dataset_name]
delete dataset
gas delete [dataset_name]
publish dataset
gas publish [dataset_name]
list data
gas ls [dataset_name]://[remote_path]
upload data
gas cp [Options] [local_path1] [local_path2] ... [dataset name]://[remote_path]
Options:
-r, --recursive Copy directories recursively.
-j, --jobs INTEGER The number of threads.
# if only upload one file and [remote path] doesn't end with '/'
# then the file will be uploaded and renamed as [remote_path]
# multi-thread upload: -j THREAD_NUM
delete data
gas rm [Options] [dataset name]://[remote_path]
Options:
-r, --recursive Remove directories recursively.
# one single command can only delete one remote path
# if '-r' then all the paths under [remote_path] and itself will be deleted
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
graviti-0.1.1.tar.gz
(16.3 kB
view details)
Built Distribution
graviti-0.1.1-py3-none-any.whl
(20.0 kB
view details)
File details
Details for the file graviti-0.1.1.tar.gz
.
File metadata
- Download URL: graviti-0.1.1.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc163f35babe5d8c9daa44e517ef435722a414cdee1b03cac238b013f5353de6 |
|
MD5 | a8c98f1ab3ee2126bdb4d89bb8e66173 |
|
BLAKE2b-256 | 9fbd61062c4f1d71e4ddc7c2d696afb7197aa478ecab72f62eb6b08f7e8ca213 |
File details
Details for the file graviti-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: graviti-0.1.1-py3-none-any.whl
- Upload date:
- Size: 20.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d14ae9ce5f74b1ffc0f83a872c3e5f002631b1cd9894f3bd263f206f412f0b33 |
|
MD5 | 9160d63fe4e37713d41c3e2d42a5dbf8 |
|
BLAKE2b-256 | aa77d7e20eb7d301f5e7735d887fa699ec86a2e24420e637d0b6a5ece00ccad5 |