Skip to content
Jules van Rie edited this page Nov 3, 2024 · 2 revisions

Basic package setup for students to use

This is the front-end part of a generic boilerplate for basic ML/DL projects. It has the basic functionality for doing one-off predictions based on simple inputs (i.e. not on images for example, or large numbers of inputs).

It contains nothing more than all the configuration files for the project. No actual code.

What's being used:

  • Streamlit for the front end

Create your repo based on this template:

Hit the green Use this template button at the top of the template repo, or follow this link, to create a new repository.

Once created, clone your new repo to your (and your teammates') machines with the green <> Code button and your favourite method (probably GitHub CLI).

Repository structure (highlights)

  • app.py: main streamlit page
  • pages/: put a .py file per page here if you use multiple pages
  • media/: store visual elements for your pages here
  • .streamlit/: configuration files for streamlit

Complete the configuration

Complete the following files (if needed):

  • requirements.txt
  • .streamlit/config.toml: mainly for layout purposes
  • .streamlit/secrets.toml: base it on the sample file; reflect the contents also in the Secrets settings on Streamlit Cloud

Create a new virtual environment (different from the one for your backend, and install all packages:

  1. pyenv virtualenv 3.10.6 <your-project-name>-front
  2. pyenv local <your-project-name>-front
  3. pip install -r requirements.txt

When finished, run make test_structure, and check any errors or warnings.

Using make shortcuts:

All commands to run streamlit connecting to a local API or to an API running on GCP have been included in the Makefiles:

  • make streamlit: defaults to make streamlit_local
  • make streamlit_local: run streamlit locally and connect to local API (running through uvicorn on port 8000)
  • make streamlit_local_docker: run streamlit locally and connect to local Docker container (running on port 8080)
  • make streamlit_cloud: run streamlit locally and connect to cloud API

Just type make <tab> on the command line to list all possibilities

URIs for local and cloud APIs are included in the .streamlit/secrets.toml file (or in the Secrets setting on Streamlit Cloud)