Skip to content

Commit 2ded548

Browse files
committed
[MZ] Created app template
1 parent bf90f28 commit 2ded548

10 files changed

Lines changed: 177 additions & 1 deletion

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,6 @@ dmypy.json
127127

128128
# Pyre type checker
129129
.pyre/
130+
131+
# Manuel's additions
132+
.vscode/

Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM python:3.7-alpine
2+
3+
RUN apk update && apk add bash make automake gcc g++ subversion python3-dev
4+
5+
# We copy just the requirements.txt first to leverage cache
6+
COPY ./requirements.txt /app/requirements.txt
7+
8+
WORKDIR /app
9+
10+
RUN python3 -m pip install -r requirements.txt
11+
12+
COPY . /app
13+
14+
EXPOSE 3001
15+
16+
CMD ["python3", "src/app.py"]

Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
all: sort-imports format type-check test
2+
3+
.PHONY: sort-imports format type-check test
4+
5+
SHELL=/bin/bash
6+
SHELLFLAGS=-euo pipefail -c
7+
8+
sort-imports:
9+
python3 -m isort --atomic app tests
10+
11+
format:
12+
python3 -m black app tests
13+
14+
type-check:
15+
python3 -m mypy app
16+
17+
test:
18+
python3 -m pytest -o log_cli=true tests

README.md

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,61 @@
1-
# zoe_challenge
1+
# zoe_challenge
2+
3+
## Prerequisites
4+
5+
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
6+
7+
The code is run and tested with Python 3.7.7 on macOS 10.14.6.
8+
9+
### Environment
10+
11+
Clone the repo to your local machine.
12+
13+
Create a virtual environment for Python 3 with:
14+
15+
python3 -m pip install virtualenv
16+
python3 -m virtualenv -p python3 env
17+
18+
Activate the virtual environment with:
19+
20+
source env/bin/activate
21+
22+
Install the required Python packages with:
23+
24+
pip3 install -r requirements.txt
25+
26+
27+
## Run the app
28+
29+
The `Dockerfile` can be used to build an image and deploy it locally:
30+
Make sure you have Docker installed:
31+
32+
docker -v
33+
34+
Build the image with:
35+
36+
docker build --tag emoji-app:latest .
37+
38+
Run the container locally:
39+
40+
docker run --name emoji-app:latest -p 3001:3001 app
41+
42+
You can now trigger the endpoint (`localhost:3001`), for example using `nc`.
43+
44+
<!-- TODO -->
45+
<!-- Include usage info -->
46+
47+
## Development and testing
48+
49+
Use the `Makefile` you can run `make <cmd>` where `<cmd>` is one of:
50+
51+
* `sort-imports` to ensure Python imports are in the correct PEP format
52+
* `format` to format Python files using black
53+
* `type-check` to run `mypy` static type checking
54+
* `test` to run unittests using `pytest`
55+
* `all` to run all the above steps
56+
57+
or just type `make`/`make all`, which will run all of the above.
58+
59+
## Authors
60+
61+
* Manuel Zander

app/app.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env python
2+
3+
import logging
4+
5+
import coloredlogs
6+
7+
logger = logging.getLogger(__name__)
8+
coloredlogs.install(level="INFO")

app/config.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env python
2+
3+
import logging
4+
5+
import coloredlogs
6+
7+
logger = logging.getLogger(__name__)
8+
coloredlogs.install(level="INFO")

app/utils.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env python
2+
3+
import logging
4+
5+
import coloredlogs
6+
7+
logger = logging.getLogger(__name__)
8+
coloredlogs.install(level="INFO")

mypy.ini

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[mypy]
2+
python_version = 3.7
3+
4+
warn_return_any = True
5+
warn_unreachable = True
6+
warn_unused_ignores = True
7+
warn_unused_configs = True
8+
9+
disallow_untyped_defs = True
10+
11+
ignore_missing_imports = True

requirements.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
appdirs==1.4.4
2+
attrs==19.3.0
3+
black==19.10b0
4+
click==7.1.2
5+
coloredlogs==14.0
6+
humanfriendly==8.2
7+
importlib-metadata==1.7.0
8+
isort==5.0.9
9+
more-itertools==8.4.0
10+
mypy==0.782
11+
mypy-extensions==0.4.3
12+
packaging==20.4
13+
pathspec==0.8.0
14+
pluggy==0.13.1
15+
py==1.9.0
16+
pyparsing==2.4.7
17+
pytest==5.4.3
18+
regex==2020.6.8
19+
six==1.15.0
20+
toml==0.10.1
21+
typed-ast==1.4.1
22+
typing-extensions==3.7.4.2
23+
wcwidth==0.2.5
24+
zipp==3.1.0

tests/test_app.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import os
2+
import unittest
3+
from pathlib import Path
4+
5+
ROOT_DIR = Path(os.path.dirname(os.path.abspath(__file__))).parent
6+
7+
8+
class AppTestCase(unittest.TestCase):
9+
def setUp(self) -> None:
10+
pass
11+
12+
def test_manuel(self):
13+
self.assertEqual(True, True)
14+
15+
def tearDown(self) -> None:
16+
pass
17+
18+
19+
if __name__ == "__main__":
20+
unittest.main()

0 commit comments

Comments
 (0)