Skip to main content

README

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.

13.196.0

  • Fixed pandas package dependency
  • Improved formatting of source files

13.187.2

  • Fixed input check for delete_records
  • Added utility functions validate_graphql_response and response_to_dataframe

13.165.2

  • Fixed compatibility issue with pandas v2

13.162.0

  • Added option parse_arrays to get, which parses array-type data to Python lists
  • Added helper functions for csv array to/from Python list conversion
  • Fixed issue with reading columns of types LONG and LONG_ARRAY

13.158.2

  • Fixed problem with accidental conversion of integers to floats when null values are present
  • Add new helper function for data-to-CSV-output

13.84.2

  • Added: method export_schema for exporting a schema's metadata

13.77.1

  • Improved error handling in 'columns' filter in get method
  • Fixed asynchronous API calls in export
  • Fixed issue with 'equals' filter for references in get method
  • Fixed greater_than and smaller_than filters for LONG type values in get method
  • Renamed __prepare_unequal_filter to prepare_not_equals_filter and added NotImplementedError for certain data types
  • Fixed issue with incorrect column names in get_graphql
  • Removed default value None for 'name' in create_schema as schema name cannot be null
  • Fixed parameter include_demo_data in recreate_schema to default to False instead of None
  • Improved error handling when creating schema with non-existent template

13.75.1

  • Fixed: issue when running get_schema_metadata on a schema with insufficient permissions to see members
  • Added: methods get_schema_settings
  • Added: methods get_schema_members
  • Added: methods get_schema_roles

13.55.4

Added: method save_table. Replaces save_schema which is now deprecated.

13.50.0

Fixed: issue with loading table data from get_graphql method

13.40.4

Fixed: no longer convert NA-like strings to pandas' NaN, only do this for missing values (i.e. empty strings).

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

The Pyclient requires a Python installation with version 3.10 or higher. 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.10 -m venv venv

On Windows:

py -3.10 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

Test

Tests for the Pyclient have been created with the Pytest framework. In order to test the functionality of the Pyclient copy the '.env-example' file to '.env' and modify the parameters for the server you want to test on.

Then execute the following to run all the tests

(venv) molgenis-emx2/tools/pyclient$ pytest

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-13.196.1.tar.gz (33.7 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_pyclient-13.196.1-py3-none-any.whl (25.3 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for molgenis_emx2_pyclient-13.196.1.tar.gz
Algorithm Hash digest
SHA256 b1cfb30bcfa753623a7e1bb9a196f972e1f6b4f8d18aa444a5e2d317a3d7db4d
MD5 96488104df44f3b43b53cff22708578e
BLAKE2b-256 71e470d255f13120de377db259d6f9afc72f5bf8928c5f3757e694678958d02a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for molgenis_emx2_pyclient-13.196.1-py3-none-any.whl
Algorithm Hash digest
SHA256 21aeac7d103fd707ad7e271ee66c4842a6ca56bd5295202e043dd60f5de11f64
MD5 c7bb3004292276389ae4ba9d30af216d
BLAKE2b-256 bb790e9f8488506738045f6719dc37e38f34b0317158572da2be05bc8ee5cc2f

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

13.196.1 This release

2 files

13.187.2

2 files

13.165.2

2 files

13.162.0

2 files

13.158.2

2 files

13.84.2

2 files

13.77.1

2 files

13.75.1

2 files

13.55.4

2 files

13.50.0

2 files

13.40.4

2 files

11.61.2

2 files

11.57.0

2 files

11.47.1

2 files

11.23.0

2 files

11.22.0

2 files

11.20.6

2 files

11.11.1

2 files

11.8.0

2 files

10.109.3

2 files

10.98.0

2 files

10.92.1

2 files

10.72.1

2 files

10.67.0

2 files

10.48.9

2 files

10.48.0

2 files

10.47.2

2 files

10.47.1

2 files

10.47.0

2 files

10.39.0

2 files

10.13.1

2 files

8.225.1

2 files

8.225.0

2 files

8.224.6

2 files

8.224.5

2 files

8.224.4

2 files

8.224.3

2 files

8.224.2

2 files

8.224.1

2 files

8.224.0

2 files

8.223.7

2 files

8.223.6

2 files

8.223.5

2 files

8.223.4

2 files

8.223.3

2 files

8.223.2

2 files

8.223.1

2 files

8.223.0

2 files

8.222.1

2 files

8.222.0

2 files

8.221.3

2 files

8.221.2

2 files

8.221.1

2 files

8.221.0

2 files

8.220.5

2 files

8.220.4

2 files

8.220.3

2 files

8.220.2

2 files

8.220.1

2 files

8.220.0

2 files

8.219.0

2 files

8.218.4

2 files

8.218.3

2 files

8.218.2

2 files

8.218.1

2 files

8.218.0

2 files

8.217.1

2 files

8.217.0

2 files

8.216.3

2 files

8.216.2

2 files

8.216.1

2 files

8.216.0

2 files

8.215.0

2 files

8.214.3

2 files

8.214.2

2 files

8.214.1

2 files

8.214.0

2 files

8.213.30

2 files

8.213.29

2 files

8.213.28

2 files

8.213.27

2 files

8.213.26

2 files

8.213.25

2 files

8.213.24

2 files

8.213.23

2 files

8.213.22

2 files

8.213.21

2 files

8.213.20

2 files

8.213.19

2 files

8.213.18

2 files

8.213.17

2 files

8.213.16

2 files

8.213.15

2 files

8.213.14

2 files

8.213.13

2 files

8.213.12

2 files

8.213.11

2 files

8.213.10

2 files

8.213.9

2 files

8.213.8

2 files

8.213.7

2 files

8.213.6

2 files

8.213.5

2 files

8.213.4

2 files

8.213.3

2 files

8.213.2

2 files

8.213.1

2 files

8.213.0

2 files

8.212.0

2 files

8.210.3

2 files

8.210.2

2 files

8.210.1

2 files

8.210.0

2 files

8.209.5

2 files

8.209.4

2 files

8.209.3

2 files

8.209.2

2 files

8.209.1

2 files

8.209.0

2 files

8.208.1

2 files

8.208.0

2 files

8.207.2

2 files

8.207.1

2 files

8.207.0

2 files

8.206.1

2 files

8.206.0

2 files

8.205.0

2 files

8.204.0

2 files

8.203.0

2 files

8.202.3

2 files

8.202.2

2 files

8.202.1

2 files

8.202.0

2 files

8.201.0

2 files

8.200.4

2 files

8.200.2

2 files

8.200.1

2 files

8.200.0

2 files

8.199.8

2 files

8.199.7

2 files

8.199.6

2 files

8.199.5

2 files

8.199.4

2 files

8.199.3

2 files

8.199.2

2 files

8.199.1

2 files

8.199.0

2 files

8.198.4

2 files

8.198.3

2 files

8.198.2

2 files

8.197.0

2 files

8.196.0

2 files

8.195.2

2 files

0.2.0

2 files

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