Skip to main content

Databrary API wrapper

Project description

Python Databrary API Wrapper

This is a Python wrapper around databrary API

Installation

Run the following to install:

pip install pydatabrary

Usage

Databrary API

from pybrary import Pybrary

# Start a Databrary session
pb = Pybrary.get_instance('USERNAME', 'PASSWORD')
# You need to have permissions to the volume, to interact with it
volume_info = pb.get_volume_info(1)
print(volume_info)

Databrary Curation

Generate tamplates

from pybrary import Curation

assets = Curation.generate_assets_list('/PATH/TO/ASSET/FOLDER', '/PATH/TO/OUTPUT/CSV')

# The number of records that you need for your ingest
payload = {
    'participant': 0,
    'pilot': 0,
    'exclusion': 0,
    'condition': 0,
    'group': 0,
    'task': 0,
    'context': 0,
}
records = Curation.generate_records_list(categories=payload, output='/PATH/TO/OUTPUT/CSV')

# Value is the number of containers you wish to generate
containers = Curation.generate_containers_list(value=2, output='/PATH/TO/OUTPUT/CSV')

Read CSV files

After you edit your CSV files you will have to pass them to pybrary to validate them and generate JSON file needed for your ingest

Only containers are required, if you provide assets and records filespybrary will populate assets and records found in the container fields

Note: pybrary will ignore duplicate keys, so make sure to have unique ids for your rows

from pybrary import Curation

# You can read your files separately to edit them programmatically 
assets = Curation.read_assets_csv('/PATH/TO/ASSETS/CSV')
records = Curation.read_records_csv('/PATH/TO/RECORDS/CSV')
containers = Curation.read_containers_csv('/PATH/TO/CONTAINERS/CSV')

Generate the ingest file

from pybrary import Curation

curation = Curation(
    'Volume',
    '/PATH/TO/CONTAINERS/CSV',
    assets_file='/PATH/TO/ASSETS/CSV',
    records_file='/PATH/TO/RECORDS/CSV'
)
curation.generate_ingest_file('/PATH/TO/JSON/OUTPUT')

Development

Install Locally

pip instal -e .

Build

python -m build

Publish

twine upload dist/*

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

pydatabrary-0.1.3.tar.gz (13.8 kB view hashes)

Uploaded Source

Built Distribution

pydatabrary-0.1.3-py3-none-any.whl (18.0 kB view hashes)

Uploaded Python 3

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