Skip to main content

A common data model for the eflips family of electric vehicle simulation & optimization tools.

Project description

Unit Tests Code style: black

eflips-model


Part of the eFLIPS/simBA list of projects.


This repository contains both the reference specification, an SQLALchemy implementation and a usage example of the eFLIPS database.

Reference Specification

The reference specification is located (for now) in the huge PDF file schema.pdf. It is a UML diagram of the database schema. The diagram was created using OmniGraffle (proprietary).

SQLAlchemy Implementation

The SQLAlchemy implementation is located in the eflips/model directory. It is a Python package that contains the SQLAlchemy models and the database migration scripts. The package is structured as follows:

Installation

Releases of the package will be made available on https://pypi.org/. As such, it is installable with pip install eflips-model. However, it should be used by including it in other packages as a dependency. The versioning scheme is semantic versioning. This means that:

  • patch releases (e.g. 1.0.0 to 1.0.1) are backwards compatible bug fixes, without schama changes
  • minor releases (e.g. 1.0.0 to 1.1.0) are backwards compatible feature additions, with the schema changes being optional
  • major releases (e.g. 1.0.0 to 2.0.0) are backwards incompatible changes, with the schema changes being mandatory

Supported database backends are

  • PostgreSQL with the PostGIS extension (CREATE EXTENSION postgis;) and btree_gist (CREATE EXTENSION btree_gist;)

Usage

This package is not expected to be used directly. It is a dependency of the eflips-* packages.

This package utilizes GIS extensions through GeoAlchemy. However, we are not handling geometry on the python side in any special way. When developing a paclage that uses eflips-model, you will probably additionally need Shapely and pyProj, which are not pure python packages and require additional dependencies to be installed on the system.

Schema updates

The schema updates are handled by Alembic. The migration scripts are located in the eflips/model/migrations directory. To create a new migration script, execute the following commands in the root directory of the repository:

cd eflips/model
alembic revision --autogenerate -m "vx.y.z"
# Edit the migration script, as necessary

Creating a migration script is required for every change to the database schema, which should also correspond to a minor or major version change in the package version.

To apply the migration scripts, execute the following command in the root directory of the repository:

cd eflips/model
export DATABASE_URL=postgresql://user:pass@hostname:port/dbname # Change to your database URL
alembic upgrade head

Testing

We use pytest for testing. The tests are located in the tests directory. To run the tests, execute the following command in the root directory of the repository (after installing the dev dependencies):


NOTE: Be aware that the tests will clear the database specified in the DATABASE_URL environment variable. Make sure that you are not using a database that you want to keep.


# Change to your database URL
export DATABASE_URL=postgresql://user:pass@hostname:port/dbname 
pytest

Documentation

Documentation is available on Read the Docs.

To locally create the documentaiton from the docstrings in the code using sphinx-autoapi, you can create the documentation execute the following command in the root directory of the repository:

sphinx-build doc/ doc/_build -W

Development

We utilize the GitHub Flow branching structure. This means that the main branch is always deployable and that all development happens in feature branches. The feature branches are merged into main via pull requests. We utilize the semantic versioning scheme for versioning.

Dependencies are managed using poetry. To install the dependencies, execute the following command in the root directory of the repository:

poetry install

We use black for code formatting. You can use black . to format the code.

We use MyPy for static type checking. You can use mypy --strict --explicit-package-bases eflips/ to run MyPy on the code.

Please make sure that your poetry.lock and pyproject.toml files are consistent before committing. You can use poetry check to check this. This is also checked by pre-commit.

You can use pre-commit to ensure that MyPy, Black, and Poetry are run before committing. To install pre-commit, execute the following command in the root directory of the repository:

We recommend utilizing linters such as PyLint for static code analysis (but not doing everything it says blindly).

Usage Example

In examples a well-documented (german-language) Jupyter notebook can be found that explains how all pieces of the data structure fit together using the SQLAlchemy Implementation. See its README for details.

License

This project is licensed under the AGPLv3 license - see the LICENSE file for details.

Funding Notice

This code was developed as part of the project eBus2030+ funded by the Federal German Ministry for Digital and Transport (BMDV) under grant number 03EMF0402.

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

eflips_model-6.0.3.tar.gz (48.0 kB view details)

Uploaded Source

Built Distribution

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

eflips_model-6.0.3-py3-none-any.whl (61.6 kB view details)

Uploaded Python 3

File details

Details for the file eflips_model-6.0.3.tar.gz.

File metadata

  • Download URL: eflips_model-6.0.3.tar.gz
  • Upload date:
  • Size: 48.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for eflips_model-6.0.3.tar.gz
Algorithm Hash digest
SHA256 4fb8e37a21c36224bb3a4012aef42057a2ba5a480759c7498ebc35bd3b0f17c3
MD5 c7c733e67e9c580f00ce75fd198146a1
BLAKE2b-256 b8938518d821bb18964ee56e4b2d77fd0fe4ab69c0b3c8165e075fd5bc0dde23

See more details on using hashes here.

Provenance

The following attestation bundles were made for eflips_model-6.0.3.tar.gz:

Publisher: release.yml on mpm-tu-berlin/eflips-model

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file eflips_model-6.0.3-py3-none-any.whl.

File metadata

  • Download URL: eflips_model-6.0.3-py3-none-any.whl
  • Upload date:
  • Size: 61.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for eflips_model-6.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f73a74bf349b17a1a53f4ab4e1b8d1c744ade4adce9965a1903ae1c101ad362a
MD5 24aad7e252506078a66c2778590cc6d1
BLAKE2b-256 c3846f2a9c4a3d30389814daa61f9b937da1538f77f815130f9a53573b6fb2ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for eflips_model-6.0.3-py3-none-any.whl:

Publisher: release.yml on mpm-tu-berlin/eflips-model

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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