Commit graph

63 commits

Author SHA1 Message Date
daa224d041
Rename _*_id columns into just *_id 2021-01-05 22:37:12 +01:00
078355897a
Fix missing unique constraint drop 2021-01-05 22:32:24 +01:00
992d2bb7d4
Adjust flake8 ...
... to not complain about implementation details when testing.
2021-01-05 19:08:52 +01:00
776112d609
Add Grid.gridify() constructor
- the purpose of this constructor method is to generate all `Pixel`s
  for a `Grid` that have at least one `Address` assigned to them
- fix missing `UniqueConstraint` in `Grid` class => it was not possible
  to create two `Grid`s with the same `.side_length` in different cities
- change the `City.viewport` property into two separate `City.southwest`
  and `City.northeast` properties; also add `City.total_x` and
  `City.total_y` properties for convenience
2021-01-05 18:58:48 +01:00
a1cbb808fd
Integrate the new Location class
- the old `UTMCoordinate` class becomes the new `Location` class
- its main purpose is to represent locations in both lat-long
  coordinates as well as in the UTM system
- remove `Address.__init__()` and `City.__init__()` methods as they
  are not executed for entries retrieved from the database
- simplfiy the `Location.__init__()` => remove `relative_to` argument
2021-01-04 20:33:10 +01:00
2e3ccd14d5
Use globals for the database connection
- remove the factory functions for creating engines and sessions
- define global engine, connection, and session objects to be used
  everywhere in the urban_meal_delivery package
2021-01-04 20:23:55 +01:00
f996376b13
Add ORM models for the pixel grids
- add Grid, Pixel, and AddressPixelAssociation ORM models
- each Grid belongs to a City an is characterized by the side_length
  of all the square Pixels contained in it
- Pixels aggregate Addresses => many-to-many relationship (that is
  modeled with SQLAlchemy's Association Pattern to implement a couple
  of constraints)
2021-01-03 19:33:36 +01:00
6cb4be80f6
Add Address.x and Address.y coordinates
- the Address.x and Address.y properties use the UTMCoordinate class
  behind the scenes
- x and y are simple coordinates in an x-y plane
- the (0, 0) origin is the southwest corner of Address.city.viewport
2021-01-02 16:29:50 +01:00
6f9935072e
Add UTMCoordinate class
- the class is a utility to abstract working with latitude-longitude
  coordinates in their UTM representation (~ "cartesian plane")
- the class's .x and .y properties enable working with simple x-y
  coordinates where the (0, 0) origin is the lower-left of a city's
  viewport
2021-01-02 14:31:59 +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
78dba23d5d
Re-factor the ORM tests to use randomized fake data
- create `*Factory` classes with fakerboy and faker that generate
  randomized instances of the ORM models
- add new pytest marker: "db" are the integration tests involving the
  database whereas "e2e" will be all other integration tests
- streamline the docstrings in the ORM models
2020-12-29 15:40:32 +01:00
416a58f9dc
Add geopy to the dev dependencies 2020-12-28 15:52:08 +01:00
3e0300cb0e
Disable too-few-public-methods error in pylint 2020-12-16 11:04:43 +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
b9c3697434
Move notebooks into the research folder 2020-12-14 16:56:27 +01:00
671d209cc5
Move submodule with demand-forecasting paper into research folder 2020-12-14 16:21:12 +01:00
86ad139c7b
Fix --require-hashes mode in GitHub Actions
- GitHub Actions complains about missing hashes in poetry's export
  of pinned dependencies
- as an example, see https://github.com/webartifex/urban-meal-delivery/runs/1550750320
2020-12-14 15:26:57 +01:00
c1064673aa
Isolate configuration related code better
- create the global `config` object inside the
  `urban_meal_delivery.configuration` module
- streamline documentation and comments
2020-12-14 15:15:08 +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
570cb0112e
Pin the dependencies ...
... after upgrading:
- dev dependencies
  + packaging
  + pre-commit
  + pytest
  + sphinx
- research dependencies
  + pandas
- transient dependencies
  + appnode   + argcomplete        + babel         + bandit
  + certifi   + cffi               + colorlog      + darglint
  + identify  + ipykernel          + jupyter-core  + nest-asyncio
  + pathspec  + prometheus-client  + py            + pygments
  + pywin32   + pyzmq              + regex         + requests
  + restructedtext-lint            + stevedore     + testfixtures
  + urllib3   + virtualenv
