Commit graph

27 commits

Author SHA1 Message Date
d5b3efbca1
Add aggregate_orders() function
- the function queries the database and aggregates the ad-hoc orders
  by pixel and time steps into a demand time series
- implement "heavy" integration tests for `aggregate_orders()`
- make `pandas` a package dependency
- streamline the `Config`
2021-01-07 23:35:13 +01:00
54ff377579
Add CLI script to gridify all cities
- reorganize `urban_meal_delivery.console` into a sub-package
- move `tests.db.conftest` fixtures into `tests.conftest`
  => some integration tests regarding CLI scripts need a database
- add `urban_meal_delivery.console.decorators.db_revision` decorator
  to ensure the database is at a certain state before a CLI script runs
- refactor the `urban_meal_delivery.db.grids.Grid.gridify()` constructor:
  - bug fix: even empty `Pixel`s end up in the database temporarily
    => create `Pixel` objects only if an `Address` is to be assigned
       to it
  - streamline code and docstring
  - add further test cases
2021-01-06 16:17:05 +01:00
755677db46
Add utm to the dependencies 2021-01-01 17:59:15 +01:00
556b9d36a3
Add shapely to the dependencies 2020-12-30 17:37:51 +01:00
416a58f9dc
Add geopy to the dev dependencies 2020-12-28 15:52:08 +01:00
2ddd430534
Add Faker to the dev dependencies 2020-12-15 19:07:14 +01:00
8345579b6c
Add factory_boy to the dev dependencies 2020-12-15 12:23:45 +01:00
0aefa22666
Integrate pytest-randomly into the test suite
As a lot of the integration tests populate the database with test data,
it is deemed safer to run the tests in random order to uncover potential
dependencies between distinct test cases.
Because of how the `db_session` fixture is designed, this should already
be taken care of.
2020-12-15 11:35:05 +01:00
9ee9c04a69
Remove python-dotenv from the dependencies
zsh-dotenv automatically loads the environment variables upon entering
the project's root.
2020-12-14 14:26:12 +01:00
437848d867
Merge branch 'release-0.2.0' into develop 2020-09-30 12:57:35 +02:00
4c633cec3d
Finalize release 0.2.0 2020-09-30 12:20:21 +02:00
a67805fcff
Upgrade isort to v5.5.4 2020-09-30 12:16:09 +02:00
ebf16b50d9
Add Jupyter Lab environment
- dependencies used to run the Jupyter Lab environment that are not
  required by the `urban-meal-delivery` package itself are put into
  an installation extra called "research"
- this allows to NOT install the requirements, for example, when
  testing the package in an isolated environment
2020-08-11 10:50:29 +02:00
a16c260543
Add database migrations
- use Alembic to migrate the PostgreSQL database
  + create initial migration script to set up the database,
    as an alternative to db.Base.metadata.create_all()
  + integrate Alembic into the test suite; the db_engine fixture
    now has two modes:
    * create the latest version of tables all at once
    * invoke `alembic upgrade head`
    => the "e2e" tests are all run twice, once in each mode; this
       ensures that the migration scripts re-create the same database
       schema as db.Base.metadata.create_all() would
    * in both modes, a temporary PostgreSQL schema is used to create the
      tables in
    => could now run "e2e" tests against production database and still
       have isolation
- make the configuration module public (to be used by Alembic)
- adjust linting rules for Alembic
2020-08-11 10:29:58 +02:00
fdcc93a1ea
Add an ORM layer
- use SQLAlchemy (and PostgreSQL) to model the ORM layer
- add the following models:
  + Address => modelling all kinds of addresses
  + City => model the three target cities
  + Courier => model the UDP's couriers
  + Customer => model the UDP's customers
  + Order => model the orders received by the UDP
  + Restaurant => model the restaurants active on the UDP
- so far, the emphasis lies on expression the Foreign Key
  and Check Constraints that are used to validate the assumptions
  inherent to the cleanded data
- provide database-independent unit tests with 100% coverage
- provide additional integration tests ("e2e") that commit data to
  a PostgreSQL instance to validate that the constraints work
- adapt linting rules a bit
2020-08-11 10:28:17 +02:00
9456f86d65
Add a config object
- add the following file:
  + src/urban_meal_delivery/_config.py
- a config module is created holding two sets of configurations:
  + production => against the real database
  + testing => against a database with test data
- the module is "protected" (i.e., underscore) and imported at the
  top level via a proxy-like object `config` that detects in which of
  the two environments the package is being run
