Package -

Build Status Coverage Status PyPI version Development status Python versions

ISPyB API

This package provides a way to write acquisition and processing results into an ISPyB database. Currently, the only supported method is through stored procedures, but the package is designed to allow for other methods as well, such
as webservices.

Requirements

  • Python 2.7 or 3.x
  • The mysql.connector Python package.
  • An ISPyB database on either MariaDB 10.0+ or MySQL 5.6+
  • If binary logging is enabled in the DB system, then execute this before importing the test schema: set global log_bin_trust_function_creators=ON;

Installation

From the source core:

python setup.py clean --all
python setup.py bdist_wheel
pip2.7 install --user dist/ispyb-3.0.0-py2-none-any.whl

From PyPI:

pip2.7 install --user ispyb

(The --user option installs the package for your own user only.)

Examples

import ispyb.factory
from datetime import datetime

# Get a connection and data area objects
conn = ispyb.open('config.cfg')
core = ispyb.factory.create_data_area(ispyb.factory.DataAreaType.CORE, conn)
mxacquisition = ispyb.factory.create_data_area(ispyb.factory.DataAreaType.MXACQUISITION, conn)

# Find the id for a given visit
sessionid = core.retrieve_visit_id('cm14451-2')

# Create a new data collection group entry:
params = mxacquisition.get_data_collection_group_params()
params['parentid'] = sessionid
params['experimenttype'] = 'OSC'
params['starttime'] = datetime.strptime('2017-09-21 13:00:00', '%Y-%m-%d %H:%M:%S')
params['endtime'] = datetime.strptime('2017-09-21 13:00:10', '%Y-%m-%d %H:%M:%S')
params['comments'] = 'This is a test of data collection group.'
dcg_id = mxacquisition.insert_data_collection_group(list(params.values()))
conn.disconnect()
print("dcg_id: %i" % dcg_id)

See docs/pipeline2ispyb.py for a more detailed example of how to use the package.

Tests

Unit tests (pytests) are run by Travis against a real MariaDB ISPyB database schema.

Github

link
Stars:

Advertisement