Skip to main content

MOLGENIS EMX2 Python tooling for a BBMRI Biobank Directory

Project description

molgenis-emx2-directory-client

MOLGENIS EMX2 Python tooling for a BBMRI Biobank Directory

Description

This library contains tools for the MOLGENIS EMX2 BBMRI Biobank Directory that help with staging and publishing the data of the national nodes. Staging is the process of copying data from a national node's external server (for example BBMRI-NL) to the staging area on the Directory server. Not all national nodes have external servers; these do not need to be staged. Publishing is the process of copying and combining the data from the staging areas to the public combined tables of the Directory.

Usage

These tools can be used as a library in a script. Start by installing the library with pip install molgenis-emx2-directory-client.

For an example of how to use this library to stage and publish nodes, see dev.py.

If you just want to retrieve the data of a node for another purpose, you can use the DirectorySession and ExternalServerSession directly:

from molgenis-emx2.directory-client import DirectorySession, ExternalServerSession
from molgenis-emx2.directory-client import NodeData

# Get the staging and published data of NL from the directory
async def get_data():
    # Set up the logger
    logging.basicConfig(level="INFO", format=" %(levelname)s: %(name)s: %(message)s")
    logging.getLogger("requests").setLevel(logging.WARNING)
    logging.getLogger("urllib3").setLevel(logging.WARNING)

    # Login to the directory with a DirectorySession
    with DirectorySession(url="<DIRECTORY_URL>", schema="<DIRECTORY_SCHEMA>") as session:
        # Apply the 'signin' method with the username and password
        session.signin(username, password)

        nl = session.get_external_node("NL")
        nl_staging_data: NodeData = session.get_staging_node_data(nl)
        nl_published_data: NodeData = session.get_published_node_data(nl)

        # Get the data from the external server of NL
        external_session = ExternalServerSession(nl)
        nl_external_data: NodeData = external_session.get_node_data()

    # Now you can use the NodeData objects as you wish
    for person in nl_external_data.persons.rows:
        print(person)

if __name__ == "__main__":
    asyncio.run(get_data())

For developers

Clone the molgenis-emx2 repository from GitHub

git clone git@github.com:molgenis/molgenis-emx2.git

Change the working directory to .../tools/directory

This project uses pre-commit and pipenv for the development workflow. Install pre-commit and pipenv if you haven't already:

pip install pre-commit
pip install pipenv

Install the git commit hooks:

pre-commit install

Create an environment and install the package including all (dev) dependencies:

pipenv install --dev

Enter the environment:

pipenv shell

Build and run the tests:

tox

Build

Before building the source, the package bumpversion needs to be installed.

(venv) $ pip install bumpversion

Bump the source version. This will update setup.py and init.py Always start with creating a new -dev0 version with major, minor or patch parameter
depending on the release scope

(venv) $ ./bumpversion major
OR
(venv) $ ./bumpversion minor
OR
(venv) $ ./bumpversion patch

Then either create a new dev-version in case any changes have been made

(venv) $ ./bumpversion build

Or if all is fine, create a new release version

(venv) $ ./bumpversion release

After bumping the version, the source can be build

(venv) $ tox -e build

Then dev (and release) versions of the source can be uploaded to testpypi

(venv) $ tox -e publish -- --skip-existing --repository testpypi

And release versions of the source can be uploaded to pypi

(venv) $ tox -e publish -- --skip-existing --repository pypi

Or install locally

(venv) $ pip install dist/molgenis_emx2_pyclient*.whl

Note

This project has been set up using PyScaffold 4.0.2. For details and usage information on PyScaffold see https://pyscaffold.org/.

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

molgenis_emx2_directory_client-1.2.0.tar.gz (67.1 kB view details)

Uploaded Source

Built Distribution

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

molgenis_emx2_directory_client-1.2.0-py2.py3-none-any.whl (35.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file molgenis_emx2_directory_client-1.2.0.tar.gz.

File metadata

File hashes

Hashes for molgenis_emx2_directory_client-1.2.0.tar.gz
Algorithm Hash digest
SHA256 ffab6c30114f72d0d58f4ed81da41ffd1ee715eeba2b5ae5998098b9ea5cc12d
MD5 e611e37732819d7593d1cc6179f420ef
BLAKE2b-256 30631496dcc92a9f6881d72440e98dbfbbb15631780cd763d258449206933331

See more details on using hashes here.

File details

Details for the file molgenis_emx2_directory_client-1.2.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for molgenis_emx2_directory_client-1.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c9051dbbaf7fe2a738d1cd7e42da992dfad1ae3d9f522c453fe04b62a5a5d463
MD5 872f9c5aeceed02e6867fa7cf9cf4070
BLAKE2b-256 29c3c0e1c8debbd5dad0a2d6c3b90ae84681a927218b1a0a4782c27abc9a4de5

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