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 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.1.0rc1.tar.gz (45.3 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.1.0rc1-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file ec_data_models-0.1.0rc1.tar.gz.

File metadata

  • Download URL: ec_data_models-0.1.0rc1.tar.gz
  • Upload date:
  • Size: 45.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.13

File hashes

Hashes for ec_data_models-0.1.0rc1.tar.gz
Algorithm Hash digest
SHA256 2e2074bf7462c7943804b2fea6397fba84d53b97b752df357e6f2dc7df4b4e5d
MD5 b3cc13e1123e3df7c5ce6dc9ac7e394c
BLAKE2b-256 627f9b48b6e10975633f1bfffbe9147d8221cfcb3fc5ce41fa43b2b996e2de5d

See more details on using hashes here.

File details

Details for the file ec_data_models-0.1.0rc1-py3-none-any.whl.

File metadata

File hashes

Hashes for ec_data_models-0.1.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 fd5f0c555ee4a57d88b6be085a7fbeda2467eb26e27c3a5076ac253b0c6f6936
MD5 04a71949bae70b3848e2c325ed4e2681
BLAKE2b-256 0b32d1c67f1eb73c71edb34bed361e7e350b75bf3facaa93df795246a02f69e0

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