Skip to content
/ sample-py Public template

A sample python with streamlit and fastapi keeping minimal features to kicstart

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE-PYTHON
Notifications You must be signed in to change notification settings

recursivezero/sample-py

Fabric Generator and Search Utility

A Streamlit template for Recursive Zero repository

Installation Guide

Prerequisites

  • Python ≥ 3.11
  • Poetry ≥ 2.2.1
  • Streamlit ≥ 1.49.1

Getting Started

Poetry Setup

curl -sSL https://install.python-poetry.org | python3 -
# OR
pip install poetry>=2.2.1

Virtual Environment Configuration

poetry config virtualenvs.path /your/desired/path

Ensure below files are configured (create if not exist) properly to run the project;

  • .env.local,
  • .env, and
  • .streamlit/secrets.toml

Install Dependencies

poetry lock --no-cache --regenerate
poetry install  --all-extras --with dev

Or manually

poetry install

How to Run

Run Streamlit App

poetry run sample dev

Access: http://localhost:8501

Run FastAPI Server

poetry run sample api
# OR
python src/api/fast_api.py

Access: http://127.0.0.1:5000

🧹 Linting & Code Quality

Pre-commit hooks are enabled. If commits fail, run:

poetry run lint

or run individual

poetry run black .
poetry run flake8 .
poetry run mypy .
poetry run ruff check .

Build & Packaging

Build Package

poetry clean
poetry build

Artifacts in dist/

  • sample-x.y.0-py3-none-any.whl
  • sample-x.y.0.tar.gz

Test Locally

python -m venv .venv-dist
source .venv-dist/bin/activate
# Windows
.venv-dist\Scripts\activate

Install package

pip install dist/*.whl
pip install --upgrade dist/*.whl
# Install extras:
pip install sample

CLI Shortcuts

sample dev → Launch Streamlit UI

sample api → Launch FastAPI

current version will be printed on start of above commands.

Install GIT hooks

these hooks will

  • Check for lint and audit for security before commit
  • Append branch name in commit message
  • Generate requirements.txt on checkout on new branch
# Install git hooks
poetry run ./scripts/setup-hooks.sh

there is .vscode/Python.code-profile file; import this as a profile in vscode which include necessary extension for python development.

Troubleshooting

sometimes there might be chances that virtual environment get corrupted then delete the old virtual environment and start afresh.

poetry env info
# this will provide virtual environment name
poetry env remove <environment-full-name>

License

MIT

References

About

A sample python with streamlit and fastapi keeping minimal features to kicstart

Resources

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE-PYTHON

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •