Skip to main content

Python client for the Molgenis EMX2 API

Project description

The Molgenis EMX2 Pyclient is a Python package developed to be used for data management on Molgenis EMX2 servers. A detailed overview of the capabilities is presented in the MOLGENIS documentation.

Installation

The releases of the package are hosted at PyPI. The recommended way to install the latest version is through pip.

pip install molgenis-emx2-pyclient

Changelog

Releases of the Molgenis EMX2 Pyclient follow the release number of the accompanying release of the Molgenis EMX2 software. Therefore, releases of the Pyclient are less frequent than those of EMX2 and the latest version of the Pyclient may differ from the latest version of Molgenis EMX2.

11.61.2

Fixed: problem where the schema metadata could not be updated with upload_file and a molgenis.csv file

11.57.0

  • Added: feature 'truncate' to remove all entries from a table
  • Added: option to filter results of get method by columns
  • Added: method get_graphql implements the GraphQL API
  • Improved: added additional parsing for data returned from the CSV API to pandas DataFrame in get method
  • Fixed: log level was set to DEBUG without possibility to change this. The user can now set the log level again at their preferred level

11.47.1

Fixed: updated GraphQL queries to be in line with EMX2 database metadata

11.23.0

Added: an optional job argument to the Client initialization, allowing the Pyclient to run asynchronous methods within a job in EMX2."

11.11.1

Added: option to specify filename in method export and to return the exported data in a function

11.8.0

Breaking: introduced asynchronous methods. Users need to explicitly address the asynchronous methods

10.109.3

Added: the ability to use the Pyclient on an EMX2 instance running on a local machine.

10.98.0

Added: the option to filter the results obtained from the get method based on columns

10.92.1

Added: the method upload_file which allows the direct upload of files of multiple types to the API

10.72.1

Fixed: issue where NA values were not properly read in or returned by the API

10.48.9

Fixed: issue in managing data of a table where the table id differs from the table name

10.48.0

Added: option to save data from the get method as a pandas DataFrame

10.47.2

Fixed: exceptions for metadata classes Column and Schema

10.47.0

Added: metadata classes for Column, Table, Schema

10.13.1

Added: methods create_schema, delete_schema, update_schema, recreate_schema, get_schema_metadata

How to use

Within your Python project import the class Client and instantiate it as a context manager. Operations and queries can then be executed from within the context.

from molgenis_emx2_pyclient import Client

username = 'username'
password = '...'

with Client('https://example.molgeniscloud.org') as client:
    client.signin(username, password)

    # Retrieve signin information
    print(client.status)
    """ Output:
    Host: https://example.molgeniscloud.org
    Status: Signed in
    Schemas:
        CatalogueOntologies
        catalogue
        ExampleSchema
        ...
    Version: v10.10.1
    """
    
    # Retrieve data from a table on a schema
    data = client.get(schema='ExampleSchema', table='Cohorts')
    
    # Create a new schema on the server
    client.create_schema(name='New Schema')
    
    # Delete a schema from the server
    client.delete_schema(name='New Schema')

Instead of signing in with a username and password the client can also be used while authorized by a (temporary) token that is generated on the server. See the MOLGENIS documentation for generating tokens

from molgenis_emx2_pyclient import Client

token = '...'

with Client('https://example.molgeniscloud.org', token=token) as client:

    # Retrieve signin information
    print(client.status)
    """ Output:
    Host: https://example.molgeniscloud.org
    User: token
    Status: session-less
    Schemas:
        CatalogueOntologies
        catalogue
        ExampleSchema
        ...
    Version: v10.32.1
    """
    
    ...
    ...

Development

Clone the molgenis-emx2 repository from GitHub

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

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

Create a virtual Python environment

On macOS:

python -m venv venv

On Linux:

python3.11 -m venv venv

On Windows:

py -3.11 venv venv

Activate the virtual environment

On macOS and Linux:

source venv/bin/activate

On Windows:

.venv\Scripts\activate.bat

Install the script dependencies

pip install -r requirements.txt

Build

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

(venv) $ pip install build

(venv) $ python -m build

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

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

molgenis_emx2_pyclient-11.61.2.tar.gz (22.0 kB view details)

Uploaded Source

Built Distribution

molgenis_emx2_pyclient-11.61.2-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

Details for the file molgenis_emx2_pyclient-11.61.2.tar.gz.

File metadata

  • Download URL: molgenis_emx2_pyclient-11.61.2.tar.gz
  • Upload date:
  • Size: 22.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.2

File hashes

Hashes for molgenis_emx2_pyclient-11.61.2.tar.gz
Algorithm Hash digest
SHA256 ff3f2b1bb21fbb9beb1bf169ce1d8a77ac55b71fe66fd5c3411ae99118b64fe0
MD5 d13c8629c7eba3f7e9d92000ff2a9b72
BLAKE2b-256 532fcbd151b92bae2d622fe7ba5dafc971b61f71c864a3100dd24531c9209a97

See more details on using hashes here.

File details

Details for the file molgenis_emx2_pyclient-11.61.2-py3-none-any.whl.

File metadata

File hashes

Hashes for molgenis_emx2_pyclient-11.61.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3b1204ff114bf89a9a55dddc8a84df86a0c8e7c027ed621535f0fe0dc13f2282
MD5 dd08770a3e9d257e882ae2b81b966e7c
BLAKE2b-256 09646ef0229013e696066a9c1e176327fa7066674eec66578bc27e312fc96f48

See more details on using hashes here.

Supported by

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