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
extract-repois now a shell command (available after installation) instead of a script
git_overviewis 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-demowith the help of conda:
conda env create -f environment.yml conda activate streamlit-demo
environment.lock.ymlto 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 run
pip 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.
├── 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