Skip to main content

Repository for SQLAlchemy models with Alembic migrations

Project description

PyPI version add more when repo is public

Data-Models

  • Repository for managing the shared SQLAlchemy / SQLModel Data Models and Alembic migrations
  • This repo gets automatically build, tested and published
  • Might be renamed to include other shared backend code later
  • The Models are used in:
    • Pipelines & Automations
    • Internal websites API
    • Helpertool

  • For generel explanation of tooling & setup see our notion page

Developer Setup

1. Prerequisites

This project uses uv for package and environment management

Install uv:

  • macOS / Linux:
    curl -LsSf https://astral.sh/uv/install.sh | sh
    
  • Windows (PowerShell):
    irm https://astral.sh/uv/install.ps1 | iex
    

2. Initial Project Setup

These commands will set up your virtual environment, install dependencies, and enable automated quality checks.

# 1. Create a virtual environment in a .venv directory
uv venv

# 2. Activate the virtual environment
#    macOS / Linux
source .venv/bin/activate
#    Windows (PowerShell)
.venv\Scripts\Activate.ps1

# 3. Install all dependencies in "editable" mode
uv pip install -e ".[dev]"

# 4. Install the pre-commit hooks for automated quality checks
pre-commit install

Your environment is now ready. The editable install (-e) means that changes you make to the source code are immediately available without reinstalling.

3. VSCode Integration

To get the best experience (live error-checking, auto-formatting), configure VSCode to use the project's environment.

  1. Install Recommended Extensions:

    • Python (by Microsoft)
    • Ruff (by Astral)
    • Mypy Type Checker (by Microsoft)
  2. Select the Python Interpreter:

    • Open the Command Palette: Ctrl+Shift+P (or Cmd+Shift+P on Mac).
    • Run the Python: Select Interpreter command.
    • Choose the interpreter located in the ./.venv directory. This is critical for all editor integrations to work.

Once the interpreter is selected, our project's .vscode/settings.json file will automatically enable formatting on save, import sorting, and type-checking.

4. Running Tests

To run the full test suite, simply use pytest:

pytest

If you also want to run tests against a local postgreSQL instance, create a .env and (for now) set MAIN_DB_URL to you local db connection string. The db will get altered! You can run the the postgreSQL test suite with

pytest -m postgres

If you run into "command not found" for pytest, install dev requirements first in your project's virtualenv:

PowerShell:

.venv\Scripts\Activate.ps1
uv pip install -e ".[dev]"
pytest -q

5. Formatting and Linting

  • If you want to invoke the pre-commit formatting and type-checking explicitly, activate the environment and run
pre-commit run --all-files
# For ruff hecks only
ruff check .
ruff format
# For MyPy static type checking only
mypy .

Local Development Across Projects

Often, you'll need to test changes from this data-models repository in another service (e.g., Internal-API) before publishing a new version. Here’s how to link them locally.

Scenario: You've made changes in data-models and want Internal-API to use them instantly.

  1. Navigate to your other project's directory:

    cd ../Internal-API
    
  2. Activate its virtual environment:

    source .venv/bin/activate
    
  3. Uninstall any existing version of data-models: This prevents conflicts with a version installed from the registry.

    uv pip uninstall data-models
    
  4. Install your local data-models in editable mode using a relative path:

    # This command creates a direct link to your local data-models source code
    uv pip install -e ../data-models
    

Now, Internal-API is linked to your local data-models folder. Any code you change in data-models will be immediately reflected when you run Internal-API.

Deployment

  • This Repo manages all DB migrations to the main DB and applies them on pushes to main
  • Best practice would be
    • blue/green testing & only implementing backwards compatible migrations with legacy fields being deprecated later
    • Integration tests on staging version

  • Trigger rebuilds & deployment of downstream applications on pushes to main

Docs

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

ec_data_models-0.2.0.tar.gz (59.4 kB view details)

Uploaded Source

Built Distribution

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

ec_data_models-0.2.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file ec_data_models-0.2.0.tar.gz.

File metadata

  • Download URL: ec_data_models-0.2.0.tar.gz
  • Upload date:
  • Size: 59.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ec_data_models-0.2.0.tar.gz
Algorithm Hash digest
SHA256 20c2324b25e1bac13b2a7d22975e28d1c6fb32ea515f722b2129fc38d6744734
MD5 91834934bff5f7aaae946ea2d1cdd1fe
BLAKE2b-256 04b1f9ef1952980266b4981c351e78fe3e1803d6f780fb6d3d4709131af68d9e

See more details on using hashes here.

File details

Details for the file ec_data_models-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: ec_data_models-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ec_data_models-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d24bd109749f63542f284521dcbb8c99a307bacaa8860c908475d792074ad902
MD5 b61d64a3e2de3282633b8237eab9c836
BLAKE2b-256 8efdd99894b53710b980f15bff84e445f176a3d060987115144d31c143d5642f

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