Skip to main content

SQLAlchemy ORM models for the ISPyB database

Project description

This provides a set of SQLAlchemy ORM models for the ISPyB database.

Installation

Install from pypi ispyb-models:

pip install ispyb-models

Basic Usage

from ispyb import models

dataCollection = models.DataCollection(
    ...
)

ses.add(dataCollection)
ses.commit()

...

datacollections = (
    ses.query(
        models.DataCollection
    ).filter(models.DataCollection.dataCollectionId == 1)
    ).first()
)

Generate a new version

To update the models you need to run the workflow Update Models through GitHub Actions panel. This will create a new branch with models matching the latest DB release and create a pull request for merge this branch into main. Before merging there are some things you need to do:

  • Make sure py-ispyb tests still pass with these new models
  • Update HISTORY.md to reflect the changes
  • Bump version number with bump2version

⚠️ Do not edit the output file yourself

The resulting _auto_db_schema.py should not be edited (other than automatic formatting with black or sorting of imports with isort). All models are imported into and accessed via the __init__.py. Any modifications, e.g. injecting additional relationships between models should be done here.

⚠️ [for local test] Manually update the DB schema

Checkout the specific tag for a given ispyb-database version:

$ git clone -b v1.18.1 https://github.com/ispyb/ispyb-database.git
$ # or, if you have an existing copy of the repository:
$ git checkout v1.18.1

Apply the schema patch in patches/circular_references.patch to avoid circular foreign key references:

$ patch -p1 < ispyb-models/patches/circular_references.patch

Then run the ispyb-database build.sh script to generate the database:

$ sh build.sh

Generate the models with sqlacodegen in src/ispyb/models/:

. generate_models.sh

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ispyb_models_pyispyb-1.2.7.tar.gz (37.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ispyb_models_pyispyb-1.2.7-py3-none-any.whl (36.8 kB view details)

Uploaded Python 3

File details

Details for the file ispyb_models_pyispyb-1.2.7.tar.gz.

File metadata

  • Download URL: ispyb_models_pyispyb-1.2.7.tar.gz
  • Upload date:
  • Size: 37.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ispyb_models_pyispyb-1.2.7.tar.gz
Algorithm Hash digest
SHA256 dec3db6d71665433691361691513fa60cf2f5b676752bed7837e207909768e3b
MD5 5bf9cd49fcc78f169fec160ac331c1fc
BLAKE2b-256 9655f1c954c0083c53ad76402b3c91d293ead0cf7b310c841ff17f1e2a75b8c8

See more details on using hashes here.

File details

Details for the file ispyb_models_pyispyb-1.2.7-py3-none-any.whl.

File metadata

File hashes

Hashes for ispyb_models_pyispyb-1.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 b5d05227dbd33478522d3490b848d35c7f2a8d2b965783d11837a58c6591633e
MD5 04f7e1ff1b076051f7122687d8db58f3
BLAKE2b-256 6a244b12399365be2d96349621e4f35f05d638c7320d9887312a9bc7b28424d7

See more details on using hashes here.

Supported by

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