2020-08-11 10:27:11 +02:00
b42ceb4cea
Bump version 2020-08-05 16:30:44 +02:00
4cf0cf4b08
Finalize release 0.1.0 2020-08-05 15:53:34 +02:00
882226f0a9
Add technical documentation for the package
- use sphinx to document the developed package
- create a nox session "docs" that builds the docs
- include a skeleton in the docs/ folder
  + how to install the package
  + how to use nox
  + license
2020-08-05 01:44:29 +02:00
126dcf7c39
Include doctests in the test suite
- use xdoctest to validate all code snippets in docstrings
- add xdoctest to the nox session "test"
2020-08-05 00:02:40 +02:00
97d714d9ee
Add CLI entry point umd
- add the following file:
  + src/urban_meal_delivery/console.py => click-based CLI tools
  + tests/test_console.py => tests for the module above
- add a CLI entry point `umd`:
  + implement the --version / -V option
    to show the installed package's version
  + rework to package's top-level:
    * add a __pkg_name__ variable to parameterize the package name
  + add unit and integration tests
- fix that pylint cannot know the proper order of imports in the
  isolated nox session
2020-08-04 21:14:40 +02:00
da233e2e35
Set up pre-commit hooks
- add pre-commit and pre-merge hooks:
  + run `poetry run nox -s pre-commit` on staged *.py files
  + run common pre-commit hooks for validations that could not be
    achieved with tools in the develop environment so easily
  + run `poetry run nox -s pre-merge` before merges and pushes
- implement the "pre-commit" and "pre-merge" sessions in nox
  + include a little hack to deal with the positional arguments
    passed by the pre-commit framework
- provide more documentation on the nox sessions
2020-08-04 17:58:35 +02:00
9fc5b4816a
Add a testing tool chain
- use pytest as the base, measure coverage with pytest-cov
  + configure coverage to include branches and specify source locations
  + configure pytest to enforce explicit markers
- add a package for the test suite under tests/
- add a `__version__` identifier at the package's root
  + it is dynamically assigned the version of the installed package
  + the version is PEP440 compliant and follows a strict subset of
    semantic versioning: x.y.z[.devN] where x, y, z, and N are all
    non-negative integers
  + add module with tests for the __version__
- add a nox session "test" that runs the test suite
- use flake8 to lint pytest for consistent style
2020-08-04 00:09:29 +02:00
c7989e0040
Add a code linting tool chain
- use flake8 as the main and pylint as the auxiliary linter
- install flake8 with the following plug-ins:
  + flake8-annotations => enforce type annotations for functions/classes
  + flake8-black => ensure black would not make any changes
  + flake8-expression-complexity
  + wemake-python-styleguide, which packages the following:
    * darglint         * flake8-bandit         * flake8-broken-line
    * flake8-bugbear   * flake8-commas         * flake8-comprehensions
    * flake8-debugger  * flake8-docstrings     * flake8-eradicate
    * flake8-isort     * flake8-rst-docstrings * flake8-string-format
    * flake8-quotes    * pep8-naming
- configure flake8 & friends in a rather explicit and strict way
- isort needed to be downgraded to ^4.3.21 due to a conflict with
  pylint and wemake-python-styleguide:
  + provide TODO's to remove the parts that "fix" isort
- use mypy for static type checking
- add a nox session "lint" that runs flake8, mypy, and pylint
- lint all source files
2020-08-03 23:12:12 +02:00
bb6de05709
Add a code formatting tool chain
- (auto-)format code with:
  + autoflake => * remove unused imports and variables
                 * remove duplicate dict keys
                 * expand star imports
  + black => enforce an uncompromising code style
  + isort => enforce a consistent import style
             (complying with Google's Python Style Guide)
- implement the nox session "format" that runs all these tools
- add the following file:
  + setup.cfg => holds configurations for the develop tools
2020-08-03 21:39:49 +02:00
6754f04fcd
Add nox as the task runner
- set up skeletons for all planned nox sessions
- provide a base configuration for all nox sessions
- create two utility functions:
  + _begin() => run commands common to all sessions
  + _install_packages() => install dependencies in nox sessions
                           respecting the versions pinned in poetry.lock
- add the following file:
  + noxfile.py
2020-08-03 21:24:06 +02:00
de8afa6335
Initial commit
- add the following files:
  + .gitignore => ignore poetry's and pyenv's artifacts
  + LICENSE.txt => MIT license as the project is scientific research
  + README.md => rough description of the project
  + poetry.lock
  + pyproject.toml
  + src/urban_meal_delivery/__init__.py => source code package
- use a "src" layout structure:
  + ensure that pytest runs the tests against a packaged and pip
    installed version of the source code, not the *.py files in the
    project directory
  + more info: https://hynek.me/articles/testing-packaging/
2020-08-03 20:19:42 +02:00