Crux Informatics API client library
Project description
Crux Python Client
A Python library for interacting with the Crux platform.
The aim of this module is to be a Pythonic way to use the Crux API reliably. It covers client functionality including scanning subscriptions, getting delivery status, and downloading files.
Python 3.6+ is supported.
See crux-python.cruxinformatics.com for detailed documentation.
Installation
Install a recent version of Python, and a Python dependency and virtual environment manager like pipenv. On macOS run:
brew install python
brew install pipenv
Install crux
from PyPI in a virtual environment, and get a shell in that environment:
mkdir -p crux_example
cd crux_example
pipenv install "crux==1.3"
pipenv shell
Getting Started
Create a file, like example.py, and use the crux
module:
from crux import Crux
conn = Crux()
identity = conn.whoami()
print("I am", identity.email)
Run the script:
HISTCONTROL=ignoreboth
export CRUX_API_KEY='YOUR_API_KEY'
python3 example.py
See the installation and authentication documentation for details.
Development
Python 3.7 is required for development, which can be installed with brew install python
. For heavy development work, every supported version of Python must be installed, see the pyenv documentation below.
Pipenv should be used to manage dependancies during development.
- Install Pipenv, on macOS run
brew install pipenv
git clone https://github.com/cruxinformatics/crux-python.git
cd crux-python
pipenv install --dev
to install the dependanciespipenv shell
to get a shell in the virtual environment
Multiple Python versions
To be able to run tests against all supported Python versions, you must have all supported Python versions installed. The test runner will look for binaries called python2.7
, python3.5
, python3.6
, etc. There are multiple ways to install Python versions, we'll document using pyenv.
-
brew install pyenv
to install -
Put
eval "$(pyenv init -)"
towards the end of the shell configuration file (~/.bashrc or ~/.bash_profile), because it manipulates$PATH
, for example:echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bashrc
-
Open a new Terminal to get an updated shell
-
Install required/missing Python versions (this assumes you have Python 2.7 already installed, otherwise install it too):
pyenv install 3.5.6 pyenv install 3.6.6 pyenv install 3.7.0
-
pyenv global system 3.5.6 3.6.6 3.7.0
to make all the Python versions available -
If you already have pipenv virtual environment, remove it with
pipenv --rm
so it detects the Python versions -
pipenv install --dev
to install all the dependancies -
pipenv shell
to get a shell in the virtual environment
Running tests
We use Nox to automate running tests, and use make
to automate running some commands. These commands should be run within a shell created with pipenv shell
.
# Run all tests: lint, unit, format_check
make test
# Or
nox
# Run only lint checks
make lint
# Or
nox -s lint
# Run unit tests against all available Python versions
make unit
# Or
nox -s unit
# Run integration tests agains all available Python versions
export CRUX_API_KEY="12345"
export CRUX_API_HOST="https://api.example.com"
make integration
# Or
export CRUX_API_KEY="12345"
export CRUX_API_HOST="https://api.example.com"
nox --s integration
# Check formatting
make format_check
# Or
nox -s format_check
# List all commands available
make
# Or
nox -l
# Run unit test only against Python 3.7
nox -s unit-3.7
# Reformat code
make format
# Generate Sphinx HTML documentation
make docs
Running test scripts
Manual testing scripts could be found at tests/regression
.
In order to run one, i.e. client.py
, follow the steps:
- copy corresponding
.env.dist
file as.env
file (if you plan to runclient.py
, copyclient.env.dist
asclient.env
) - fill variables within
.env
file - launch the script (while being in the
tests/regression
folder, executepython client.py
)
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 crux-1.3.tar.gz
.
File metadata
- Download URL: crux-1.3.tar.gz
- Upload date:
- Size: 30.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/67.4.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c42b5bb22963aa6652bad7d2235ecfe77c71a34293df3446277b2be06590e56 |
|
MD5 | a9c5f639df4900062132c2cb3262d4ad |
|
BLAKE2b-256 | bf2b38ed242f34aab3745e6838bcd566122312c0d67b34fcf9e49d994e8b4041 |
File details
Details for the file crux-1.3-py3-none-any.whl
.
File metadata
- Download URL: crux-1.3-py3-none-any.whl
- Upload date:
- Size: 37.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/67.4.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3bb4cdc2bbeff716bd8b850d5f89b7e2aaf67f5bef120d474a65016497909562 |
|
MD5 | 4fc2da4f0c48cf151034ed878bbc5224 |
|
BLAKE2b-256 | 689c0da76d23c8c85ea9b9d26524c5326a8d50b002ccb7b583b9e789c13509b9 |