Skip to main content

Module for working with Unfolded Studio's Data SDK

Project description

unfolded-data-sdk

Python package for interfacing with Unfolded's Data SDK.

Installation

For now, this package is not on a public Python package repository. However you can install it directly from Github easily as long as you have access to the repository:

pip install git+ssh://git@github.com/UnfoldedInc/unfolded-py.git#subdirectory=modules/data-sdk

Usage

CLI

The CLI is available through uf-data-sdk on the command line. Running that without any other arguments gives you a list of available commands:

> uf-data-sdk
Usage: uf-data-sdk [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  delete-dataset    Delete dataset from Unfolded Studio Warning: This...
  download-dataset  Download existing dataset to disk
  list-datasets     List datasets for a given user
  update-dataset    Update data for existing Unfolded Studio dataset
  upload-file       Upload new dataset to Unfolded Studio

Then to see how to use a command, pass --help to a subcommand:

> uf-data-sdk list-datasets --help
Usage: uf-data-sdk list-datasets [OPTIONS]

  List datasets for a given user

Options:
  --token TEXT    Unfolded Studio access token.  [required]
  --baseurl TEXT  Unfolded Studio API URL.  [default: https://api.unfolded.ai]
  --help          Show this message and exit.

Python Package

The Python package can be imported via unfolded.data_sdk:

from unfolded.data_sdk import DataSDK, ContentType

data_sdk = DataSDK(token='eyJ...')

List Datasets

List datasets for given user

datasets = data_sdk.list_datasets()

Get Dataset by ID

Get dataset given its id

dataset = datasets[0]
data_sdk.get_dataset_by_id(dataset)

Download dataset data

Download data for dataset given its id

dataset = datasets[0]
data_sdk.download_dataset(dataset, output_file='output.csv')

Upload new dataset

Upload new dataset to Unfolded Studio

data_sdk.upload_file(
    file='new_file.csv',
    name='Dataset name',
    content_type=ContentType.CSV,
    description='Dataset description')

Update existing dataset

Update data for existing Unfolded Studio dataset

dataset = datasets[0]
data_sdk.update_dataset(
    file='new_file.csv',
    dataset=dataset,
    content_type=ContentType.CSV)

Delete dataset

Delete dataset from Unfolded Studio

Warning: This operation cannot be undone. If you delete a dataset currently used in one or more maps, the dataset will be removed from those maps, possibly causing them to render incorrectly.

dataset = datasets[0]
data_sdk.delete_dataset(dataset)

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

unfolded.data-sdk-0.1.0.tar.gz (5.2 kB view hashes)

Uploaded Source

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