Official Python SDK for DataCrunch Public API
Project description
DataCrunch Python SDK
The official DataCrunch.io Python SDK.
The SDK's documentation is available on ReadTheDocs
DataCrunch's Public API documentation is available here.
Getting Started - Using the SDK:
-
Install via pip:
pip install datacrunch
-
Generate your client credentials - instructions in the public API docs.
-
Add the client secret to an environment variable (don't want it to be hardcoded):
Linux (bash):
export DATACRUNCH_CLIENT_SECRET=Z4CZq02rdwdB7ISV0k4Z2gtwAFKiyvr2U1l0KDIeYi
Other platforms: https://en.wikipedia.org/wiki/Environment_variable
-
Example for creating a new instance:
import os from datacrunch import DataCrunchClient # Get client secret from environment variable CLIENT_SECRET = os.environ['DATACRUNCH_CLIENT_SECRET'] CLIENT_ID = 'Ibk5bdxV64lKAWOqYnvSi' # Create datcrunch client datacrunch = DataCrunchClient(CLIENT_ID, CLIENT_SECRET) # Get all SSH keys ssh_keys = datacrunch.ssh_keys.get() # Create a new instance instance = datacrunch.instances.create(instance_type='1V100.6V', image='fastai', ssh_key_ids=ssh_keys, hostname='example', description='example instance') # Delete instance datacrunch.instances.action(instance.id, datacrunch.actions.DELETE)
More examples can be found in the
/examples
folder or in the documentation.
Development
Setting up the local development environment
-
Clone the repository:
git clone
-
Create local virtual environment:
python3 -m venv datacrunch_env && source ./datacrunch_env/bin/activate
or if using fish shell:
python3 -m venv datacrunch_env && source ./datacrunch_env/bin/activate.fish
-
Install Dependencies:
pip3 install -e .[test] pip3 install -U pytest
Running Tests
We use pytest for testing.
-
To execute all tests
pytest
-
To execute a single test file
pytest ./tests/unit_tests/test_file.py
Local Manual Testing
from datacrunch.datacrunch import DataCrunchClient
CLIENT_SECRET = 'secret'
CLIENT_ID = 'Ibk5bdxV64lKAWOqYnvSi'
# Create datcrunch client
datacrunch = DataCrunchClient(CLIENT_ID, CLIENT_SECRET, base_url='http://localhost:3001/v1')
Generating the documentation
If added a new service, create a documentation template under api/services for that service.
cd docs
make html
Style Guide
Use autopep8 for auto code formatting:
# Install
pip3 install autopep8
# Apply to an entire directory
autopep8 directory_name --recursive --in-place --pep8-passes 2000 --verbose
# Or a single file
autopep8 file.py --in-place
Contact
You can contact us here, or send a message / open an issue in the repo.
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
Built Distribution
File details
Details for the file datacrunch-1.0.4.tar.gz
.
File metadata
- Download URL: datacrunch-1.0.4.tar.gz
- Upload date:
- Size: 24.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aef9dadcf6b425402a8d86948a2506343085909816db0b92b7071e582fcf32b5 |
|
MD5 | e1bdcaff734a94c37e6d5ef61520e0de |
|
BLAKE2b-256 | 2390b1801da3acb86c645b71df82cb8d8adf48879c1d11ac17f2adc88170af22 |
File details
Details for the file datacrunch-1.0.4-py3-none-any.whl
.
File metadata
- Download URL: datacrunch-1.0.4-py3-none-any.whl
- Upload date:
- Size: 35.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a50b385dbe228b61c7e03762648032b21aa9b1a41b67fbf843466180a7b6c677 |
|
MD5 | 80e2626c8978177378204badcdfa1ce4 |
|
BLAKE2b-256 | 628120fc2f7c54aac3cf04f7d85cea0f1c7bb15cd0cbebe7a8ecc2a80b1fab68 |