Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
753eaf23e4 |
|||
|
3b52ee0525 |
|||
|
ed739ed756 |
|||
|
2bfd936087 |
|||
|
f9fce093d1 |
|||
|
47a22f9587 |
|||
|
7a000145a7 |
|||
|
a06cb5bdfb |
|||
|
f9643642b8 |
|||
|
9c409b619e |
|||
|
50889df241 |
|||
|
c18fc2ba59 |
|||
|
f90f263dab |
|||
|
51f68743e5 |
|||
|
bca4250b4d |
|||
|
0f69709226 |
|||
|
9b8fe8b8fd |
|||
|
1413d08ed9 |
|||
|
ff7f705bc8 |
|||
|
2f1afd459f |
|||
|
049a5f6f62 |
|||
|
454c2898a0 |
|||
|
732a74be1c |
|||
|
e5c7487515 |
|||
|
8b5e66d70b |
|||
|
53746966ac |
|||
|
e1cdac4cfa |
|||
|
49276bb9cf |
|||
|
cc45b78e5d |
|||
|
9be63c3fef |
|||
|
2a64958a93 |
|||
|
df53ce7bc4 |
|||
|
67917ae3f6 |
|||
|
b947337bd1 |
|||
|
80d2573f0d |
|||
|
5609e8ec6e |
|||
|
a85d426b6e |
|||
|
35d0c7b409 |
|||
|
2add322a25 |
|||
|
eb059c1ea5 |
|||
|
ef7b41e675 |
|||
|
664dccee02 |
|||
|
bbd7d6a279 |
|||
|
2b1dd6af35 |
|||
|
fc185fa3c0 |
|||
|
9d98021b11 |
|||
|
bc2e3f439d |
|||
|
185a37f7d4 |
|||
|
2eb6b5769f |
|||
|
0dc3e11a63 |
|||
|
54e21109e7 |
|||
|
9d2a4139b7 |
|||
|
53e1859ee8 |
|||
|
1f5a39f83a |
|||
|
c1f04c65aa |
|||
|
455af6dfdb |
|||
|
248c1ae600 |
|||
|
25ed8c744b |
|||
|
69d3be4a53 |
|||
|
7d53abc057 |
|||
|
1f9d0effae |
|||
|
2a627072d8 |
|||
|
db2e00216d |
|||
|
f532aae588 |
|||
|
b36a3d1cd6 |
|||
|
731299bb6e |
|||
|
69b9d53704 |
|||
|
cfd8d33049 |
|||
|
f47c87f51f |
|||
|
2f313e7e3a |
|||
|
5f7d3108de |
|||
|
893b6bd8f1 |
|||
|
e4711875ca |
|||
|
f92fd35ce3 |
|||
|
8abc93987e |
|||
|
3b8b041a3e |
|||
|
9a0dbb8ad8 |
|||
|
96b5a07f20 |
|||
|
66265c8808 |
|||
|
804a4a0966 |
|||
|
77806b14b9 |
|||
|
c74a7b81f1 |
|||
|
081d6f7fd9 |
|||
|
d6b798a736 |
|||
|
f7a6aa1881 |
|||
|
369957c06b |
|||
|
883a3ab8cc |
|||
|
9da2d0b703 |
|||
|
fef268321a |
|||
|
7190724260 |
|||
|
dafc695693 |
|||
|
a4c1574135 |
|||
|
784d5c8ca0 |
|||
|
0a5f8f6c55 |
|||
|
bbc00e2f1c |
|||
|
0d2aab4211 |
|||
|
76982126f4 |
|||
|
5ad3fb538d |
|||
|
4be6078327 |
|||
|
699e7f0443 |
|||
|
af0e3cf1a1 |
|||
|
f45a444f83 |
|||
|
9a2ec3d86b |
|||
|
90c0597193 |
|||
|
bda9cf69ed |
|||
|
99c8c2ac2e |
|||
|
8f5d11db7f |
|||
|
de86c2e64d |
|||
|
2e03e58716 |
|||
|
6633067563 |
|||
|
cd74b343bc |
|||
|
ef0888619e |
|||
|
e4016db9fe |
|||
|
d9364eea9e |
|||
|
7e4fe464f6 |
|||
|
2bc2408694 |
|||
|
01416a1175 |
|||
|
f835b091b2 |
|||
|
ad56683166 |
|||
|
83b5bd40a7 |
|||
|
927ea56082 |
|||
|
6ecbd6860a |
|||
|
8d843895b7 |
|||
|
567bb713e2 |
|||
|
57ac602612 |
|||
|
1827e02f34 |
|||
|
4023f32662 |
|||
|
e612e33f59 |
|||
|
991543046d |
|||
|
d55e72e04d |
|||
|
5c62c9919c |
|||
|
33daa9cda7 |
|||
|
c32566527a |
|||
|
6ebcd69524 |
|||
|
ed53324a1d |
|||
|
0090145b65 |
|||
|
c56fe649b7 |
|||
|
ae2dc8db64 |
|||
|
652713e702 |
|||
|
5beb88559f |
|||
|
d0326aee4f |
|||
|
99dda74a9e |
|||
|
95f08bc96d |
|||
|
f266adad45 |
|||
|
00aff456c3 |
|||
|
0a4fd0edbc |
|||
|
9cc21f5b69 |
|||
|
0cb924b3b6 |
|||
|
3bd7dd5772 |
|||
|
007998372f |
|||
|
5dce8e6645 |
|||
|
d0d5c92c55 |
|||
|
75824ea602 |
|||
|
31dda815d9 |
|||
|
5c13d719cd |
|||
|
cf2534f41e |
|||
|
de5e49b497 |
|||
|
dc45c689c4 |
|||
|
e9743eaa01 |
|||
|
8bca30c836 |
|||
|
9b844b16e7 |
|||
|
07e90b7851 |
|||
|
07660ecff9 |
|||
|
d660f0cc4e |
|||
|
d006752194 |
|||
|
5ca16ae47c |
|||
|
f0c617955b |
|||
|
9c3b52befb |
|||
|
c6518f6b39 |
|||
|
aa1a7c796f |
|||
|
0b2a1197a2 |
|||
|
9d3af5e447 |
|||
|
78e052b668 |
|||
|
e30b3efbe8 |
|||
|
a85ba4c4c4 |
|||
|
2b112f46e2 |
|||
|
e9dbf528d7 |
|||
|
6119064d71 |
|||
|
570c9c9fcb |
|||
|
295a271ad7 |
|||
|
607055d55a |
|||
|
744d9a6353 |
|||
|
1c206a715b |
|||
|
a4d1f477ae |
|||
|
e08272e6ab |
|||
|
1cc5dcff54 |
|||
|
82d245836f |
|||
|
a320c1fba5 |
|||
|
b5a6fb42cc |
|||
|
27171fe79a |
|||
|
c339719936 |
|||
|
a8b4bca79d |
|||
|
c3198ecc48 |
|||
|
e01421bb96 |
|||
|
ee5a372b2b |
|||
|
87aaebe475 |
|||
|
fb87326d66 |
|||
|
a24db98262 |
|||
|
8f36a740d7 |
|||
|
707b4ab652 |
|||
|
e451f03d0f |
|||
|
318dff8fc8 |
|||
|
175d722071 |
|||
|
88554e3939 |
|||
|
1a4dfb0ee7 |
|||
|
4a81403f15 |
|||
|
3ec7ec8c98 |
|||
|
afe8b3ce90 |
|||
|
882d3c98ba |
|||
|
29a711f049 |
|||
|
cb8f919b1f |
|||
|
650765a9d3 |
|||
|
50a0e45309 |
|||
|
ea8f1a13e3 |
|||
|
7b32ffc599 |
|||
|
efde4322bf |
|||
|
08493d1ea1 |
|||
|
7f14c9c855 |
|||
|
cb110267f0 |
|||
|
d9d9464f44 |
|||
|
2000ceca54 |
|||
|
137b3b1e03 |
|||
|
b24eb80f70 |
|||
|
13eedbf699 |
|||
|
21d6066086 |
|||
|
785bb99c7d |
|||
|
9fcb3c8c14 |
|||
|
8a5a652b3e |
|||
|
7c528d327e |
|||
|
253a12821e |
|||
|
0dc32da8c1 |
|||
|
30aac8e3c7 |
|||
|
d158577984 |
|||
|
9e10a0c9aa |
|||
|
4fb96ee485 |
|||
|
c6ea7b13ec |
|||
|
8265790d5d |
|||
|
5c3a942ad5 |
|||
|
2f0748e059 |
|||
|
d8edd58fe6 |
|||
|
792da0507f |
|||
|
fbfb79d610 |
|||
|
08dd3b8218 |
|||
|
83007d458c |
|||
|
ff53af5001 |
|||
|
9adddd7959 |
|||
|
79f35ae3aa |
|||
|
079a9505ff |
|||
|
ed34e05cc7 |
|||
|
44eef9eafc |
|||
|
0ce8840bed |
|||
|
518811e138 |
|||
|
b4e22dd0d4 |
|||
|
6958cc6a58 |
|||
|
045139a933 |
|||
|
aaeb9b1e72 |
|||
|
a8c0e17bed |
|||
|
ad8d43815e |
|||
|
7c2e21130f |
|||
|
689c8a8f42 |
|||
|
32f6540ec3 |
|||
|
110c6f755b |
|||
|
e7d93a5496 |
|||
|
50d5b885bf |
|||
|
2147dbf9d0 |
|||
|
ded4691177 |
|||
|
5f73b74d69 |
|||
|
ebad87b0a3 |
|||
|
d918063218 |
|||
|
f5f24ea611 |
|||
|
6d2578ef80 |
|||
|
60aa7911d2 |
|||
|
99db2dc623 |
|||
|
f5a0a91202 |
|||
|
b5db5ab80e |
|||
|
911107af95 |
|||
|
218d1d6078 |
|||
|
7ad2e4ee26 |
|||
|
f6344ac4c5 |
|||
|
935e3e28d6 |
|||
|
4495da2b60 |
|||
|
68ada518ea |
|||
|
c5c8635c09 |
|||
|
ed510eba7d |
|||
|
1dd2810ac7 |
|||
|
c4eae82e4d |
|||
|
355dfd993f |
|||
|
afb17b61da |
|||
|
3adfa117a5 |
|||
|
c3f82deeab |
|||
|
c28d702a58 |
|||
|
74ddb54772 |
|||
|
03617d5bbb |
|||
|
8771bb682e |
|||
|
63c9453ce7 |
|||
|
eb62ff2048 |
|||
|
645802bb7d |
|||
|
1faf140c30 |
|||
|
d7c69f3f37 |
|||
|
0e2b8f75f8 |
|||
|
f0d04c8a2a |
|||
|
4be36d527f |
|||
|
505e29b855 |
|||
|
bbe3f9af28 |
|||
|
ec7473e87a |
|||
|
dd50d7a62f |
|||
|
fbb7d078fa |
|||
|
ea3e25a85b |
|||
|
705955b38b |
|||
|
6290d280e2 |
|||
|
b6f570e13f |
|||
|
746fe023e6 |
|||
|
ac3251867f |
|||
|
3e11980ab0 |
|||
|
4516f54236 |
|||
|
5189a63bc3 |
|||
|
8cbd1fa979 |
|||
|
2f085f7450 |
|||
|
36264dc49c |
|||
|
c310c335ff |
|||
|
5710d12e21 |
|||
|
5519c9030c |
|||
|
6af7c4437d |
|||
|
042256eb99 |
|||
|
34da92102f |
|||
|
d54f94a998 |
|||
|
359d7be62a |
|||
|
9eecd371bc |
|||
|
94df768f74 |
|||
|
ffd72c9987 |
|||
|
dbdce83067 |
|||
|
fad875b332 |
|||
|
685bb872a8 |
|||
|
fc3fe900f6 |
|||
|
d8d5eecac9 |
|||
|
b2ce82f431 |
|||
|
d33816302c |
|||
|
71544f3088 |
|||
|
1d03d09a67 |
|||
|
b21ae1bf26 |
|||
|
af6c639cc1 |
|||
|
e6130f4253 |
|||
|
c895078837 |
|||
|
47b56550bc |
|||
|
b7cfdcb1c0 |
|||
|
e94ade4c88 |
|||
|
fb2db07d37 |
|||
|
793f3105b1 |
|||
|
46787de9bc |
|||
|
d8df96763c |
|||
|
db1b23cd99 |
|||
|
39cf160b95 |
|||
|
f736e0e73b |
|||
|
061832faa6 |
|||
|
fb912d12bb |
|||
|
b0cb3b412b |
|||
|
d4e8f17f0c |
|||
|
3e080c71c4 |
|||
|
1db69037ba |
|||
|
4224776f60 |
|||
|
4169da38b1 |
|||
|
706b0938c2 |
|||
|
c7f10f4c7f |
|||
|
4bc87eaf18 |
|||
|
b44fc5f826 |
|||
|
629e3e6e3d |
|||
|
dfc5cb7fb6 |
|||
|
9801baadee |
|||
|
dcb2f82deb |
|||
|
95c760a0c3 |
|||
|
754303ca71 |
|||
|
5cc8a13719 |
|||
|
3c6d3cbc65 |
|||
|
510c28c91e |
|||
|
abc3ec5b3c |
|||
|
ce2cdd6f3e |
|||
|
447533cceb |
|||
|
8eb0dda0e1 |
|||
|
fa5b2690ad |
|||
|
8e2536f45a |
|||
|
e7a2d4a3cb |
|||
|
4855209392 |
|||
|
a39d636876 |
|||
|
f253c09f43 |
|||
|
2a3450f537 |
|||
|
830f44e3cc |
|||
|
419c7e6bf6 |
|||
|
e4e543bd40 |
|||
|
41f75f507d |
|||
|
f0eb9d3b6f |
|||
|
6091ad95c6 |
|||
|
f891fac3dc |
|||
|
7e23033d84 |
|||
|
5978b0e92f |
|||
|
d03c2f91fb |
|||
|
0f60640bc0 |
|||
|
5eabd541e8 |
166 changed files with 222723 additions and 214338 deletions
52
.forgejo/actions/setup/action.yaml
Normal file
52
.forgejo/actions/setup/action.yaml
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
name: Set up `velofy`
|
||||||
|
description: Install R, `uv`, `nox`, and `pre-commit`
|
||||||
|
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- name: Install R via system packages
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
apt-get update
|
||||||
|
apt-get install --no-install-recommends \
|
||||||
|
r-base-dev \
|
||||||
|
r-cran-forecast \
|
||||||
|
r-cran-zoo \
|
||||||
|
-y
|
||||||
|
|
||||||
|
# Built wheels (e.g., `rpy2`) and Python versions, keyed by their pins
|
||||||
|
# => Only the "lint" job in ci.yaml saves the cache
|
||||||
|
- name: Restore the `uv` cache
|
||||||
|
id: uv-cache
|
||||||
|
uses: actions/cache/restore@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.cache/uv
|
||||||
|
~/.local/share/uv/python
|
||||||
|
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock', 'pyproject.toml') }}
|
||||||
|
restore-keys: uv-${{ runner.os }}-
|
||||||
|
|
||||||
|
# Tell the "lint" job in ci.yaml the key and if it must save the cache
|
||||||
|
- name: Remember the `uv` cache key and if it was restored exactly
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "UV_CACHE_KEY=${{ steps.uv-cache.outputs.cache-primary-key }}" >> "$FORGEJO_ENV"
|
||||||
|
echo "UV_CACHE_HIT=${{ steps.uv-cache.outputs.cache-hit }}" >> "$FORGEJO_ENV"
|
||||||
|
|
||||||
|
# All `SUPPORTED_PYTHONS` from the "classifiers" in pyproject.toml
|
||||||
|
# => `nox` would otherwise pick the system's Python without headers
|
||||||
|
- name: Install `uv` and all supported Python versions
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
curl -LsSf https://astral.sh/uv/0.13.10/install.sh | sh
|
||||||
|
echo "$HOME/.local/bin" >> "$FORGEJO_PATH"
|
||||||
|
"$HOME/.local/bin/uv" python install $(grep -oP 'Programming Language :: Python :: \K3\.\d+' pyproject.toml)
|
||||||
|
|
||||||
|
# The jobs only use `nox` and `pre-commit` from the develop environment
|
||||||
|
# => The `nox` sessions install `velofy` and its dependencies themselves
|
||||||
|
- name: Install `nox` and `pre-commit`
|
||||||
|
shell: bash
|
||||||
|
run: '"$HOME/.local/bin/uv" sync --locked --only-group dev'
|
||||||
2
.forgejo/default_merge_message/MERGE_TEMPLATE.md
Normal file
2
.forgejo/default_merge_message/MERGE_TEMPLATE.md
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
Merge branch '${HeadBranch}' into ${BaseBranch}
|
||||||
|
${ReviewedOn}
|
||||||
117
.forgejo/workflows/ci.yaml
Normal file
117
.forgejo/workflows/ci.yaml
Normal file
|
|
@ -0,0 +1,117 @@
|
||||||
|
name: CI
|
||||||
|
|
||||||
|
|
||||||
|
# Run on every push, which also covers pull requests from this repository
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
|
||||||
|
|
||||||
|
# Use `bash` instead of the container's default `sh`
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
|
||||||
|
# Same variables as in `.env` on `nehemiah`, the main development machine
|
||||||
|
env:
|
||||||
|
DATABASE_URI: postgresql://user:password@postgres:5432/db
|
||||||
|
GOOGLE_MAPS_API_KEY: AIzaDummyKeyForTests # Fake key to mock the Google API
|
||||||
|
R_LIBS: /usr/lib/R/site-library
|
||||||
|
UV_NO_SYNC: "1" # Keep `uv run` from installing all groups (see the setup action)
|
||||||
|
UV_PYTHON_PREFERENCE: only-managed # Only uv's Python has the headers to build `rpy2`
|
||||||
|
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
lint:
|
||||||
|
name: Lint
|
||||||
|
runs-on: debian-13
|
||||||
|
|
||||||
|
# Stop hanging jobs (e.g., a test waiting for a database lock)
|
||||||
|
timeout-minutes: 20
|
||||||
|
|
||||||
|
# Throwaway database, reachable from the job as host `postgres`
|
||||||
|
services: &database
|
||||||
|
postgres:
|
||||||
|
image: postgres:17
|
||||||
|
env:
|
||||||
|
POSTGRES_USER: user
|
||||||
|
POSTGRES_PASSWORD: password
|
||||||
|
POSTGRES_DB: db
|
||||||
|
# Start the steps only once the database accepts connections
|
||||||
|
options: >-
|
||||||
|
--health-cmd "pg_isready --username=user --dbname=db"
|
||||||
|
--health-interval 2s
|
||||||
|
--health-timeout 5s
|
||||||
|
--health-retries 15
|
||||||
|
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
fetch-depth: 0 # Fetch all branches with their history for the next step
|
||||||
|
|
||||||
|
- name: Ensure feature branches contain no merge commits
|
||||||
|
if: forgejo.ref_name != 'develop' && forgejo.ref_name != 'main'
|
||||||
|
run: "! git rev-list --merges origin/develop..HEAD | grep ."
|
||||||
|
|
||||||
|
- uses: ./.forgejo/actions/setup
|
||||||
|
|
||||||
|
- name: Ensure `nox -s format` changes nothing
|
||||||
|
run: uv run nox -s format && git diff --exit-code
|
||||||
|
|
||||||
|
- name: Lint the source files
|
||||||
|
run: uv run nox -s lint
|
||||||
|
|
||||||
|
- name: Test the code snippets in the docstrings with `xdoctest`
|
||||||
|
run: uv run nox -s test-docstrings
|
||||||
|
|
||||||
|
- name: Run the `pre-commit` hooks not covered by `nox`
|
||||||
|
run: uv run pre-commit run --all-files --show-diff-on-failure
|
||||||
|
env:
|
||||||
|
SKIP: local-format,local-lint,local-test,local-test-docstrings,local-test-types,no-commit-to-branch
|
||||||
|
|
||||||
|
# Only this job saves the `uv` cache that ./.forgejo/actions/setup restores
|
||||||
|
# => Keep only what is expensive to rebuild, not wheels that are cheap to download
|
||||||
|
- name: Shrink the `uv` cache
|
||||||
|
if: env.UV_CACHE_HIT != 'true'
|
||||||
|
run: uv cache prune --ci
|
||||||
|
|
||||||
|
- name: Save the `uv` cache
|
||||||
|
if: env.UV_CACHE_HIT != 'true'
|
||||||
|
uses: actions/cache/save@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.cache/uv
|
||||||
|
~/.local/share/uv/python
|
||||||
|
key: ${{ env.UV_CACHE_KEY }}
|
||||||
|
|
||||||
|
|
||||||
|
tests:
|
||||||
|
name: Tests (${{ matrix.session }})
|
||||||
|
runs-on: debian-13
|
||||||
|
|
||||||
|
# Stop hanging jobs (e.g., a test waiting for a database lock)
|
||||||
|
timeout-minutes: 20
|
||||||
|
|
||||||
|
# Run the sessions in parallel, each with its own database
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
session:
|
||||||
|
- test
|
||||||
|
- test-types
|
||||||
|
# One job per non-main Python version listed in the "classifiers"
|
||||||
|
# in pyproject.toml => Keep in sync manually
|
||||||
|
- test-with-3.15
|
||||||
|
|
||||||
|
# Same database as in the "lint" job
|
||||||
|
services: *database
|
||||||
|
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- uses: ./.forgejo/actions/setup
|
||||||
|
|
||||||
|
- name: Run the `nox` session
|
||||||
|
run: uv run nox -s ${{ matrix.session }}
|
||||||
92
.git-blame-ignore-revs
Normal file
92
.git-blame-ignore-revs
Normal file
|
|
@ -0,0 +1,92 @@
|
||||||
|
# Mechanical commits that `git blame` skips
|
||||||
|
# => Enable locally with `git config blame.ignoreRevsFile .git-blame-ignore-revs`
|
||||||
|
|
||||||
|
# Use double quotes
|
||||||
|
ea8f1a13e34bfce01ea66951311e5f5fb5ab967f
|
||||||
|
|
||||||
|
# Use the `sa` alias for `sqlalchemy` everywhere
|
||||||
|
e30b3efbe8fc719f7d1d5bef32c69df67884f4d7
|
||||||
|
|
||||||
|
# Use `sa.func` instead of importing `func`
|
||||||
|
78e052b668d029204daeb17d0ded3938156f1f2b
|
||||||
|
|
||||||
|
# Import the `postgresql` dialect as `psql`
|
||||||
|
9d3af5e44719c88e4115c429d38e9e795de5bf05
|
||||||
|
|
||||||
|
# Import `sqlalchemy.ext.hybrid` as `sa_hybrid`
|
||||||
|
0b2a1197a2b089120f66ae2c8c365fac983192f4
|
||||||
|
|
||||||
|
# Use builtin generics and `X | None`
|
||||||
|
c6518f6b39386a7c803d0c2792fdae6d61436064
|
||||||
|
|
||||||
|
# Import `typing` as `t` ...
|
||||||
|
9c3b52befb51f91026accb9d4d3e0874ef6c3d23
|
||||||
|
|
||||||
|
# Use the `nox` module import
|
||||||
|
f0c617955bc8e9d46cd4126e0a334f1a28cc7849
|
||||||
|
|
||||||
|
# Import `datetime` as `dt` everywhere
|
||||||
|
5ca16ae47c63c06ac67b11908f813a544c377670
|
||||||
|
|
||||||
|
# Import `googlemaps` as `gm` everywhere
|
||||||
|
d660f0cc4ed6d9e62d0fe7c6d618322d57a1b049
|
||||||
|
|
||||||
|
# Import `geopy.distance` as `geo_distance` everywhere
|
||||||
|
07660ecff980932d082f82c43575fbfafc1172fe
|
||||||
|
|
||||||
|
# Import `click.testing` as `cli_testing`
|
||||||
|
07e90b7851e3c585270edf84b94fbb2998e51c46
|
||||||
|
|
||||||
|
# Import `statsmodels.tsa.api` as `tsa`
|
||||||
|
9b844b16e777ef643ea20f93f9fe415ecc51ff20
|
||||||
|
|
||||||
|
# Import `rpy2.rinterface_lib.callbacks` as `r_callbacks`
|
||||||
|
8bca30c83630a7136cba9c427d6bcc1dbffb2b7a
|
||||||
|
|
||||||
|
# Import `rpy2.robjects.packages` as `r_packages`
|
||||||
|
e9743eaa013362cd4e79b19dd7dd0c25ede11e73
|
||||||
|
|
||||||
|
# Import `alembic.command` as `alembic_cmd`
|
||||||
|
dc45c689c40ccfe98c2148f9ba08612612121083
|
||||||
|
|
||||||
|
# Import `alembic.config` as `alembic_config`
|
||||||
|
de5e49b497cc8f5904637fa5d913e2f8b331f2e8
|
||||||
|
|
||||||
|
# Import `velofy.config` as `pkg_config` everywhere
|
||||||
|
cf2534f41e9e535b8f68a38bb3e0ebadf3fb19b3
|
||||||
|
|
||||||
|
# Capitalize the explanations after "=>"
|
||||||
|
0090145b654c098cc464aed757e6c1fdda7487bd
|
||||||
|
|
||||||
|
# Remove periods from one-sentence comments
|
||||||
|
049a5f6f62e05f08ffdcb6ce90c1f07ec3042871
|
||||||
|
|
||||||
|
# Break multi-line comments before conjunctions
|
||||||
|
2f1afd459fe73c2ab4136acaa1f87ecf64212e9f
|
||||||
|
|
||||||
|
# Put identifiers in comments into backticks
|
||||||
|
ff7f705bc831734bbab63a43fd78a11121696bc5
|
||||||
|
|
||||||
|
# Reword the comments in `velofy.db`
|
||||||
|
1413d08ed9115501fa2757b97de23525581d9acf
|
||||||
|
|
||||||
|
# Reword the comments in `velofy.forecasts`
|
||||||
|
9b8fe8b8fd41e920954ce4cda5b2fd5e70b44185
|
||||||
|
|
||||||
|
# Reword the comments in the rest of `velofy`
|
||||||
|
0f6970922623a7bda82b78bb48d5fb05646e7d45
|
||||||
|
|
||||||
|
# Reword the comments in the test suite
|
||||||
|
bca4250b4d9512dde4f67996f21f4c4bc9c18387
|
||||||
|
|
||||||
|
# Reword the comments in the config files
|
||||||
|
51f68743e537a9ffa744f47e65313485b0ecd3c5
|
||||||
|
|
||||||
|
# Explain the "why" in a few more comments
|
||||||
|
f90f263dab12013cc1353381e6ee3258df5e9176
|
||||||
|
|
||||||
|
# Refer to sources with "See:" in comments
|
||||||
|
c18fc2ba59ed9286336da113604a98f423cbc32f
|
||||||
|
|
||||||
|
# Put the `ruff` per-file ignores on separate lines
|
||||||
|
47a22f9587f94fa5bc2705302a3e29dca3701dcf
|
||||||
32
.github/workflows/tests.yml
vendored
32
.github/workflows/tests.yml
vendored
|
|
@ -1,32 +0,0 @@
|
||||||
name: CI
|
|
||||||
on: push
|
|
||||||
jobs:
|
|
||||||
fast-tests:
|
|
||||||
name: fast (without R)
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: actions/setup-python@v1
|
|
||||||
with:
|
|
||||||
python-version: 3.8
|
|
||||||
architecture: x64
|
|
||||||
- run: pip install nox==2020.5.24
|
|
||||||
- run: pip install poetry==1.1.4
|
|
||||||
- run: nox -s format lint ci-tests-fast safety docs
|
|
||||||
slow-tests:
|
|
||||||
name: slow (with R)
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
env:
|
|
||||||
R_LIBS: .r_libs
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: actions/setup-python@v1
|
|
||||||
with:
|
|
||||||
python-version: 3.8
|
|
||||||
architecture: x64
|
|
||||||
- run: mkdir .r_libs
|
|
||||||
- run: sudo apt-get install r-base r-base-dev libcurl4-openssl-dev libxml2-dev patchelf
|
|
||||||
- run: R -e "install.packages('forecast')"
|
|
||||||
- run: pip install nox==2020.5.24
|
|
||||||
- run: pip install poetry==1.1.4
|
|
||||||
- run: nox -s ci-tests-slow
|
|
||||||
2
.gitmodules
vendored
2
.gitmodules
vendored
|
|
@ -1,3 +1,3 @@
|
||||||
[submodule "research/papers/demand-forecasting"]
|
[submodule "research/papers/demand-forecasting"]
|
||||||
path = research/papers/demand-forecasting
|
path = research/papers/demand-forecasting
|
||||||
url = git@github.com:webartifex/urban-meal-delivery-demand-forecasting.git
|
url = ssh://git@git.webartifex.de/alexander/velofy-forecasting.git
|
||||||
|
|
|
||||||
|
|
@ -1,50 +1,109 @@
|
||||||
default_stages: [commit] # only used if a hook does not specify stages
|
# Hooks run by `git commit` and `git merge`,
|
||||||
|
# installed with `uv run nox -s init-project`
|
||||||
|
|
||||||
|
# Used by a plain `pre-commit install`
|
||||||
|
default_install_hook_types:
|
||||||
|
- pre-commit
|
||||||
|
- pre-merge-commit
|
||||||
|
|
||||||
|
# Used if a hook does not specify stages
|
||||||
|
default_stages:
|
||||||
|
- pre-commit
|
||||||
|
|
||||||
fail_fast: true
|
fail_fast: true
|
||||||
|
|
||||||
|
|
||||||
repos:
|
repos:
|
||||||
# Run the local formatting, linting, and testing tool chains.
|
|
||||||
- repo: local
|
# Format, lint, and test with the `nox` sessions
|
||||||
|
- repo: local
|
||||||
hooks:
|
hooks:
|
||||||
- id: local-fix-branch-references
|
|
||||||
name: Check for wrong branch references
|
# `require_serial: true`
|
||||||
entry: poetry run nox -s fix-branch-references --
|
# => Parallel runs would recreate the same `nox` environment
|
||||||
language: system
|
|
||||||
stages: [commit]
|
|
||||||
types: [text]
|
|
||||||
- id: local-format
|
- id: local-format
|
||||||
name: Format the source files
|
name: Format the source files
|
||||||
entry: poetry run nox -s format --
|
entry: uv run nox -s format --
|
||||||
language: system
|
language: unsupported
|
||||||
stages: [commit]
|
stages: [pre-commit]
|
||||||
types: [python]
|
types: [python]
|
||||||
|
require_serial: true
|
||||||
|
|
||||||
- id: local-lint
|
- id: local-lint
|
||||||
name: Lint the source files
|
name: Lint the source files
|
||||||
entry: poetry run nox -s lint --
|
entry: uv run nox -s lint --
|
||||||
language: system
|
language: unsupported
|
||||||
stages: [commit]
|
stages: [pre-commit]
|
||||||
types: [python]
|
types: [python]
|
||||||
- id: local-test-suite
|
require_serial: true
|
||||||
name: Run the entire test suite
|
|
||||||
entry: poetry run nox -s test-suite --
|
- id: local-test
|
||||||
language: system
|
name: Run the test suite
|
||||||
stages: [merge-commit]
|
entry: uv run nox -s test
|
||||||
types: [text]
|
language: unsupported
|
||||||
# Enable hooks provided by the pre-commit project to
|
stages: [pre-merge-commit]
|
||||||
# enforce rules that local tools could not that easily.
|
pass_filenames: false # => No `--` at the end of the "entry"
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
always_run: true
|
||||||
rev: v3.2.0
|
require_serial: true
|
||||||
|
|
||||||
|
- id: local-test-docstrings
|
||||||
|
name: Run the doctests
|
||||||
|
entry: uv run nox -s test-docstrings
|
||||||
|
language: unsupported
|
||||||
|
stages: [pre-merge-commit]
|
||||||
|
pass_filenames: false # => No `--` at the end of the "entry"
|
||||||
|
always_run: true
|
||||||
|
require_serial: true
|
||||||
|
|
||||||
|
- id: local-test-types
|
||||||
|
name: Check the type annotations at runtime
|
||||||
|
entry: uv run nox -s test-types
|
||||||
|
language: unsupported
|
||||||
|
stages: [pre-merge-commit]
|
||||||
|
pass_filenames: false # => No `--` at the end of the "entry"
|
||||||
|
always_run: true
|
||||||
|
require_serial: true
|
||||||
|
|
||||||
|
# Keep requirements.txt in sync with uv.lock
|
||||||
|
- repo: https://github.com/astral-sh/uv-pre-commit
|
||||||
|
rev: 0.13.10
|
||||||
hooks:
|
hooks:
|
||||||
|
|
||||||
|
- id: uv-export
|
||||||
|
args:
|
||||||
|
- --extra=research
|
||||||
|
- --no-default-groups
|
||||||
|
- --no-emit-project
|
||||||
|
- --frozen
|
||||||
|
- --quiet
|
||||||
|
- --output-file=requirements.txt
|
||||||
|
|
||||||
|
# Generic checks that the "local" tools can not cover
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v6.0.0
|
||||||
|
hooks:
|
||||||
|
|
||||||
- id: check-added-large-files
|
- id: check-added-large-files
|
||||||
args: [--maxkb=100]
|
args: [--maxkb=100]
|
||||||
- id: check-case-conflict
|
exclude: ^requirements\.txt$ # Large because of the hashes
|
||||||
|
|
||||||
- id: check-builtin-literals
|
- id: check-builtin-literals
|
||||||
|
|
||||||
|
- id: check-case-conflict
|
||||||
|
|
||||||
- id: check-merge-conflict
|
- id: check-merge-conflict
|
||||||
|
|
||||||
- id: check-toml
|
- id: check-toml
|
||||||
|
|
||||||
- id: check-yaml
|
- id: check-yaml
|
||||||
|
|
||||||
- id: end-of-file-fixer
|
- id: end-of-file-fixer
|
||||||
stages: [commit] # overwrite the default
|
|
||||||
- id: mixed-line-ending
|
- id: mixed-line-ending
|
||||||
args: [--fix=no]
|
args: [--fix=no]
|
||||||
|
|
||||||
- id: no-commit-to-branch
|
- id: no-commit-to-branch
|
||||||
args: [--branch, main]
|
args: [--branch, main]
|
||||||
|
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
stages: [commit] # overwrite the default
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
Copyright (c) 2020 Alexander Hess [alexander@webartifex.biz]
|
Copyright (c) 2020 Alexander Hess [alexander@webartifex.de]
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
|
||||||
38
README.md
38
README.md
|
|
@ -16,16 +16,16 @@ that iteratively build on each other.
|
||||||
### Data Cleaning
|
### Data Cleaning
|
||||||
|
|
||||||
The UDP provided its raw data as a PostgreSQL dump.
|
The UDP provided its raw data as a PostgreSQL dump.
|
||||||
This [notebook](https://nbviewer.jupyter.org/github/webartifex/urban-meal-delivery/blob/main/research/01_clean_data.ipynb)
|
This [notebook](research/01_clean_data.ipynb)
|
||||||
cleans the data extensively
|
cleans the data extensively
|
||||||
and maps them onto the [ORM models](https://github.com/webartifex/urban-meal-delivery/tree/main/src/urban_meal_delivery/db)
|
and maps them onto the [ORM models](src/velofy/db)
|
||||||
defined in the `urban-meal-delivery` package
|
defined in the `velofy` package
|
||||||
that is developed in the [src/](https://github.com/webartifex/urban-meal-delivery/tree/main/src) folder
|
that is developed in the [src/](src) folder
|
||||||
and contains all source code to drive the analyses.
|
and contains all source code to drive the analyses.
|
||||||
|
|
||||||
Due to a non-disclosure agreement with the UDP,
|
Due to a non-disclosure agreement with the UDP,
|
||||||
neither the raw nor the cleaned data are published as of now.
|
neither the raw nor the cleaned data are published as of now.
|
||||||
However, previews of the data can be seen throughout the [research/](https://github.com/webartifex/urban-meal-delivery/tree/main/research) folder.
|
However, previews of the data can be seen throughout the [research/](research) folder.
|
||||||
|
|
||||||
|
|
||||||
### Tactical Demand Forecasting
|
### Tactical Demand Forecasting
|
||||||
|
|
@ -34,9 +34,9 @@ Before any optimizations of the UDP's operations are done,
|
||||||
a **demand forecasting** system for *tactical* purposes is implemented.
|
a **demand forecasting** system for *tactical* purposes is implemented.
|
||||||
To achieve that, the cities first undergo a **gridification** step
|
To achieve that, the cities first undergo a **gridification** step
|
||||||
where each *pickup* location is assigned into a pixel on a "checker board"-like grid.
|
where each *pickup* location is assigned into a pixel on a "checker board"-like grid.
|
||||||
The main part of the source code that implements that is in this [file](https://github.com/webartifex/urban-meal-delivery/blob/main/src/urban_meal_delivery/db/grids.py#L60).
|
The main part of the source code that implements that is in this [file](src/velofy/db/grids.py#L60).
|
||||||
Visualizations of the various grids can be found in the [visualizations/](https://github.com/webartifex/urban-meal-delivery/tree/main/research/visualizations) folder
|
Visualizations of the various grids can be found in the [visualizations/](research/visualizations) folder
|
||||||
and in this [notebook](https://nbviewer.jupyter.org/github/webartifex/urban-meal-delivery/blob/main/research/03_grid_visualizations.ipynb).
|
and in this [notebook](research/03_grid_visualizations.ipynb).
|
||||||
|
|
||||||
Then, demand is aggregated on a per-pixel level
|
Then, demand is aggregated on a per-pixel level
|
||||||
and different kinds of order time series are generated.
|
and different kinds of order time series are generated.
|
||||||
|
|
@ -46,8 +46,8 @@ and are thus used for tactical purposes, in particular predictive routing (cf.,
|
||||||
The details of how this works can be found in the first academic paper
|
The details of how this works can be found in the first academic paper
|
||||||
published in the context of this research project
|
published in the context of this research project
|
||||||
and titled "*Real-time Demand Forecasting for an Urban Delivery Platform*"
|
and titled "*Real-time Demand Forecasting for an Urban Delivery Platform*"
|
||||||
(cf., the [repository](https://github.com/webartifex/urban-meal-delivery-demand-forecasting) with the LaTeX files).
|
(cf., the [repository](https://code.webartifex.de/alexander/velofy-forecasting) with the LaTeX files).
|
||||||
All demand forecasting related code is in the [forecasts/](https://github.com/webartifex/urban-meal-delivery/tree/main/src/urban_meal_delivery/forecasts) sub-package.
|
All demand forecasting related code is in the [forecasts/](src/velofy/forecasts) sub-package.
|
||||||
|
|
||||||
|
|
||||||
### Predictive Routing
|
### Predictive Routing
|
||||||
|
|
@ -59,23 +59,23 @@ All demand forecasting related code is in the [forecasts/](https://github.com/we
|
||||||
|
|
||||||
To play with the code developed for the analyses,
|
To play with the code developed for the analyses,
|
||||||
you can clone the project with [git](https://git-scm.com/)
|
you can clone the project with [git](https://git-scm.com/)
|
||||||
and install the contained `urban-meal-delivery` package
|
and install the contained `velofy` package
|
||||||
and all its dependencies
|
and all its dependencies
|
||||||
in a [virtual environment](https://docs.python.org/3/tutorial/venv.html)
|
in a [virtual environment](https://docs.python.org/3/tutorial/venv.html)
|
||||||
with [poetry](https://python-poetry.org/docs/):
|
with [uv](https://docs.astral.sh/uv/):
|
||||||
|
|
||||||
`git clone https://github.com/webartifex/urban-meal-delivery.git`
|
`git clone ssh://git@git.webartifex.de/alexander/velofy.git`
|
||||||
|
|
||||||
and
|
and
|
||||||
|
|
||||||
`poetry install --extras research`
|
`uv sync --extra research`
|
||||||
|
|
||||||
The `--extras` option is necessary as the non-develop dependencies
|
The `--extra` option is necessary as the non-develop dependencies
|
||||||
are structured in the [pyproject.toml](https://github.com/webartifex/urban-meal-delivery/blob/main/pyproject.toml) file
|
are structured in the [pyproject.toml](pyproject.toml) file
|
||||||
into dependencies related to only the `urban-meal-delivery` source code package
|
into dependencies related to only the `velofy` source code package
|
||||||
and dependencies used to run the [Jupyter](https://jupyter.org/) environment
|
and dependencies used to run the [Jupyter](https://jupyter.org/) environment
|
||||||
with the analyses.
|
with the analyses.
|
||||||
|
|
||||||
Contributions are welcome.
|
Contributions are welcome.
|
||||||
Use the [issues](https://github.com/webartifex/urban-meal-delivery/issues) tab.
|
Use the [issues](https://code.webartifex.de/alexander/velofy/issues) tab.
|
||||||
The project is licensed under the [MIT license](https://github.com/webartifex/urban-meal-delivery/blob/main/LICENSE.txt).
|
The project is licensed under the [MIT license](LICENSE.txt).
|
||||||
|
|
|
||||||
16
docs/conf.py
16
docs/conf.py
|
|
@ -1,15 +1,15 @@
|
||||||
"""Configure sphinx."""
|
"""Configure sphinx."""
|
||||||
|
|
||||||
import urban_meal_delivery as umd
|
import velofy
|
||||||
|
|
||||||
|
|
||||||
project = umd.__pkg_name__
|
project = velofy.__pkg_name__
|
||||||
author = umd.__author__
|
author = velofy.__author__
|
||||||
copyright = f'2020, {author}'
|
project_copyright = f"2020, {author}"
|
||||||
version = release = umd.__version__
|
version = release = velofy.__version__
|
||||||
|
|
||||||
extensions = [
|
extensions = [
|
||||||
'sphinx.ext.autodoc',
|
"sphinx.ext.autodoc",
|
||||||
'sphinx.ext.napoleon',
|
"sphinx.ext.napoleon",
|
||||||
'sphinx_autodoc_typehints',
|
"sphinx_autodoc_typehints",
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ Urban Meal Delivery
|
||||||
reference
|
reference
|
||||||
|
|
||||||
|
|
||||||
This is the documentation for the `urban-meal-delivery` package
|
This is the documentation for the `velofy` package
|
||||||
that contains all the source code
|
that contains all the source code
|
||||||
used in a research project
|
used in a research project
|
||||||
residing in this `repository`_.
|
residing in this `repository`_.
|
||||||
|
|
@ -25,13 +25,13 @@ All other software is automatically installed (cf., next section).
|
||||||
Installation
|
Installation
|
||||||
------------
|
------------
|
||||||
|
|
||||||
The `urban-meal-delivery` package is installed
|
The `velofy` package is installed
|
||||||
only after cloning the `repository`_.
|
only after cloning the `repository`_.
|
||||||
It is *not* available on `PyPI`_ via `pip`_.
|
It is *not* available on `PyPI`_ via `pip`_.
|
||||||
|
|
||||||
.. code-block:: console
|
.. code-block:: console
|
||||||
|
|
||||||
$ git clone https://github.com/webartifex/urban-meal-delivery.git
|
$ git clone ssh://git@git.webartifex.de/alexander/velofy.git
|
||||||
|
|
||||||
Use `poetry`_ to install the package
|
Use `poetry`_ to install the package
|
||||||
with its dependencies into a `virtual environment`_,
|
with its dependencies into a `virtual environment`_,
|
||||||
|
|
@ -91,5 +91,5 @@ You can use them to choose among the different tasks you want to achieve.
|
||||||
.. _poetry: https://python-poetry.org/docs/
|
.. _poetry: https://python-poetry.org/docs/
|
||||||
.. _pypi: https://pypi.org/
|
.. _pypi: https://pypi.org/
|
||||||
.. _python: https://docs.python.org/3/
|
.. _python: https://docs.python.org/3/
|
||||||
.. _repository: https://github.com/webartifex/urban-meal-delivery
|
.. _repository: https://code.webartifex.de/alexander/velofy
|
||||||
.. _virtual environment: https://docs.python.org/3/tutorial/venv.html
|
.. _virtual environment: https://docs.python.org/3/tutorial/venv.html
|
||||||
|
|
|
||||||
|
|
@ -6,43 +6,41 @@ from logging import config as log_config
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from alembic import context
|
from alembic import context
|
||||||
|
|
||||||
from urban_meal_delivery import config as umd_config
|
from velofy import config as pkg_config
|
||||||
from urban_meal_delivery import db
|
from velofy import db
|
||||||
|
|
||||||
|
|
||||||
# Disable the --sql option, a.k.a, the "offline mode".
|
# Disable the --sql option, a.k.a, the "offline mode"
|
||||||
if context.is_offline_mode():
|
if context.is_offline_mode():
|
||||||
raise NotImplementedError('The --sql option is not implemented in this project')
|
msg = "The --sql option is not implemented in this project"
|
||||||
|
raise NotImplementedError(msg)
|
||||||
|
|
||||||
|
|
||||||
# Set up the default Python logger from the alembic.ini file.
|
# Set up the default Python logger from the alembic.ini file
|
||||||
log_config.fileConfig(context.config.config_file_name)
|
log_config.fileConfig(context.config.config_file_name)
|
||||||
|
|
||||||
|
|
||||||
def include_object(obj, _name, type_, _reflected, _compare_to):
|
def include_object(obj, _name, type_, _reflected, _compare_to):
|
||||||
"""Only include the clean schema into --autogenerate migrations."""
|
"""Only include the clean schema into --autogenerate migrations."""
|
||||||
if ( # noqa:WPS337
|
return not (
|
||||||
type_ in {'table', 'column'}
|
type_ in {"table", "column"}
|
||||||
and hasattr(obj, 'schema') # noqa:WPS421 => fix for rare edge case
|
and hasattr(obj, "schema") # => Fix for rare edge case
|
||||||
and obj.schema != umd_config.CLEAN_SCHEMA
|
and obj.schema != pkg_config.CLEAN_SCHEMA
|
||||||
):
|
)
|
||||||
return False
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
engine = sa.create_engine(umd_config.DATABASE_URI)
|
# Without a `pool`, the `connection` really closes after the migrations
|
||||||
|
engine = sa.create_engine(pkg_config.DATABASE_URI, poolclass=sa.pool.NullPool)
|
||||||
|
|
||||||
|
test_schema = f"_{pkg_config.CLEAN_SCHEMA}" if os.getenv("TESTING") else ""
|
||||||
|
|
||||||
with engine.connect() as connection:
|
with engine.connect() as connection:
|
||||||
context.configure(
|
context.configure(
|
||||||
connection=connection,
|
connection=connection,
|
||||||
include_object=include_object,
|
include_object=include_object,
|
||||||
target_metadata=db.Base.metadata,
|
target_metadata=db.Base.metadata,
|
||||||
version_table='{alembic_table}{test_schema}'.format(
|
version_table=f"{pkg_config.ALEMBIC_TABLE}{test_schema}",
|
||||||
alembic_table=umd_config.ALEMBIC_TABLE,
|
version_table_schema=pkg_config.ALEMBIC_TABLE_SCHEMA,
|
||||||
test_schema=(f'_{umd_config.CLEAN_SCHEMA}' if os.getenv('TESTING') else ''),
|
|
||||||
),
|
|
||||||
version_table_schema=umd_config.ALEMBIC_TABLE_SCHEMA,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
with context.begin_transaction():
|
with context.begin_transaction():
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,4 @@
|
||||||
"""${message}.
|
"""${message}."""
|
||||||
|
|
||||||
Revision: # ${up_revision} at ${create_date}
|
|
||||||
Revises: # ${down_revision | comma,n}
|
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
@ -10,7 +6,8 @@ import sqlalchemy as sa
|
||||||
from alembic import op
|
from alembic import op
|
||||||
${imports if imports else ""}
|
${imports if imports else ""}
|
||||||
|
|
||||||
from urban_meal_delivery import configuration
|
from velofy import configuration
|
||||||
|
|
||||||
|
|
||||||
revision = ${repr(up_revision)}
|
revision = ${repr(up_revision)}
|
||||||
down_revision = ${repr(down_revision)}
|
down_revision = ${repr(down_revision)}
|
||||||
|
|
@ -18,14 +15,14 @@ branch_labels = ${repr(branch_labels)}
|
||||||
depends_on = ${repr(depends_on)}
|
depends_on = ${repr(depends_on)}
|
||||||
|
|
||||||
|
|
||||||
config = configuration.make_config('testing' if os.getenv('TESTING') else 'production')
|
config = configuration.make_config("testing" if os.getenv("TESTING") else "production")
|
||||||
|
|
||||||
|
|
||||||
def upgrade():
|
def upgrade():
|
||||||
"""Upgrade to revision ${up_revision}."""
|
"""Upgrade to the next revision."""
|
||||||
${upgrades if upgrades else "pass"}
|
${upgrades if upgrades else "pass"}
|
||||||
|
|
||||||
|
|
||||||
def downgrade():
|
def downgrade():
|
||||||
"""Downgrade to revision ${down_revision}."""
|
"""Downgrade to the previous revision."""
|
||||||
${downgrades if downgrades else "pass"}
|
${downgrades if downgrades else "pass"}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,167 +1,176 @@
|
||||||
"""Add pixel grid.
|
"""Add pixel grid."""
|
||||||
|
|
||||||
Revision: #888e352d7526 at 2021-01-02 18:11:02
|
|
||||||
Revises: #f11cd76d2f45
|
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
from urban_meal_delivery import configuration
|
from velofy import configuration
|
||||||
|
|
||||||
|
|
||||||
revision = '888e352d7526'
|
revision = "888e352d7526"
|
||||||
down_revision = 'f11cd76d2f45'
|
down_revision = "f11cd76d2f45"
|
||||||
branch_labels = None
|
branch_labels = None
|
||||||
depends_on = None
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
config = configuration.make_config('testing' if os.getenv('TESTING') else 'production')
|
config = configuration.make_config("testing" if os.getenv("TESTING") else "production")
|
||||||
|
|
||||||
|
|
||||||
def upgrade():
|
def upgrade():
|
||||||
"""Upgrade to revision 888e352d7526."""
|
"""Upgrade to the next revision."""
|
||||||
op.create_table(
|
op.create_table(
|
||||||
'grids',
|
"grids",
|
||||||
sa.Column('id', sa.SmallInteger(), autoincrement=True, nullable=False),
|
sa.Column("id", sa.SmallInteger(), autoincrement=True, nullable=False),
|
||||||
sa.Column('city_id', sa.SmallInteger(), nullable=False),
|
sa.Column("city_id", sa.SmallInteger(), nullable=False),
|
||||||
sa.Column('side_length', sa.SmallInteger(), nullable=True),
|
sa.Column("side_length", sa.SmallInteger(), nullable=True),
|
||||||
sa.PrimaryKeyConstraint('id', name=op.f('pk_grids')),
|
sa.PrimaryKeyConstraint("id", name=op.f("pk_grids")),
|
||||||
sa.ForeignKeyConstraint(
|
sa.ForeignKeyConstraint(
|
||||||
['city_id'],
|
["city_id"],
|
||||||
[f'{config.CLEAN_SCHEMA}.cities.id'],
|
[f"{config.CLEAN_SCHEMA}.cities.id"],
|
||||||
name=op.f('fk_grids_to_cities_via_city_id'),
|
name=op.f("fk_grids_to_cities_via_city_id"),
|
||||||
onupdate='RESTRICT',
|
onupdate="RESTRICT",
|
||||||
ondelete='RESTRICT',
|
ondelete="RESTRICT",
|
||||||
),
|
),
|
||||||
sa.UniqueConstraint(
|
sa.UniqueConstraint(
|
||||||
'city_id', 'side_length', name=op.f('uq_grids_on_city_id_side_length'),
|
"city_id",
|
||||||
|
"side_length",
|
||||||
|
name=op.f("uq_grids_on_city_id_side_length"),
|
||||||
),
|
),
|
||||||
# This `UniqueConstraint` is needed by the `addresses_pixels` table below.
|
# This `UniqueConstraint` is needed by the `addresses_pixels` table below
|
||||||
sa.UniqueConstraint('id', 'city_id', name=op.f('uq_grids_on_id_city_id')),
|
sa.UniqueConstraint("id", "city_id", name=op.f("uq_grids_on_id_city_id")),
|
||||||
schema=config.CLEAN_SCHEMA,
|
schema=config.CLEAN_SCHEMA,
|
||||||
)
|
)
|
||||||
|
|
||||||
op.create_table(
|
op.create_table(
|
||||||
'pixels',
|
"pixels",
|
||||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
|
||||||
sa.Column('grid_id', sa.SmallInteger(), nullable=False),
|
sa.Column("grid_id", sa.SmallInteger(), nullable=False),
|
||||||
sa.Column('n_x', sa.SmallInteger(), nullable=False),
|
sa.Column("n_x", sa.SmallInteger(), nullable=False),
|
||||||
sa.Column('n_y', sa.SmallInteger(), nullable=False),
|
sa.Column("n_y", sa.SmallInteger(), nullable=False),
|
||||||
sa.CheckConstraint('0 <= n_x', name=op.f('ck_pixels_on_n_x_is_positive')),
|
sa.CheckConstraint("0 <= n_x", name=op.f("ck_pixels_on_n_x_is_positive")),
|
||||||
sa.CheckConstraint('0 <= n_y', name=op.f('ck_pixels_on_n_y_is_positive')),
|
sa.CheckConstraint("0 <= n_y", name=op.f("ck_pixels_on_n_y_is_positive")),
|
||||||
sa.ForeignKeyConstraint(
|
sa.ForeignKeyConstraint(
|
||||||
['grid_id'],
|
["grid_id"],
|
||||||
[f'{config.CLEAN_SCHEMA}.grids.id'],
|
[f"{config.CLEAN_SCHEMA}.grids.id"],
|
||||||
name=op.f('fk_pixels_to_grids_via_grid_id'),
|
name=op.f("fk_pixels_to_grids_via_grid_id"),
|
||||||
onupdate='RESTRICT',
|
onupdate="RESTRICT",
|
||||||
ondelete='RESTRICT',
|
ondelete="RESTRICT",
|
||||||
),
|
),
|
||||||
sa.PrimaryKeyConstraint('id', name=op.f('pk_pixels')),
|
sa.PrimaryKeyConstraint("id", name=op.f("pk_pixels")),
|
||||||
sa.UniqueConstraint(
|
sa.UniqueConstraint(
|
||||||
'grid_id', 'n_x', 'n_y', name=op.f('uq_pixels_on_grid_id_n_x_n_y'),
|
"grid_id",
|
||||||
|
"n_x",
|
||||||
|
"n_y",
|
||||||
|
name=op.f("uq_pixels_on_grid_id_n_x_n_y"),
|
||||||
),
|
),
|
||||||
sa.UniqueConstraint('id', 'grid_id', name=op.f('uq_pixels_on_id_grid_id')),
|
sa.UniqueConstraint("id", "grid_id", name=op.f("uq_pixels_on_id_grid_id")),
|
||||||
schema=config.CLEAN_SCHEMA,
|
schema=config.CLEAN_SCHEMA,
|
||||||
)
|
)
|
||||||
|
|
||||||
op.create_index(
|
op.create_index(
|
||||||
op.f('ix_pixels_on_grid_id'),
|
op.f("ix_pixels_on_grid_id"),
|
||||||
'pixels',
|
"pixels",
|
||||||
['grid_id'],
|
["grid_id"],
|
||||||
unique=False,
|
unique=False,
|
||||||
schema=config.CLEAN_SCHEMA,
|
schema=config.CLEAN_SCHEMA,
|
||||||
)
|
)
|
||||||
op.create_index(
|
op.create_index(
|
||||||
op.f('ix_pixels_on_n_x'),
|
op.f("ix_pixels_on_n_x"),
|
||||||
'pixels',
|
"pixels",
|
||||||
['n_x'],
|
["n_x"],
|
||||||
unique=False,
|
unique=False,
|
||||||
schema=config.CLEAN_SCHEMA,
|
schema=config.CLEAN_SCHEMA,
|
||||||
)
|
)
|
||||||
op.create_index(
|
op.create_index(
|
||||||
op.f('ix_pixels_on_n_y'),
|
op.f("ix_pixels_on_n_y"),
|
||||||
'pixels',
|
"pixels",
|
||||||
['n_y'],
|
["n_y"],
|
||||||
unique=False,
|
unique=False,
|
||||||
schema=config.CLEAN_SCHEMA,
|
schema=config.CLEAN_SCHEMA,
|
||||||
)
|
)
|
||||||
|
|
||||||
# This `UniqueConstraint` is needed by the `addresses_pixels` table below.
|
# This `UniqueConstraint` is needed by the `addresses_pixels` table below
|
||||||
op.create_unique_constraint(
|
op.create_unique_constraint(
|
||||||
'uq_addresses_on_id_city_id',
|
"uq_addresses_on_id_city_id",
|
||||||
'addresses',
|
"addresses",
|
||||||
['id', 'city_id'],
|
["id", "city_id"],
|
||||||
schema=config.CLEAN_SCHEMA,
|
schema=config.CLEAN_SCHEMA,
|
||||||
)
|
)
|
||||||
|
|
||||||
op.create_table(
|
op.create_table(
|
||||||
'addresses_pixels',
|
"addresses_pixels",
|
||||||
sa.Column('address_id', sa.Integer(), nullable=False),
|
sa.Column("address_id", sa.Integer(), nullable=False),
|
||||||
sa.Column('city_id', sa.SmallInteger(), nullable=False),
|
sa.Column("city_id", sa.SmallInteger(), nullable=False),
|
||||||
sa.Column('grid_id', sa.SmallInteger(), nullable=False),
|
sa.Column("grid_id", sa.SmallInteger(), nullable=False),
|
||||||
sa.Column('pixel_id', sa.Integer(), nullable=False),
|
sa.Column("pixel_id", sa.Integer(), nullable=False),
|
||||||
sa.ForeignKeyConstraint(
|
sa.ForeignKeyConstraint(
|
||||||
['address_id', 'city_id'],
|
["address_id", "city_id"],
|
||||||
[
|
[
|
||||||
f'{config.CLEAN_SCHEMA}.addresses.id',
|
f"{config.CLEAN_SCHEMA}.addresses.id",
|
||||||
f'{config.CLEAN_SCHEMA}.addresses.city_id',
|
f"{config.CLEAN_SCHEMA}.addresses.city_id",
|
||||||
],
|
],
|
||||||
name=op.f('fk_addresses_pixels_to_addresses_via_address_id_city_id'),
|
name=op.f("fk_addresses_pixels_to_addresses_via_address_id_city_id"),
|
||||||
onupdate='RESTRICT',
|
onupdate="RESTRICT",
|
||||||
ondelete='RESTRICT',
|
ondelete="RESTRICT",
|
||||||
),
|
),
|
||||||
sa.ForeignKeyConstraint(
|
sa.ForeignKeyConstraint(
|
||||||
['grid_id', 'city_id'],
|
["grid_id", "city_id"],
|
||||||
[
|
[
|
||||||
f'{config.CLEAN_SCHEMA}.grids.id',
|
f"{config.CLEAN_SCHEMA}.grids.id",
|
||||||
f'{config.CLEAN_SCHEMA}.grids.city_id',
|
f"{config.CLEAN_SCHEMA}.grids.city_id",
|
||||||
],
|
],
|
||||||
name=op.f('fk_addresses_pixels_to_grids_via_grid_id_city_id'),
|
name=op.f("fk_addresses_pixels_to_grids_via_grid_id_city_id"),
|
||||||
onupdate='RESTRICT',
|
onupdate="RESTRICT",
|
||||||
ondelete='RESTRICT',
|
ondelete="RESTRICT",
|
||||||
),
|
),
|
||||||
sa.ForeignKeyConstraint(
|
sa.ForeignKeyConstraint(
|
||||||
['pixel_id', 'grid_id'],
|
["pixel_id", "grid_id"],
|
||||||
[
|
[
|
||||||
f'{config.CLEAN_SCHEMA}.pixels.id',
|
f"{config.CLEAN_SCHEMA}.pixels.id",
|
||||||
f'{config.CLEAN_SCHEMA}.pixels.grid_id',
|
f"{config.CLEAN_SCHEMA}.pixels.grid_id",
|
||||||
],
|
],
|
||||||
name=op.f('fk_addresses_pixels_to_pixels_via_pixel_id_grid_id'),
|
name=op.f("fk_addresses_pixels_to_pixels_via_pixel_id_grid_id"),
|
||||||
onupdate='RESTRICT',
|
onupdate="RESTRICT",
|
||||||
ondelete='RESTRICT',
|
ondelete="RESTRICT",
|
||||||
),
|
),
|
||||||
sa.PrimaryKeyConstraint(
|
sa.PrimaryKeyConstraint(
|
||||||
'address_id', 'pixel_id', name=op.f('pk_addresses_pixels'),
|
"address_id",
|
||||||
|
"pixel_id",
|
||||||
|
name=op.f("pk_addresses_pixels"),
|
||||||
),
|
),
|
||||||
sa.UniqueConstraint(
|
sa.UniqueConstraint(
|
||||||
'address_id',
|
"address_id",
|
||||||
'grid_id',
|
"grid_id",
|
||||||
name=op.f('uq_addresses_pixels_on_address_id_grid_id'),
|
name=op.f("uq_addresses_pixels_on_address_id_grid_id"),
|
||||||
),
|
),
|
||||||
schema=config.CLEAN_SCHEMA,
|
schema=config.CLEAN_SCHEMA,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def downgrade():
|
def downgrade():
|
||||||
"""Downgrade to revision f11cd76d2f45."""
|
"""Downgrade to the previous revision."""
|
||||||
op.drop_table('addresses_pixels', schema=config.CLEAN_SCHEMA)
|
op.drop_table("addresses_pixels", schema=config.CLEAN_SCHEMA)
|
||||||
op.drop_constraint(
|
op.drop_constraint(
|
||||||
'uq_addresses_on_id_city_id',
|
"uq_addresses_on_id_city_id",
|
||||||
'addresses',
|
"addresses",
|
||||||
type_=None,
|
type_=None,
|
||||||
schema=config.CLEAN_SCHEMA,
|
schema=config.CLEAN_SCHEMA,
|
||||||
)
|
)
|
||||||
op.drop_index(
|
op.drop_index(
|
||||||
op.f('ix_pixels_on_n_y'), table_name='pixels', schema=config.CLEAN_SCHEMA,
|
op.f("ix_pixels_on_n_y"),
|
||||||
|
table_name="pixels",
|
||||||
|
schema=config.CLEAN_SCHEMA,
|
||||||
)
|
)
|
||||||
op.drop_index(
|
op.drop_index(
|
||||||
op.f('ix_pixels_on_n_x'), table_name='pixels', schema=config.CLEAN_SCHEMA,
|
op.f("ix_pixels_on_n_x"),
|
||||||
|
table_name="pixels",
|
||||||
|
schema=config.CLEAN_SCHEMA,
|
||||||
)
|
)
|
||||||
op.drop_index(
|
op.drop_index(
|
||||||
op.f('ix_pixels_on_grid_id'), table_name='pixels', schema=config.CLEAN_SCHEMA,
|
op.f("ix_pixels_on_grid_id"),
|
||||||
|
table_name="pixels",
|
||||||
|
schema=config.CLEAN_SCHEMA,
|
||||||
)
|
)
|
||||||
op.drop_table('pixels', schema=config.CLEAN_SCHEMA)
|
op.drop_table("pixels", schema=config.CLEAN_SCHEMA)
|
||||||
op.drop_table('grids', schema=config.CLEAN_SCHEMA)
|
op.drop_table("grids", schema=config.CLEAN_SCHEMA)
|
||||||
|
|
|
||||||
|
|
@ -1,45 +1,41 @@
|
||||||
"""Add demand forecasting.
|
"""Add demand forecasting."""
|
||||||
|
|
||||||
Revision: #e40623e10405 at 2021-01-06 19:55:56
|
|
||||||
Revises: #888e352d7526
|
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from alembic import op
|
from alembic import op
|
||||||
from sqlalchemy.dialects import postgresql
|
from sqlalchemy.dialects import postgresql as psql
|
||||||
|
|
||||||
from urban_meal_delivery import configuration
|
from velofy import configuration
|
||||||
|
|
||||||
|
|
||||||
revision = 'e40623e10405'
|
revision = "e40623e10405"
|
||||||
down_revision = '888e352d7526'
|
down_revision = "888e352d7526"
|
||||||
branch_labels = None
|
branch_labels = None
|
||||||
depends_on = None
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
config = configuration.make_config('testing' if os.getenv('TESTING') else 'production')
|
config = configuration.make_config("testing" if os.getenv("TESTING") else "production")
|
||||||
|
|
||||||
|
|
||||||
def upgrade():
|
def upgrade():
|
||||||
"""Upgrade to revision e40623e10405."""
|
"""Upgrade to the next revision."""
|
||||||
op.create_table(
|
op.create_table(
|
||||||
'forecasts',
|
"forecasts",
|
||||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
|
||||||
sa.Column('pixel_id', sa.Integer(), nullable=False),
|
sa.Column("pixel_id", sa.Integer(), nullable=False),
|
||||||
sa.Column('start_at', sa.DateTime(), nullable=False),
|
sa.Column("start_at", sa.DateTime(), nullable=False),
|
||||||
sa.Column('time_step', sa.SmallInteger(), nullable=False),
|
sa.Column("time_step", sa.SmallInteger(), nullable=False),
|
||||||
sa.Column('training_horizon', sa.SmallInteger(), nullable=False),
|
sa.Column("training_horizon", sa.SmallInteger(), nullable=False),
|
||||||
sa.Column('method', sa.Unicode(length=20), nullable=False),
|
sa.Column("method", sa.Unicode(length=20), nullable=False),
|
||||||
sa.Column('prediction', postgresql.DOUBLE_PRECISION(), nullable=False),
|
sa.Column("prediction", psql.DOUBLE_PRECISION(), nullable=False),
|
||||||
sa.PrimaryKeyConstraint('id', name=op.f('pk_forecasts')),
|
sa.PrimaryKeyConstraint("id", name=op.f("pk_forecasts")),
|
||||||
sa.ForeignKeyConstraint(
|
sa.ForeignKeyConstraint(
|
||||||
['pixel_id'],
|
["pixel_id"],
|
||||||
[f'{config.CLEAN_SCHEMA}.pixels.id'],
|
[f"{config.CLEAN_SCHEMA}.pixels.id"],
|
||||||
name=op.f('fk_forecasts_to_pixels_via_pixel_id'),
|
name=op.f("fk_forecasts_to_pixels_via_pixel_id"),
|
||||||
onupdate='RESTRICT',
|
onupdate="RESTRICT",
|
||||||
ondelete='RESTRICT',
|
ondelete="RESTRICT",
|
||||||
),
|
),
|
||||||
sa.CheckConstraint(
|
sa.CheckConstraint(
|
||||||
"""
|
"""
|
||||||
|
|
@ -49,48 +45,49 @@ def upgrade():
|
||||||
EXTRACT(HOUR FROM start_at) > 22
|
EXTRACT(HOUR FROM start_at) > 22
|
||||||
)
|
)
|
||||||
""",
|
""",
|
||||||
name=op.f('ck_forecasts_on_start_at_must_be_within_operating_hours'),
|
name=op.f("ck_forecasts_on_start_at_must_be_within_operating_hours"),
|
||||||
),
|
),
|
||||||
sa.CheckConstraint(
|
sa.CheckConstraint(
|
||||||
'CAST(EXTRACT(MINUTES FROM start_at) AS INTEGER) % 15 = 0',
|
"CAST(EXTRACT(MINUTES FROM start_at) AS INTEGER) % 15 = 0",
|
||||||
name=op.f('ck_forecasts_on_start_at_minutes_must_be_quarters_of_the_hour'),
|
name=op.f("ck_forecasts_on_start_at_minutes_must_be_quarters_of_the_hour"),
|
||||||
),
|
),
|
||||||
sa.CheckConstraint(
|
sa.CheckConstraint(
|
||||||
'CAST(EXTRACT(MICROSECONDS FROM start_at) AS INTEGER) % 1000000 = 0',
|
"CAST(EXTRACT(MICROSECONDS FROM start_at) AS INTEGER) % 1000000 = 0",
|
||||||
name=op.f('ck_forecasts_on_start_at_allows_no_microseconds'),
|
name=op.f("ck_forecasts_on_start_at_allows_no_microseconds"),
|
||||||
),
|
),
|
||||||
sa.CheckConstraint(
|
sa.CheckConstraint(
|
||||||
'EXTRACT(SECONDS FROM start_at) = 0',
|
"EXTRACT(SECONDS FROM start_at) = 0",
|
||||||
name=op.f('ck_forecasts_on_start_at_allows_no_seconds'),
|
name=op.f("ck_forecasts_on_start_at_allows_no_seconds"),
|
||||||
),
|
),
|
||||||
sa.CheckConstraint(
|
sa.CheckConstraint(
|
||||||
'time_step > 0', name=op.f('ck_forecasts_on_time_step_must_be_positive'),
|
"time_step > 0",
|
||||||
|
name=op.f("ck_forecasts_on_time_step_must_be_positive"),
|
||||||
),
|
),
|
||||||
sa.CheckConstraint(
|
sa.CheckConstraint(
|
||||||
'training_horizon > 0',
|
"training_horizon > 0",
|
||||||
name=op.f('ck_forecasts_on_training_horizon_must_be_positive'),
|
name=op.f("ck_forecasts_on_training_horizon_must_be_positive"),
|
||||||
),
|
),
|
||||||
sa.UniqueConstraint(
|
sa.UniqueConstraint(
|
||||||
'pixel_id',
|
"pixel_id",
|
||||||
'start_at',
|
"start_at",
|
||||||
'time_step',
|
"time_step",
|
||||||
'training_horizon',
|
"training_horizon",
|
||||||
'method',
|
"method",
|
||||||
name=op.f(
|
name=op.f(
|
||||||
'uq_forecasts_on_pixel_id_start_at_time_step_training_horizon_method',
|
"uq_forecasts_on_pixel_id_start_at_time_step_training_horizon_method",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
schema=config.CLEAN_SCHEMA,
|
schema=config.CLEAN_SCHEMA,
|
||||||
)
|
)
|
||||||
op.create_index(
|
op.create_index(
|
||||||
op.f('ix_forecasts_on_pixel_id'),
|
op.f("ix_forecasts_on_pixel_id"),
|
||||||
'forecasts',
|
"forecasts",
|
||||||
['pixel_id'],
|
["pixel_id"],
|
||||||
unique=False,
|
unique=False,
|
||||||
schema=config.CLEAN_SCHEMA,
|
schema=config.CLEAN_SCHEMA,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def downgrade():
|
def downgrade():
|
||||||
"""Downgrade to revision 888e352d7526."""
|
"""Downgrade to the previous revision."""
|
||||||
op.drop_table('forecasts', schema=config.CLEAN_SCHEMA)
|
op.drop_table("forecasts", schema=config.CLEAN_SCHEMA)
|
||||||
|
|
|
||||||
|
|
@ -1,55 +1,54 @@
|
||||||
"""Add confidence intervals to forecasts.
|
"""Add confidence intervals to forecasts."""
|
||||||
|
|
||||||
Revision: #26711cd3f9b9 at 2021-01-20 16:08:21
|
|
||||||
Revises: #e40623e10405
|
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from alembic import op
|
from alembic import op
|
||||||
from sqlalchemy.dialects import postgresql
|
from sqlalchemy.dialects import postgresql as psql
|
||||||
|
|
||||||
from urban_meal_delivery import configuration
|
from velofy import configuration
|
||||||
|
|
||||||
|
|
||||||
revision = '26711cd3f9b9'
|
revision = "26711cd3f9b9"
|
||||||
down_revision = 'e40623e10405'
|
down_revision = "e40623e10405"
|
||||||
branch_labels = None
|
branch_labels = None
|
||||||
depends_on = None
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
config = configuration.make_config('testing' if os.getenv('TESTING') else 'production')
|
config = configuration.make_config("testing" if os.getenv("TESTING") else "production")
|
||||||
|
|
||||||
|
|
||||||
def upgrade():
|
def upgrade():
|
||||||
"""Upgrade to revision 26711cd3f9b9."""
|
"""Upgrade to the next revision."""
|
||||||
op.alter_column(
|
op.alter_column(
|
||||||
'forecasts', 'method', new_column_name='model', schema=config.CLEAN_SCHEMA,
|
"forecasts",
|
||||||
)
|
"method",
|
||||||
op.add_column(
|
new_column_name="model",
|
||||||
'forecasts',
|
|
||||||
sa.Column('low80', postgresql.DOUBLE_PRECISION(), nullable=True),
|
|
||||||
schema=config.CLEAN_SCHEMA,
|
schema=config.CLEAN_SCHEMA,
|
||||||
)
|
)
|
||||||
op.add_column(
|
op.add_column(
|
||||||
'forecasts',
|
"forecasts",
|
||||||
sa.Column('high80', postgresql.DOUBLE_PRECISION(), nullable=True),
|
sa.Column("low80", psql.DOUBLE_PRECISION(), nullable=True),
|
||||||
schema=config.CLEAN_SCHEMA,
|
schema=config.CLEAN_SCHEMA,
|
||||||
)
|
)
|
||||||
op.add_column(
|
op.add_column(
|
||||||
'forecasts',
|
"forecasts",
|
||||||
sa.Column('low95', postgresql.DOUBLE_PRECISION(), nullable=True),
|
sa.Column("high80", psql.DOUBLE_PRECISION(), nullable=True),
|
||||||
schema=config.CLEAN_SCHEMA,
|
schema=config.CLEAN_SCHEMA,
|
||||||
)
|
)
|
||||||
op.add_column(
|
op.add_column(
|
||||||
'forecasts',
|
"forecasts",
|
||||||
sa.Column('high95', postgresql.DOUBLE_PRECISION(), nullable=True),
|
sa.Column("low95", psql.DOUBLE_PRECISION(), nullable=True),
|
||||||
|
schema=config.CLEAN_SCHEMA,
|
||||||
|
)
|
||||||
|
op.add_column(
|
||||||
|
"forecasts",
|
||||||
|
sa.Column("high95", psql.DOUBLE_PRECISION(), nullable=True),
|
||||||
schema=config.CLEAN_SCHEMA,
|
schema=config.CLEAN_SCHEMA,
|
||||||
)
|
)
|
||||||
op.create_check_constraint(
|
op.create_check_constraint(
|
||||||
op.f('ck_forecasts_on_ci_upper_and_lower_bounds'),
|
op.f("ck_forecasts_on_ci_upper_and_lower_bounds"),
|
||||||
'forecasts',
|
"forecasts",
|
||||||
"""
|
"""
|
||||||
NOT (
|
NOT (
|
||||||
low80 IS NULL AND high80 IS NOT NULL
|
low80 IS NULL AND high80 IS NOT NULL
|
||||||
|
|
@ -64,8 +63,8 @@ def upgrade():
|
||||||
schema=config.CLEAN_SCHEMA,
|
schema=config.CLEAN_SCHEMA,
|
||||||
)
|
)
|
||||||
op.create_check_constraint(
|
op.create_check_constraint(
|
||||||
op.f('prediction_must_be_within_ci'),
|
op.f("prediction_must_be_within_ci"),
|
||||||
'forecasts',
|
"forecasts",
|
||||||
"""
|
"""
|
||||||
NOT (
|
NOT (
|
||||||
prediction < low80
|
prediction < low80
|
||||||
|
|
@ -80,8 +79,8 @@ def upgrade():
|
||||||
schema=config.CLEAN_SCHEMA,
|
schema=config.CLEAN_SCHEMA,
|
||||||
)
|
)
|
||||||
op.create_check_constraint(
|
op.create_check_constraint(
|
||||||
op.f('ci_upper_bound_greater_than_lower_bound'),
|
op.f("ci_upper_bound_greater_than_lower_bound"),
|
||||||
'forecasts',
|
"forecasts",
|
||||||
"""
|
"""
|
||||||
NOT (
|
NOT (
|
||||||
low80 > high80
|
low80 > high80
|
||||||
|
|
@ -92,8 +91,8 @@ def upgrade():
|
||||||
schema=config.CLEAN_SCHEMA,
|
schema=config.CLEAN_SCHEMA,
|
||||||
)
|
)
|
||||||
op.create_check_constraint(
|
op.create_check_constraint(
|
||||||
op.f('ci95_must_be_wider_than_ci80'),
|
op.f("ci95_must_be_wider_than_ci80"),
|
||||||
'forecasts',
|
"forecasts",
|
||||||
"""
|
"""
|
||||||
NOT (
|
NOT (
|
||||||
low80 < low95
|
low80 < low95
|
||||||
|
|
@ -106,19 +105,30 @@ def upgrade():
|
||||||
|
|
||||||
|
|
||||||
def downgrade():
|
def downgrade():
|
||||||
"""Downgrade to revision e40623e10405."""
|
"""Downgrade to the previous revision."""
|
||||||
op.alter_column(
|
op.alter_column(
|
||||||
'forecasts', 'model', new_column_name='method', schema=config.CLEAN_SCHEMA,
|
"forecasts",
|
||||||
|
"model",
|
||||||
|
new_column_name="method",
|
||||||
|
schema=config.CLEAN_SCHEMA,
|
||||||
)
|
)
|
||||||
op.drop_column(
|
op.drop_column(
|
||||||
'forecasts', 'low80', schema=config.CLEAN_SCHEMA,
|
"forecasts",
|
||||||
|
"low80",
|
||||||
|
schema=config.CLEAN_SCHEMA,
|
||||||
)
|
)
|
||||||
op.drop_column(
|
op.drop_column(
|
||||||
'forecasts', 'high80', schema=config.CLEAN_SCHEMA,
|
"forecasts",
|
||||||
|
"high80",
|
||||||
|
schema=config.CLEAN_SCHEMA,
|
||||||
)
|
)
|
||||||
op.drop_column(
|
op.drop_column(
|
||||||
'forecasts', 'low95', schema=config.CLEAN_SCHEMA,
|
"forecasts",
|
||||||
|
"low95",
|
||||||
|
schema=config.CLEAN_SCHEMA,
|
||||||
)
|
)
|
||||||
op.drop_column(
|
op.drop_column(
|
||||||
'forecasts', 'high95', schema=config.CLEAN_SCHEMA,
|
"forecasts",
|
||||||
|
"high95",
|
||||||
|
schema=config.CLEAN_SCHEMA,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -126,16 +126,16 @@ import os
|
||||||
|
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
from urban_meal_delivery import configuration
|
from velofy import configuration
|
||||||
|
|
||||||
|
|
||||||
revision = 'e86290e7305e'
|
revision = "e86290e7305e"
|
||||||
down_revision = '26711cd3f9b9'
|
down_revision = "26711cd3f9b9"
|
||||||
branch_labels = None
|
branch_labels = None
|
||||||
depends_on = None
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
config = configuration.make_config('testing' if os.getenv('TESTING') else 'production')
|
config = configuration.make_config("testing" if os.getenv("TESTING") else "production")
|
||||||
|
|
||||||
|
|
||||||
def upgrade():
|
def upgrade():
|
||||||
|
|
@ -326,7 +326,7 @@ def upgrade():
|
||||||
""",
|
""",
|
||||||
)
|
)
|
||||||
|
|
||||||
# 4) Ensure every `Restaurant` has only one `Order.pickup_address`.
|
# 4) Ensure every `Restaurant` has only one `Order.pickup_address`
|
||||||
op.execute(
|
op.execute(
|
||||||
f"""
|
f"""
|
||||||
UPDATE
|
UPDATE
|
||||||
|
|
@ -347,26 +347,26 @@ def upgrade():
|
||||||
""",
|
""",
|
||||||
)
|
)
|
||||||
op.create_unique_constraint(
|
op.create_unique_constraint(
|
||||||
'uq_restaurants_on_id_address_id',
|
"uq_restaurants_on_id_address_id",
|
||||||
'restaurants',
|
"restaurants",
|
||||||
['id', 'address_id'],
|
["id", "address_id"],
|
||||||
schema=config.CLEAN_SCHEMA,
|
schema=config.CLEAN_SCHEMA,
|
||||||
)
|
)
|
||||||
op.create_foreign_key(
|
op.create_foreign_key(
|
||||||
op.f('fk_orders_to_restaurants_via_restaurant_id_pickup_address_id'),
|
op.f("fk_orders_to_restaurants_via_restaurant_id_pickup_address_id"),
|
||||||
'orders',
|
"orders",
|
||||||
'restaurants',
|
"restaurants",
|
||||||
['restaurant_id', 'pickup_address_id'],
|
["restaurant_id", "pickup_address_id"],
|
||||||
['id', 'address_id'],
|
["id", "address_id"],
|
||||||
source_schema=config.CLEAN_SCHEMA,
|
source_schema=config.CLEAN_SCHEMA,
|
||||||
referent_schema=config.CLEAN_SCHEMA,
|
referent_schema=config.CLEAN_SCHEMA,
|
||||||
onupdate='RESTRICT',
|
onupdate="RESTRICT",
|
||||||
ondelete='RESTRICT',
|
ondelete="RESTRICT",
|
||||||
)
|
)
|
||||||
op.drop_constraint(
|
op.drop_constraint(
|
||||||
'fk_orders_to_restaurants_via_restaurant_id',
|
"fk_orders_to_restaurants_via_restaurant_id",
|
||||||
'orders',
|
"orders",
|
||||||
type_='foreignkey',
|
type_="foreignkey",
|
||||||
schema=config.CLEAN_SCHEMA,
|
schema=config.CLEAN_SCHEMA,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -374,25 +374,25 @@ def upgrade():
|
||||||
def downgrade():
|
def downgrade():
|
||||||
"""Downgrade to revision 26711cd3f9b9."""
|
"""Downgrade to revision 26711cd3f9b9."""
|
||||||
op.create_foreign_key(
|
op.create_foreign_key(
|
||||||
op.f('fk_orders_to_restaurants_via_restaurant_id'),
|
op.f("fk_orders_to_restaurants_via_restaurant_id"),
|
||||||
'orders',
|
"orders",
|
||||||
'restaurants',
|
"restaurants",
|
||||||
['restaurant_id'],
|
["restaurant_id"],
|
||||||
['id'],
|
["id"],
|
||||||
source_schema=config.CLEAN_SCHEMA,
|
source_schema=config.CLEAN_SCHEMA,
|
||||||
referent_schema=config.CLEAN_SCHEMA,
|
referent_schema=config.CLEAN_SCHEMA,
|
||||||
onupdate='RESTRICT',
|
onupdate="RESTRICT",
|
||||||
ondelete='RESTRICT',
|
ondelete="RESTRICT",
|
||||||
)
|
)
|
||||||
op.drop_constraint(
|
op.drop_constraint(
|
||||||
'fk_orders_to_restaurants_via_restaurant_id_pickup_address_id',
|
"fk_orders_to_restaurants_via_restaurant_id_pickup_address_id",
|
||||||
'orders',
|
"orders",
|
||||||
type_='foreignkey',
|
type_="foreignkey",
|
||||||
schema=config.CLEAN_SCHEMA,
|
schema=config.CLEAN_SCHEMA,
|
||||||
)
|
)
|
||||||
op.drop_constraint(
|
op.drop_constraint(
|
||||||
'uq_restaurants_on_id_address_id',
|
"uq_restaurants_on_id_address_id",
|
||||||
'restaurants',
|
"restaurants",
|
||||||
type_='unique',
|
type_="unique",
|
||||||
schema=config.CLEAN_SCHEMA,
|
schema=config.CLEAN_SCHEMA,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -9,33 +9,33 @@ import os
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
from urban_meal_delivery import configuration
|
from velofy import configuration
|
||||||
|
|
||||||
|
|
||||||
revision = 'c2af85bada01'
|
revision = "c2af85bada01"
|
||||||
down_revision = 'e86290e7305e'
|
down_revision = "e86290e7305e"
|
||||||
branch_labels = None
|
branch_labels = None
|
||||||
depends_on = None
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
config = configuration.make_config('testing' if os.getenv('TESTING') else 'production')
|
config = configuration.make_config("testing" if os.getenv("TESTING") else "production")
|
||||||
|
|
||||||
|
|
||||||
def upgrade():
|
def upgrade():
|
||||||
"""Upgrade to revision c2af85bada01."""
|
"""Upgrade to revision c2af85bada01."""
|
||||||
op.add_column(
|
op.add_column(
|
||||||
'forecasts',
|
"forecasts",
|
||||||
sa.Column('actual', sa.SmallInteger(), nullable=False),
|
sa.Column("actual", sa.SmallInteger(), nullable=False),
|
||||||
schema=config.CLEAN_SCHEMA,
|
schema=config.CLEAN_SCHEMA,
|
||||||
)
|
)
|
||||||
op.create_check_constraint(
|
op.create_check_constraint(
|
||||||
op.f('ck_forecasts_on_actuals_must_be_non_negative'),
|
op.f("ck_forecasts_on_actuals_must_be_non_negative"),
|
||||||
'forecasts',
|
"forecasts",
|
||||||
'actual >= 0',
|
"actual >= 0",
|
||||||
schema=config.CLEAN_SCHEMA,
|
schema=config.CLEAN_SCHEMA,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def downgrade():
|
def downgrade():
|
||||||
"""Downgrade to revision e86290e7305e."""
|
"""Downgrade to revision e86290e7305e."""
|
||||||
op.drop_column('forecasts', 'actual', schema=config.CLEAN_SCHEMA)
|
op.drop_column("forecasts", "actual", schema=config.CLEAN_SCHEMA)
|
||||||
|
|
|
||||||
|
|
@ -8,16 +8,16 @@ import os
|
||||||
|
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
from urban_meal_delivery import configuration
|
from velofy import configuration
|
||||||
|
|
||||||
|
|
||||||
revision = '8bfb928a31f8'
|
revision = "8bfb928a31f8"
|
||||||
down_revision = 'c2af85bada01'
|
down_revision = "c2af85bada01"
|
||||||
branch_labels = None
|
branch_labels = None
|
||||||
depends_on = None
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
config = configuration.make_config('testing' if os.getenv('TESTING') else 'production')
|
config = configuration.make_config("testing" if os.getenv("TESTING") else "production")
|
||||||
|
|
||||||
|
|
||||||
def upgrade():
|
def upgrade():
|
||||||
|
|
@ -31,7 +31,7 @@ def upgrade():
|
||||||
TO
|
TO
|
||||||
train_horizon;
|
train_horizon;
|
||||||
""",
|
""",
|
||||||
) # noqa:WPS355
|
)
|
||||||
|
|
||||||
|
|
||||||
def downgrade():
|
def downgrade():
|
||||||
|
|
@ -45,4 +45,4 @@ def downgrade():
|
||||||
TO
|
TO
|
||||||
training_horizon;
|
training_horizon;
|
||||||
""",
|
""",
|
||||||
) # noqa:WPS355
|
)
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue