Skip to content

Commit 88e154a

Browse files
committed
Update dependencies; formatting; spelling errors.
1 parent 1be7c83 commit 88e154a

File tree

25 files changed

+790
-579
lines changed

25 files changed

+790
-579
lines changed

.env.example

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
FLASK_APP=wsgi.py
21
FLASK_ENV=development
32
SECRET_KEY=randomstringofcharacters
43
LESS_BIN=/usr/local/bin/lessc

Makefile

Lines changed: 67 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,103 @@
1-
SRCPATH := $(CURDIR)
2-
PROJECTNAME := $(shell basename $(CURDIR))
1+
PROJECT_NAME := $(shell basename $CURDIR)
2+
VIRTUAL_ENVIRONMENT := $(CURDIR)/.venv
3+
LOCAL_PYTHON := $(VIRTUAL_ENVIRONMENT)/bin/python3
34

45
define HELP
5-
Manage $(PROJECTNAME). Usage:
6+
Manage $(PROJECT_NAME). Usage:
7+
8+
make run - Run $(PROJECT_NAME) locally.
9+
make install - Create local virtualenv & install dependencies.
10+
make deploy - Set up project & run locally.
11+
make update - Update dependencies via Poetry and output resulting `requirements.txt`.
12+
make format - Run Python code formatter & sort dependencies.
13+
make lint - Check code formatting with flake8.
14+
make clean - Remove extraneous compiled files, caches, logs, etc.
615

7-
make run - Run $(PROJECTNAME).
8-
make deploy - Install requirements and run app for the first time.
9-
make update - Update pip dependencies via Python Poetry.
10-
make format - Format code with Python's `Black` library.
11-
make clean - Remove cached files and lock files.
1216
endef
1317
export HELP
1418

15-
.PHONY: run deploy update format clean help
19+
20+
.PHONY: run install deploy update format lint clean help
1621

1722

18-
requirements: .requirements.txt
19-
env: .venv/bin/activate
23+
all help:
24+
@echo "$$HELP"
2025

2126

22-
.requirements.txt: requirements.txt
23-
$(shell . .venv/bin/activate && pip install -r requirements.txt)
27+
env: $(VIRTUAL_ENVIRONMENT)
2428

2529

26-
all help:
27-
@echo "$$HELP"
30+
$(VIRTUAL_ENVIRONMENT):
31+
if [ -d $(VIRTUAL_ENVIRONMENT) ]; then \
32+
@echo "Creating Python virtual environment..." && \
33+
python3 -m venv $(VIRTUAL_ENVIRONMENT) && \
34+
fi
2835

2936

3037
.PHONY: run
3138
run: env
32-
$(shell . .venv/bin/activate && flask run)
39+
$(shell python3 -m wsgi.py)
40+
41+
42+
.PHONY: install
43+
install:
44+
if [ ! -d "./.venv" ]; then python3 -m venv $(VIRTUAL_ENVIRONMENT); fi
45+
$(shell . .venv/bin/activate)
46+
$(LOCAL_PYTHON) -m pip install --upgrade pip setuptools wheel
47+
$(LOCAL_PYTHON) -m pip install -r requirements.txt
3348

3449

3550
.PHONY: deploy
3651
deploy:
37-
$(shell . ./deploy.sh)
52+
make clean
53+
make install
54+
make run
55+
56+
57+
.PHONY: test
58+
test: env
59+
$(LOCAL_PYTHON) -m \
60+
coverage run -m pytest -v \
61+
--disable-pytest-warnings \
62+
&& coverage html --title='Coverage Report' -d .reports \
63+
&& open .reports/index.html
3864

3965

4066
.PHONY: update
41-
update: env
42-
.venv/bin/python3 -m pip install -U pip
67+
update:
68+
if [ ! -d "./.venv" ]; then python3 -m venv $(VIRTUAL_ENVIRONMENT); fi
69+
$(LOCAL_PYTHON) -m pip install --upgrade pip setuptools wheel
4370
poetry update
4471
poetry export -f requirements.txt --output requirements.txt --without-hashes
4572

4673

4774
.PHONY: format
4875
format: env
49-
$(shell . .venv/bin/activate && isort ./)
50-
$(shell . .venv/bin/activate && black ./)
76+
isort --multi-line=3 .
77+
black .
78+
79+
80+
.PHONY: lint
81+
lint: env
82+
$(LOCAL_PYTHON) -m flake8 . --count \
83+
--select=E9,F63,F7,F82 \
84+
--exclude .git,.github,__pycache__,.pytest_cache,.venv,logs,creds,.venv,docs,logs,.reports \
85+
--show-source \
86+
--statistics
5187

5288

5389
.PHONY: clean
5490
clean:
5591
find . -name '*.pyc' -delete
5692
find . -name '__pycache__' -delete
5793
find . -name 'poetry.lock' -delete
58-
find . -name 'Pipefile.lock' -delete
94+
find . -name 'Pipefile.lock' -delete
95+
find . -name '*.log' -delete
96+
find . -name '.coverage' -delete
97+
find . -wholename 'logs/*.json' -delete
98+
find . -wholename '*/.pytest_cache' -delete
99+
find . -wholename '**/.pytest_cache' -delete
100+
find . -wholename './logs/*.json' -delete
101+
find . -wholename '.webassets-cache/*' -delete
102+
find . -wholename './logs' -delete
103+
find . -wholename './.reports' -delete

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Plotly Dash Flask Tutorial
22

