Skip to main content

BIGSdb Python Toolkit

Project description

BIGSdb_Python_Toolkit

Python libraries for interacting with BIGSdb databases.

The modules included in this package enable scripts to be written in Python that can query and update BIGSdb databases using similar method calls as used in the main BIGSdb Perl package.

A script object that is passed a database config name will automatically parse the BIGSdb configuration and database configuration files, and set up the required database connections. Methods for querying databases are included in the Datastore module. More methods will be added as required to replicate the Perl BIGSdb libraries.

BIGSdb plugins can also now be written in Python so that additional analysis functionality can be added to the platform without having to write Perl code.

Installation

It is recommended that you install this in a virtual environment, e.g.

python -m venv .venv
source .venv/bin/activate

Install with pip:

pip install bigsdb

You can de-activate the virtual environment with:

deactivate

You can also clone the git repository and install dependencies. You will need to clone the repository to access various scripts needed to enable plugins.

git clone https://github.com/kjolley/BIGSdb_Python_Toolkit.git
cd BIGSdb_Python_Toolkit
pip install -r requirements.txt

Initiating plugins

BIGSdb needs to know about any plugins. In order to enable this, there is a script called create_plugin_list.py found in the scripts directory. Run this and save the output to a file called python_plugins.json and copy this to /etc/bigsdb. This contains everything that BIGSdb needs to know about each plugin including descriptive attributes, Javascript libraries needed and any inline Javascript that should be added to the page.

python create_plugin_list.py --plugin_dir ../sample_plugins/

BIGSdb will call a script called plugin_runner.py and it needs to know the location of this as well as the location of the Python plugins. Set the python_plugin_runner_path and python_plugin_dir in bigsdb.conf, e.g.

python_plugin_runner_path=/home/bigsdb/BIGSdb_Python_Toolkit/.venv/bin/python /home/bigsdb/BIGSdb_Python_Toolkit/plugin_runner.py
python_plugin_dir=/home/bigsdb/BIGSdb_Python_Toolkit/sample_plugins

Tests

Many of the tests involve creating and dropping a test database. The user running the tests must have permissions set to enable this. They will also need to be able to modify tables which may be owned by the apache user. If running as the bigsdb user, run the following to set these permissions:

psql
ALTER USER bigsdb createdb;
ALTER USER bigsdb createrole;
GRANT postgres TO bigsdb;
GRANT apache TO bigsdb;

Tests can be run from the tests/ directory with the following:

python -m unittest discover

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

bigsdb-0.0.3.tar.gz (62.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bigsdb-0.0.3-py3-none-any.whl (53.0 kB view details)

Uploaded Python 3

File details

Details for the file bigsdb-0.0.3.tar.gz.

File metadata

  • Download URL: bigsdb-0.0.3.tar.gz
  • Upload date:
  • Size: 62.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.4

File hashes

Hashes for bigsdb-0.0.3.tar.gz
Algorithm Hash digest
SHA256 127a77df264b6878eae300c2da2689739c48b9d8a7cbb9d256a105ce11e61990
MD5 38e08d56fa2031bc75617bad8c5636a0
BLAKE2b-256 5d7a7a60c2e7ccf094f148b2007d15653096b29483e40ca1cce5dcdc39b2ba85

See more details on using hashes here.

File details

Details for the file bigsdb-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: bigsdb-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 53.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.4

File hashes

Hashes for bigsdb-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b6b040ba8da24ef4d700d58f2bfee92aee2557486ae8ec49aca576b625f17947
MD5 939dec547ca4086e01619cab32f438a0
BLAKE2b-256 77476159762a3fea08bceee89ef01d7d591f677e688d8ac70638f49ff29b4eab

See more details on using hashes here.

Supported by

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