Skip to content

Commit 275d27e

Browse files
committed
1 parent 734070e commit 275d27e

File tree

9 files changed

+80
-1
lines changed

9 files changed

+80
-1
lines changed

.github/workflows/data.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,14 @@ jobs:
2020
with:
2121
tests: frame/tests
2222
test-entry-point: pytest
23-
working-directory: frame
23+
working-directory: frame
24+
dash:
25+
runs-on: ubuntu-latest
26+
env:
27+
container: dash
28+
steps:
29+
- uses: actions/checkout@main
30+
- run: export DOCKER_BUILDKIT=1
31+
- run: docker build -t dash:latest visualization/app/dash
32+
- run: docker run --name $container -d dash:latest
33+
- run: curl https://raw.githubusercontent.com/davidkhala/containers/refs/heads/main/cli/health.sh | bash -s wait-until-healthy $container

visualization/README.md

Whitespace-only changes.

visualization/app/dash/Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM python
2+
RUN pip install dash
3+
RUN pip install pandas
4+
ADD gapminder_unfiltered.py .
5+
HEALTHCHECK --interval=1s CMD curl --fail http://localhost:8050/health || exit 1
6+
ENTRYPOINT [ "python", "gapminder_unfiltered.py" ]
7+
EXPOSE 8050
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from dash import Dash, html, dcc, callback, Output, Input
2+
from plotly import express
3+
import pandas
4+
5+
df = pandas.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/gapminder_unfiltered.csv')
6+
7+
app = Dash()
8+
9+
app.layout = [
10+
html.H1(children='Title of Dash App', style={'textAlign': 'center'}),
11+
dcc.Dropdown(df.country.unique(), 'Canada', id='dropdown-selection'),
12+
dcc.Graph(id='graph-content')
13+
]
14+
15+
16+
@callback(
17+
Output('graph-content', 'figure'),
18+
Input('dropdown-selection', 'value')
19+
)
20+
def update_graph(value):
21+
dff = df[df.country == value]
22+
return express.line(dff, x='year', y='pop')
23+
24+
25+
@app.server.route('/health')
26+
def is_health():
27+
return 'OK'
28+
29+
30+
if __name__ == '__main__':
31+
app.run('0.0.0.0', debug=True)

visualization/davidkhala/data/visualization/dash/__init__.py

Whitespace-only changes.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Matplotlib library
2+
> The Matplotlib library requires data to be in a Pandas dataframe rather than a Spark dataframe
3+
- > [**toPandas** method is used to convert it](https://learn.microsoft.com/en-us/training/modules/use-apache-spark-work-files-lakehouse/6-visualize-data)
4+
5+
6+
> Python supports a large selection of packages; most of them built on the base **Matplotlib** library.

visualization/davidkhala/data/visualization/matplotlib/__init__.py

Whitespace-only changes.

visualization/davidkhala/data/visualization/streamlit/__init__.py

Whitespace-only changes.

visualization/pyproject.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[project]
2+
name = "davidkhala.data.visualization"
3+
version = "0.0.0"
4+
description = "data visualization tools"
5+
readme = "README.md"
6+
requires-python = ">=3.12"
7+
dependencies = []
8+
9+
[project.optional-dependencies]
10+
dash = ["dash"]
11+
streamlit = ["streamlit"]
12+
13+
14+
[dependency-groups]
15+
dev = ["pytest","pandas"]
16+
17+
[tool.hatch.build.targets.sdist]
18+
include = ["davidkhala"]
19+
20+
[tool.hatch.build.targets.wheel]
21+
include = ["davidkhala"]
22+
23+
[build-system]
24+
requires = ["hatchling"]
25+
build-backend = "hatchling.build"

0 commit comments

Comments
 (0)