Skip to main content

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:

import logging
import asyncio
import os
from molgenis_emx2.directory_client.directory_client import DirectorySession
from molgenis_emx2.directory_client.directory_client import NodeData

os.environ['NN_SCHEMA_PREFIX'] = "BBMRI"

# 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_node("NL")
        nl_staging_data: NodeData = session.get_staging_node_data(nl)
        nl_published_data: NodeData = session.get_published_node_data(nl)

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

    # Now you can use the NodeData objects as you wish
    for biobank in nl_published_data.biobanks.rows:
        print(biobank)

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. NB! Make sure that the version numbers in these file have single quotes. Always start with creating a new -dev0 version with major, minor or patch parameter depending on the release scope

(venv) $ ./bump-version.sh major
OR
(venv) $ ./bump-version.sh minor
OR
(venv) $ ./bump-version.sh patch

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

(venv) $ ./bump-version.sh build

Or if all is fine, create a new release version

(venv) $ ./bump-version.sh 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

When releasing a new version, don't forget to update CHANGELOG.md and, if applicable, README.md and AUTHORS.md.

Note

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

Metadata

Release files for molgenis-emx2-directory-client 1.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for molgenis-emx2-directory-client 1.6.1
File Size Uploaded Provenance Actions
molgenis_emx2_directory_client-1.6.1.tar.gz 80.0 kB Without provenance Details for molgenis_emx2_directory_client-1.6.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for molgenis-emx2-directory-client 1.6.1
File Interpreter ABI Platform Actions
molgenis_emx2_directory_client-1.6.1-py2.py3-none-any.whl Python 2, Python 3 none any Details for molgenis_emx2_directory_client-1.6.1-py2.py3-none-any.whl

Total release size: 118.3 kB

Release files / molgenis_emx2_directory_client-1.6.1.tar.gz

Download URL molgenis_emx2_directory_client-1.6.1.tar.gz
Size 80.0 kB
Tags Source
SHA-256 checksum
How to use checksums
0017c7046bd1eff4bfdab36faa5d4c84cf0bf50cf46c823c0c7cd501a8440ddf
BLAKE2b-256 checksum
How to use checksums
cb6de6e549b8b21b96732fd639c3743753ee3aef9fc91cac2cfb9c7144f7e166
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.7

Release files / molgenis_emx2_directory_client-1.6.1-py2.py3-none-any.whl

Download URL molgenis_emx2_directory_client-1.6.1-py2.py3-none-any.whl
Size 38.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
20929a091fde40436b73f96e65ed43aaeb9d45e8ce079c1e77da0b3cd7fcc6a2
BLAKE2b-256 checksum
How to use checksums
2b1e65de5493d7d39f0e620ce2697199aae8f72afef6db5ae7b8f8908370cff7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.7

Security for molgenis-emx2-directory-client 1.6.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page