streamlit-demo
Streamlit application powered by a PyScaffold project setup.
Work in progress: The idea of this repo is to demonstrate how to package a streamlit app using PyScaffold. Since streamlit currently doesn't support apps as proper Python packages, this example is still suboptimal. Following Github issue was created to improve the current situation.
The structure was created with:
putup --dsproject streamlit-demo -p git_overview \
-d "Streamlit application powered by a PyScaffold project setup." \
-u https://github.com/pyscaffold/streamlit-demo
then the actual code was taken from git-overview (MIT-licensed) and changed into a proper Python package layout.
The advantages over the original codebase are:
- wheel file for distribution can be easily build with
tox -e build
, - unit tests can be easily added in the
tests
folder, extract-repo
is now a shell command (available after installation) instead of a scriptrepo.py
,git_overview
is a Python package that could be reused by other Python projects after installation,- all the other advantages of a PyScaffold layout...
Installation & Running the dashboard
In order to set up the necessary environment:
- create and activate the environment
streamlit-demo
with the help of conda:conda env create -f environment.yml conda activate streamlit-demo
environment.lock.yml
to recreate an environment with pinned dependencies.
NOTE: The conda environment will have streamlit-demo installed in editable mode. Some changes, e.g. in
setup.cfg
, might require you to runpip install -e .
again.
-
run the dashboard with:
streamlit run scripts/show_dashboard.py
-
or (optionally) build a docker image and run it with:
docker build -t local/streamlit-demo:latest . docker run -p 8501:8501 local/streamlit-demo:latest
-
open the dashboard at http://localhost:8501.
Project Organization
โโโ AUTHORS.md <- List of developers and maintainers.
โโโ CHANGELOG.md <- Changelog to keep track of new features and fixes.
โโโ CONTRIBUTING.md <- Guidelines for contributing to this project.
โโโ Dockerfile <- Build a docker container with `docker build .`.
โโโ LICENSE.txt <- License as chosen on the command-line.
โโโ README.md <- The top-level README for developers.
โโโ docs <- Directory for Sphinx documentation in rst or md.
โโโ environment.yml <- The conda environment file for reproducibility.
โโโ pyproject.toml <- Build configuration. Don't change! Use `pip install -e .`
โ to install for development or to build `tox -e build`.
โโโ scripts <- Entry-script `show_dashboard.py` for streamlit
โโโ setup.cfg <- Declarative configuration of your project.
โโโ setup.py <- [DEPRECATED] obsolete way of building and installation.
โโโ src
โ โโโ git_overview <- Actual Python package `git-overview` with the main functionality.
โ โโโ __init__.py
โ โโโ dashboard.py <- Layout-function of the actual dashboard.
โ โโโ repo.py <- Functions to download repo data.
โ โโโ utils.py <- Some dashboard-related helpers
โโโ tests <- Unit tests which can be run with `pytest`.
โโโ .coveragerc <- Configuration for coverage reports of unit tests.
โโโ .isort.cfg <- Configuration for git hook that sorts imports.
โโโ .pre-commit-config.yaml <- Configuration of pre-commit git hooks.
This structure is in strong contrast to the original one:
โโโ app
โ โโโ dashboard.py <- Dashboard entry-point
โ โโโ __init__.py
โ โโโ repo.py <- Script to download repo data
โ โโโ utils.py <- Some dashboard-related helpers
โโโ Dockerfile
โโโ README.md
โโโ requirements.txt
Note
This project has been set up using PyScaffold 4.1.1.post1.dev28+g075b76f and the dsproject extension 0.6.1.post28+g91ab61a.