3-
![Python](https://img.shields.io/badge/Python-^3.8-blue.svg?logo=python&longCache=true&logoColor=white&colorB=5e81ac&style=flat-square&colorA=4c566a)
4-
![Flask](https://img.shields.io/badge/Flask-1.1.2-blue.svg?longCache=true&logo=flask&style=flat-square&logoColor=white&colorB=5e81ac&colorA=4c566a)
3+
![Python](https://img.shields.io/badge/Python-^3.9-blue.svg?logo=python&longCache=true&logoColor=white&colorB=5e81ac&style=flat-square&colorA=4c566a)
4+
![Flask](https://img.shields.io/badge/Flask^2.0.0-blue.svg?longCache=true&logo=flask&style=flat-square&logoColor=white&colorB=5e81ac&colorA=4c566a)
55
![Flask-Assets](https://img.shields.io/badge/Flask--Assets-v2.0-blue.svg?longCache=true&logo=flask&style=flat-square&logoColor=white&colorB=5e81ac&colorA=4c566a)
6-
![Pandas](https://img.shields.io/badge/Pandas-v^1.0.0-blue.svg?longCache=true&logo=python&longCache=true&style=flat-square&logoColor=white&colorB=5e81ac&colorA=4c566a)
7-
![Dash](https://img.shields.io/badge/Dash-v1.12.0-blue.svg?longCache=true&logo=python&longCache=true&style=flat-square&logoColor=white&colorB=5e81ac&colorA=4c566a)
8-
![Plotly](https://img.shields.io/badge/Plotly-v4.8.1-blue.svg?longCache=true&logo=python&longCache=true&style=flat-square&logoColor=white&colorB=5e81ac&colorA=4c566a)
6+
![Pandas](https://img.shields.io/badge/Pandas-v^1.4.0-blue.svg?longCache=true&logo=python&longCache=true&style=flat-square&logoColor=white&colorB=5e81ac&colorA=4c566a)
7+
![Dash](https://img.shields.io/badge/Dash-v^2.0.0-blue.svg?longCache=true&logo=python&longCache=true&style=flat-square&logoColor=white&colorB=5e81ac&colorA=4c566a)
8+
![Plotly](https://img.shields.io/badge/Plotly-v^5.8.0-blue.svg?longCache=true&logo=python&longCache=true&style=flat-square&logoColor=white&colorB=5e81ac&colorA=4c566a)
99
![GitHub Last Commit](https://img.shields.io/github/last-commit/google/skia.svg?style=flat-square&colorA=4c566a&colorB=a3be8c)
1010
[![GitHub Issues](https://img.shields.io/github/issues/toddbirchard/plotlydash-flask-tutorial.svg?style=flat-square&colorA=4c566a&colorB=ebcb8b)](https://github.com/toddbirchard/plotlydash-flask-tutorial/issues)
1111
[![GitHub Stars](https://img.shields.io/github/stars/toddbirchard/plotlydash-flask-tutorial.svg?style=flat-square&colorB=ebcb8b&colorA=4c566a)](https://github.com/toddbirchard/plotlydash-flask-tutorial/stargazers)
@@ -26,7 +26,6 @@ Get set up locally in two steps:
2626

2727
Replace the values in **.env.example** with your values and rename this file to **.env**:
2828

29-
* `FLASK_APP`: Entry point of your application; should be `wsgi.py`.
3029
* `FLASK_ENV`: The environment in which to run your application; either `development` or `production`.
3130
* `SECRET_KEY`: Randomly generated string of characters used to encrypt your app's data.
3231
* `LESS_BIN` *(optional for static assets)*: Path to your local LESS installation via `which lessc`.
@@ -43,7 +42,7 @@ Get up and running with `make deploy`:
4342

4443
```shell
4544
$ git clone https://github.com/hackersandslackers/plotlydash-flask-tutorial.git
46-
$ cd plotlydash-flask-tutorial
45+
$ cd dashboard-flask-tutorial
4746
$ make deploy
4847
```
4948

config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Config:
1111
"""Flask configuration variables."""
1212

1313
# General Config
14-
FLASK_APP = environ.get("FLASK_APP")
14+
FLASK_APP = "wsgi.py"
1515
FLASK_ENV = environ.get("FLASK_ENV")
1616
SECRET_KEY = environ.get("SECRET_KEY")
1717

deploy.sh

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
"""Initialize Flask app."""
2-
from ddtrace import patch_all
32
from flask import Flask
43
from flask_assets import Environment
54

6-
patch_all()
7-
85

96
def init_app():
107
"""Construct core Flask application with embedded Dash app."""
@@ -19,7 +16,7 @@ def init_app():
1916
from .assets import compile_static_assets
2017

2118
# Import Dash application
22-
from .plotlydash.dashboard import init_dashboard
19+
from .dashboard import init_dashboard
2320

2421
app = init_dashboard(app)
2522

plotlyflask_tutorial/plotlydash/dashboard.py renamed to plotly_flask_tutorial/dashboard/__init__.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
"""Instantiate a Dash app."""
22
import dash
3-
import dash_core_components as dcc
4-
import dash_html_components as html
5-
import dash_table
6-
import numpy as np
7-
import pandas as pd
3+
from dash import dash_table
4+
from dash import dcc
5+
from dash import html
86

97
from .data import create_dataframe
108
from .layout import html_layout

0 commit comments

Comments
 (0)