This repo is a template to quick start a streamlit application for proof of concept projects
Table of Contents
This Python project is managed via Poetry, and leverages the pyproject.toml
configuration file, rather than the older setup.py.
The pyproject.toml configuration file can be and is also used to store 3rd party tools configurations, such as black, ruff, mypy etc.
Install the project and its poetry dependencies, by using:
poetry env use `which python 3.12`
poetry add streamlit seaborn tqdm matplotlib altair pydantic plotly numpy pandas
poetry add --group lsp-dev pylsp-mypy python-lsp-server
poetry installRun the app without entering the virtual environment with:
poetry run streamlit run template_streamlit/main.pyAlternatively, the virtual environment can be activated with:
source ./activate.shor if this doesn't work try
source $(poetry env info -p)/bin/activateAnd then the streamlit app can be manually run:
streamlit run template_streamlit/main.pyIn order to use poetry, you should install it first. If your OS package manager has
a python-poetry package, you might also choose to install Poetry that way. Notice that if you do this, you should make sure that your OS
also ships all the necessary plugins you might want to use (most importantly, poetry-plugin-export). As of the time of writing, Archlinux does.
To add a dependency, simply run:
poetry add 3rd-party-packageTo remove a dependency, run:
poetry remove 3rd-party-packageTo add a dev dependency, run:
poetry add dev-dep-package --group devIn this template, we also create one (or more) additional dependency group(s) to deal with IDE specific dependencies.
For instance, if you want to use the python-lsp-server, as well as installing
its plugins for mypy etc., then you can use the lsp-dev group.
poetry install --with dev --with lsp-devPoetry has some nice shortcuts to manage the project version. You can see them by running
poetry version --helpFor instance, bumping to the next minor version can be done with:
poetry version minorThis would be a project from, e.g., 1.2 to 1.3. A major bump can be done with:
poetry version majorPoetry can do more than this, consult the documentation for more information.
see streamlit docs for details
Look here for a cheat-sheet of commands and often used widgets
To customize the theme or adjust rendering logic of e.g. the sidebar, create / update the .streamlit/config.toml file in your root folder.
For example, as an app grows, one might want to hide the sidebar with showSidebarNavigation = true and implement their own menu.
You can also configure server, client and browser options; for all options see the docs.
Available streamlit plugins can be found here. For example for
- more ui tools/components,
- additional charting,
- a simple kind of authentication or
- chatbot functionality
Install pre-commit.
Pre-commit framework need to get initialized.
task pre-commit:initRun the following to fix linting issues using pre-commit.
task pre-commit:runBased on pre-commit gitleaks dependencies Go language needs to be installed.
All changes require a PR and review. Create a new branch and reference a Jira ticket, f.e.
git switch -c feature/INPRO-1-configure-resource