Skip to content

Commit 48c0a2b

Browse files
committed
fix all the imports, get it all working
1 parent 9317b9f commit 48c0a2b

File tree

17 files changed

+44
-30
lines changed

17 files changed

+44
-30
lines changed

Dockerfile

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ FROM python:3.7-alpine
33
RUN apk add --no-cache --virtual .build-deps gcc postgresql-dev musl-dev python3-dev
44
RUN apk add libpq
55

6-
COPY requirements.txt /tmp
6+
COPY requirements.txt /tmp/
77
RUN pip install -r /tmp/requirements.txt
88

99
RUN apk del --no-cache .build-deps
1010

11-
RUN mkdir -p /code
12-
COPY *.py /code/
13-
WORKDIR /code
14-
RUN pip install .
15-
ENV FLASK_APP=flask_app.py FLASK_DEBUG=1 PYTHONUNBUFFERED=1
11+
RUN mkdir -p /src
12+
COPY src/ /src/
13+
RUN pip install -e /src
14+
COPY tests/ /tests/
15+
16+
WORKDIR /src
17+
ENV FLASK_APP=allocation/flask_app.py FLASK_DEBUG=1 PYTHONUNBUFFERED=1
1618
CMD flask run --host=0.0.0.0 --port=80

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ services:
1111
- DB_HOST=postgres
1212
- DB_PASSWORD=abc123
1313
volumes:
14-
- ./:/code
14+
- ./src:/src
1515
ports:
1616
- "5005:80"
1717

mypy.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
[mypy]
22
ignore_missing_imports = False
3+
namespace_packages = True
4+
mypy_path = ./src
35

46
[mypy-pytest.*]
57
ignore_missing_imports = True

src/allocation/flask_app.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
from sqlalchemy import create_engine
44
from sqlalchemy.orm import sessionmaker
55

6-
import config
7-
import model
8-
import orm
9-
import repository
10-
import services
6+
from allocation import config
7+
from allocation import orm
8+
from allocation import repository
9+
from allocation import model
10+
from allocation import services
1111

1212
orm.start_mappers()
1313
get_session = sessionmaker(bind=create_engine(config.get_postgres_uri()))
File renamed without changes.

src/allocation/orm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
)
55
from sqlalchemy.orm import mapper, relationship
66

7-
import model
7+
from allocation import model
88

99

1010
metadata = MetaData()

src/allocation/repository.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import abc
2-
import model
2+
from allocation import model
33

44

55
class AbstractRepository(abc.ABC):

services.py renamed to src/allocation/services.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
from typing import Optional
33
from datetime import date
44

5-
import model
6-
from model import OrderLine
7-
from repository import AbstractRepository
5+
from allocation.model import OrderLine
6+
from allocation.repository import AbstractRepository
7+
from allocation import model
8+
89

910
class InvalidSku(Exception):
1011
pass

src/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from setuptools import setup
22

33
setup(
4-
name='procurement',
4+
name='allocation',
55
version='0.1',
66
packages=['allocation'],
77
)
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
from sqlalchemy import create_engine
1010
from sqlalchemy.orm import sessionmaker, clear_mappers
1111

12-
from orm import metadata, start_mappers
13-
import config
12+
from allocation.orm import metadata, start_mappers
13+
from allocation import config
1414

1515

1616
@pytest.fixture
@@ -66,7 +66,7 @@ def postgres_session(postgres_db):
6666

6767
@pytest.fixture
6868
def restart_api():
69-
(Path(__file__).parent / 'flask_app.py').touch()
69+
(Path(__file__).parent / '../src/allocation/flask_app.py').touch()
7070
time.sleep(0.5)
7171
wait_for_webapp_to_come_up()
7272

0 commit comments

Comments
 (0)