2020-12-14 13:54:26 +01:00
143ecba98e
Update submodule for demand-forecasting paper
The paper is now published.
2020-12-14 13:46:45 +01:00
51bb7e8235
Adjust the branch reference fixer task's logic ...
... to assume a feature branch if the branch name does not start with
'release' or 'research' and change all references into 'develop'.
2020-11-07 16:42:35 +01:00
03e498cab9
Pin the dependencies ...
... after upgrading:
- sqlalchemy
- dev dependencies
  + darglint
  + flake8(-comprehensions)
  + pre-commit
  + pytest
  + sphinx(-autodoc-typehints)
- reseach dependencies
  + jupyterlab
  + numpy
  + pandas
  + pytz
- transient dependencies
  + attrs
  + colorama
  + gitpython
  + identify
  + iniconfig
  + ipython
  + nbclient
  + nbconvert
  + nbformat
  + nest-asyncio
  + notebook
  + pandocfilters
  + pbr
  + prompt-toolkit
  + pygments
  + regex
  + testfixtures
  + toml
  + tornado
  + traitlets
  + urllib3
  + virtualenv
2020-11-07 16:25:18 +01:00
af5d54f159
Upgrade poetry to v1.1.0
The order of keys in the poetry.lock file is changed.
2020-11-07 16:23:27 +01:00
f8fd9c83bd
Add submodule for demand forecasting paper 2020-11-07 12:51:09 +01:00
88a9b8101c
Merge branch 'research-clean-data' into develop 2020-09-30 13:52:01 +02:00
6d9e5ffcef
Add info about the data cleaning 2020-09-30 13:43:00 +02:00
6333f1af1e
Clean the raw data
- clean the raw data given by the undisclosed meal delivery platform:
  + keep data only for the three target citis:
    * Bordeaux
    * Lyon
    * Paris
  + merge duplicates
    * it appears as redundant addresses were created
      for each order by the same customer
      =>  significant reduction in the number of addresses
    * propagate the merges to the other tables
      that reference records merged away
  + cast data types and keep their scopes narrow
  + normalize the data
  + remove obvious outliers
  + adjust/discard unplausible values
- map the cleaned data onto the ORM models
- store the cleaned data in a new database schema
2020-09-30 13:39:48 +02:00
437848d867
Merge branch 'release-0.2.0' into develop 2020-09-30 12:57:35 +02:00
3393071db3
Merge branch 'release-0.2.0' into main
Some checks failed
CI / tests (push) Has been cancelled
2020-09-30 12:20:58 +02:00
4c633cec3d
Finalize release 0.2.0 2020-09-30 12:20:21 +02:00
deeba63fbd
Pin the dependencies ...
.. after upgrading a couple of packages
2020-09-30 12:16:10 +02:00
a67805fcff
Upgrade isort to v5.5.4 2020-09-30 12:16:09 +02:00
db119ea776
Adjust the branch reference fixer's logic
- change references to temporary branches (e.g., "release-*" and
  "publish") to point to the 'main' branch
- add --branch=BRANCH_NAME option to the nox session so that
  one can pass in a target branch to make all references point to
- run "fix-branch-references" as the first pre-commit hook
  as it fails the fastest
- bug fix: allow dots in branch references (e.g., "release-0.1.0")
2020-09-30 12:16:00 +02:00
79f0ddf0fe
Add installation and contributing info 2020-08-11 11:02: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
4ee5a50fc6
Simplify the pre-commit hooks
- run "format" and "lint" separately
  => remove the nox session "pre-commit"
- execute the entire "test-suite" before merges
  + rename "pre-merge" into "test-suite"
  + do not "format" and "lint" here any more
  + do not execute this before pushes
    * allow branches with <100% test coverage to exist on GitHub
      (they cannot be merged into 'main' until 100% coverage)
    * GitHub Actions executes the test suite
2020-08-11 10:41:43 +02:00
ac5804174d
Add a branch reference fixer as a pre-commit hook
- many *.py and *.ipynb files will contain links to resources on
  GitHub or nbviewer that have branch references in them
- add a pre-commit hook implemented as the nox session
  "fix-branch-references" that goes through these files and
  changes all the branch labels to the current one
2020-08-11 10:35:18 +02:00
49ba0c433e
Fix the "clean-pwd" command in nox
- some glob patterns in .gitignore were not correctly expanded
- adapt the exclude logic to focus on the start of the excluded paths
2020-08-11 10:31:54 +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
d219fa816d
Pin the dependencies ...
... after upgrading:
- flake8-plugin-utils
- sphinx
2020-08-11 10:27:59 +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
9f32b80b93
Merge branch 'release-0.1.0' into develop 2020-08-05 16:28:12 +02:00
52514ca411
Merge branch 'release-0.1.0' into main
Some checks failed
CI / tests (push) Has been cancelled
2020-08-05 16:10:39 +02:00
4cf0cf4b08
Finalize release 0.1.0 2020-08-05 15:53:34 +02:00