https://github.com/diamondlightsource/ispyb-api
Package for writing acquisition and processing results into an ISPyB database
https://github.com/diamondlightsource/ispyb-api
database ispyb mariadb mysql python stored-procedures
Last synced: 3 months ago
JSON representation
Package for writing acquisition and processing results into an ISPyB database
- Host: GitHub
- URL: https://github.com/diamondlightsource/ispyb-api
- Owner: DiamondLightSource
- License: apache-2.0
- Created: 2017-03-22T21:05:44.000Z (about 8 years ago)
- Default Branch: main
- Last Pushed: 2025-02-18T11:39:54.000Z (3 months ago)
- Last Synced: 2025-02-18T12:36:11.495Z (3 months ago)
- Topics: database, ispyb, mariadb, mysql, python, stored-procedures
- Language: Python
- Homepage:
- Size: 1.62 MB
- Stars: 7
- Watchers: 13
- Forks: 11
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.rst
- Contributing: docs/contributing.rst
- License: LICENSE.md
Awesome Lists containing this project
README
[](https://pypi.python.org/pypi/ispyb)
[](https://anaconda.org/conda-forge/ispyb)
[](https://pypi.python.org/pypi/ispyb)
[](https://pypi.python.org/pypi/ispyb)[](https://dev.azure.com/DLS-tooling/ispyb/\_build/latest?definitionId=2)
[](https://coveralls.io/github/DiamondLightSource/ispyb-api?branch=main)
[](https://ispyb.readthedocs.io/en/latest/?badge=latest)

[](https://lgtm.com/projects/g/DiamondLightSource/ispyb-api/context:python)
[](https://lgtm.com/projects/g/DiamondLightSource/ispyb-api/alerts/)# 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.### Documentation
Please see https://ispyb.readthedocs.io.### Requirements
* Python 3.7, 3.8, 3.9, 3.10, 3.11
* The MySQL Connector/Python package.
* MariaDB 10.0+ or MySQL 5.6+, but we recommend MariaDB 10.2 or later.
* An ISPyB database installed on the above. See the [ispyb-database](https://github.com/DiamondLightSource/ispyb-database) repository for details.### Installation
From PyPI:
```bash
pip install --user ispyb
```
The `--user` option installs the package for your own user only.
You can leave it out if you want to install the package system-wide.To install the source code in editable mode for development:
```bash
git clone [email protected]:DiamondLightSource/ispyb-api.git
pip install --user -e ispyb-api
```### Examples
```python
import ispyb
from datetime import datetime# Get a connection and data area objects
with ispyb.open("config.cfg") as conn:
core = conn.core
mx_acquisition = conn.mx_acquisition# Find the id for a given visit
sessionid = core.retrieve_visit_id("cm14451-2")# Create a new data collection group entry:
params = mx_acquisition.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 = mx_acquisition.insert_data_collection_group(list(params.values()))
print("dcg_id: %i" % dcg_id)
```See [`docs/pipeline2ispyb.py`](https://github.com/DiamondLightSource/ispyb-api/blob/main/docs/pipeline2ispyb.py) for a more detailed example of how to use the package.
### Tests
Unit tests (pytests) are run automatically by Azure against a real MariaDB ISPyB database schema. You can also run the tests in your Development environment if you have an ISPyB database.