Skip to main content

Blue Core BIBFRAME Data Models

Project description

Blue Core Data Models

The Blue Core Data Models are used in Blue Core API and in the Blue Core Workflows services.

🐳 Run Postgres with Docker

To run the Postgres with the Blue Core Database, run the following command from this directory:

docker run --name bluecore_db -e POSTGRES_USER=airflow -e POSTGRES_PASSWORD=airflow -v ./create-db.sql:/docker-entrypoint-initdb.d/create_database.sql -p 5432:5432 postgres:17


🛠️ Installing

  • Install via pip: pip install bluecore-models
  • Install via uv: uv add bluecore-models

🗄️ Database Management

The SQLAlchemy Object Relational Mapper (ORM) is used to create the Bluecore database models.

erDiagram
    ResourceBase ||--o{ Instance : "has"
    ResourceBase ||--o{ Work : "has"
    ResourceBase ||--o{ OtherResource : "has"
    ResourceBase ||--o{ ResourceBibframeClass : "has classes"
    ResourceBase ||--o{ Version : "has versions"
    ResourceBase ||--o{ BibframeOtherResources : "has other resources"

    Work ||--o{ Instance : "has"
    
    BibframeClass ||--o{ ResourceBibframeClass : "classifies"
    
    OtherResource ||--o{ BibframeOtherResources : "links to"

Database Migrations with Alembic

The Alembic database migration package is used to manage database changes with the Bluecore Data models.

To create a new migration, ensure that the Postgres database is available and then run:

  • uv run alembic revision --autogenerate -m "{short message describing change}

A new migration script will be created in the bluecore_store_migration directory. Be sure to add the new script to the repository with git.

Applying Migrations

To apply all of the migrations, run the following command:

  • uv run alembic upgrade head

🧹 Linter for Python

bluecore-models uses ruff

  • uv run ruff check

To auto-fix errors in both (where possible):

  • uv run ruff check --fix

Check formatting differences without changing files:

  • uv run ruff format --diff

Apply Ruff's code formatting:

  • uv run ruff format

🧪 Running Tests

The test suite is written using pytest and is executed via uv. All tests are located in the tests/ directory.

Run All Tests

uv run pytest

Run a specific test file

uv run pytest tests/test_models.py

Run a specific test function

uv run pytest tests/test_models.py -k test_updated_instance

Show output (prints/logs) during test execution

uv run pytest -s

💡 Make sure your virtual environment is activated and dependencies are installed with uv before running tests.


⬆️ Publishing to Pypi

To publish the bluecore-models to pypi, the following steps need to be taken.

  1. Update the version in pyproject.toml either in a feature branch PR or in a dedicated PR.
  2. After the PR is merged, create a tagged release using the same version (prepended with a v i.e. v0.4.2.
  3. Once the tagged release is saved, the Publish to PyPi Github Action should then publish the release to PyPi.

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

bluecore_models-0.11.3.tar.gz (45.8 kB view details)

Uploaded Source

Built Distribution

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

bluecore_models-0.11.3-py3-none-any.whl (26.4 kB view details)

Uploaded Python 3

File details

Details for the file bluecore_models-0.11.3.tar.gz.

File metadata

  • Download URL: bluecore_models-0.11.3.tar.gz
  • Upload date:
  • Size: 45.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for bluecore_models-0.11.3.tar.gz
Algorithm Hash digest
SHA256 5ed0d92dfc78c0e57f1034d178502f8307fb88b95963b9e5b768df7f6ffd56b9
MD5 d11314c8841214382772cf4586b62ee9
BLAKE2b-256 d5cdc0390077f6bdbd016310dc0643bd566f469caf894d4313e4aa5cd1db4302

See more details on using hashes here.

File details

Details for the file bluecore_models-0.11.3-py3-none-any.whl.

File metadata

  • Download URL: bluecore_models-0.11.3-py3-none-any.whl
  • Upload date:
  • Size: 26.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for bluecore_models-0.11.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e515ca4932e51075dc1f7838e5120caf866c30858c2d73b4e55f9e6c773b77b0
MD5 b0696d9fdbbb8f6a45a2824cdcae524d
BLAKE2b-256 2a341b7d1b4acc08689595471e933dfd680614c68feeb5363da5e0e10e9ea620

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