Skip to main content

Graviti TensorBay 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


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.2.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

graviti-0.1.2-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file graviti-0.1.2.tar.gz.

File metadata

  • Download URL: graviti-0.1.2.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.2

File hashes

Hashes for graviti-0.1.2.tar.gz
Algorithm Hash digest
SHA256 aeac09dc4b2ec0fc7a4d884217914f656af2bd97d6c2ee5f64933165f7499856
MD5 9b6c4e21c6118a1df8e25e16112660ba
BLAKE2b-256 7df2d641c90b240109fb2939bd980417ec0c839a9362cea1d8bb166e29f79a2a

See more details on using hashes here.

File details

Details for the file graviti-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: graviti-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 20.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.2

File hashes

Hashes for graviti-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d6ab7b8774128bf35e5c36362fa822d390329dff106c0fbe9b67344529d8d5fb
MD5 c6f97bc5e488453107ff3da6bff1964e
BLAKE2b-256 86ef4c840f0495cacb7365369250d314fad5d927371d74ec8d5cd5a4e414f83d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page