Pin the dependencies ...

... after upgrading:
- alembic
- matplotlib
- pandas
- rpy2
- sqlalchemy
- statsmodels
- dev dependencies
  + coverage     + factory-boy    + faker                 + nox
  + packaging    + pre-commit     + flake8-annotations    + pytest
  + pytest-cov   + sphinx
- research dependencies
  + numpy        + pyty
- transient dependencies
  + astpretty    + atomicwrites   + bleach                + chardet
  + colorlog     + darglint       + flake8-comprehensions + gitpython
  + identify     + ipykernel      + ipython               + jedi
  + jinja2       + jupyter-client + jupyter-core          + mako
  + nbformat     + nest-asyncio   + notebook              + parso
  + pluggy       + prompt-toolkit + ptyprocess            + pygments
  + pyyaml       + pyzmq          + requests              + smmap
  + terminado    + textfixtures   + snowballstemmer       + typed-ast
  + urllib3      + virtualenv

- fix SQL statements written in raw text
This commit is contained in:
Alexander Hess 2021-02-04 12:21:41 +01:00
parent 50b35a8284
commit 0da86e5f07
Signed by: alexander
GPG key ID: 344EA5AB10D868E0
3 changed files with 504 additions and 481 deletions

866
poetry.lock generated

File diff suppressed because it is too large Load diff

View file

@ -218,6 +218,7 @@ class City(meta.Base):
all_zip_codes = sorted( all_zip_codes = sorted(
row[0] row[0]
for row in db.session.execute( for row in db.session.execute(
sa.text(
f""" -- # noqa:S608 f""" -- # noqa:S608
SELECT DISTINCT SELECT DISTINCT
zip_code zip_code
@ -226,6 +227,7 @@ class City(meta.Base):
WHERE WHERE
city_id = {self.id}; city_id = {self.id};
""", """,
),
) )
) )
cmap = utils.make_random_cmap(len(all_zip_codes), bright=False) cmap = utils.make_random_cmap(len(all_zip_codes), bright=False)

View file

@ -6,6 +6,7 @@ import datetime as dt
from typing import Tuple from typing import Tuple
import pandas as pd import pandas as pd
import sqlalchemy as sa
from urban_meal_delivery import config from urban_meal_delivery import config
from urban_meal_delivery import db from urban_meal_delivery import db
@ -68,7 +69,8 @@ class OrderHistory:
# `data` is probably missing "pixel_id"-"start_at" pairs. # `data` is probably missing "pixel_id"-"start_at" pairs.
# This happens when there is no demand in the `Pixel` in the given `time_step`. # This happens when there is no demand in the `Pixel` in the given `time_step`.
data = pd.read_sql_query( data = pd.read_sql_query(
f"""-- # noqa:E501,WPS221 sa.text(
f""" -- # noqa:WPS221
SELECT SELECT
pixel_id, pixel_id,
start_at, start_at,
@ -80,9 +82,11 @@ class OrderHistory:
FROM ( FROM (
SELECT SELECT
pixels.pixel_id, pixels.pixel_id,
DATE_TRUNC('MINUTE', orders.placed_at) AS placed_at_without_seconds, DATE_TRUNC('MINUTE', orders.placed_at)
AS placed_at_without_seconds,
(( ((
EXTRACT(MINUTES FROM orders.placed_at)::INTEGER % {self._time_step} EXTRACT(MINUTES FROM orders.placed_at)::INTEGER
% {self._time_step}
)::TEXT || ' MINUTES')::INTERVAL )::TEXT || ' MINUTES')::INTERVAL
AS minutes_to_be_cut AS minutes_to_be_cut
FROM ( FROM (
@ -114,7 +118,7 @@ class OrderHistory:
WHERE WHERE
grid_id = {self._grid.id} grid_id = {self._grid.id}
AND AND
city_id = {self._grid.city.id} -- redundant -> sanity check city_id = {self._grid.city.id} -- -> sanity check
) AS pixels ) AS pixels
ON orders.pickup_address_id = pixels.address_id ON orders.pickup_address_id = pixels.address_id
) AS placed_at_aggregated_into_start_at ) AS placed_at_aggregated_into_start_at
@ -126,6 +130,7 @@ class OrderHistory:
pixel_id, pixel_id,
start_at; start_at;
""", """,
), # noqa:WPS355
con=db.connection, con=db.connection,
index_col=['pixel_id', 'start_at'], index_col=['pixel_id', 'start_at'],
) )