decode_tools / docs /runbooks /local-setup.md
DecodeMarketing's picture
[ai-standards][slice-2] structure and dependency reproducibility (#9)
975d390 unverified
|
Raw History Blame Contribute Delete
3.87 kB

A newer version of the Streamlit SDK is available: 1.67.0

Upgrade

Local setup

How to run icat_app on your machine for development.

Prerequisites

  • Python 3.12 (matches HF Spaces deploy; see runtime.txt and .python-version).
  • Git with Git Bash on Windows (the repo's .githooks/ are bash scripts).
  • gh (GitHub CLI), optional but recommended for opening PRs.

One-time setup

git clone git@github.com:implicitdiagnosticsandsolutions/icat_app.git
cd icat_app
bash scripts/setup.sh          # wires .githooks/ into git via core.hooksPath
python -m venv .venv
source .venv/Scripts/activate  # Windows Git Bash
# or: source .venv/bin/activate    # macOS / Linux
pip install -r requirements.txt

scripts/setup.sh is idempotent. It is also invoked automatically by the ensure-setup.sh SessionStart hook the next time you open Claude Code in this repo.

If you prefer the exact pinned versions used in the deploy build (rather than re-resolving against the latest compatible), install from the lockfile instead:

pip install -r requirements.lock

requirements.lock is generated against Python 3.12 with uv pip compile. Do not regenerate it from Python 3.13+ — the resolution can differ from what HF Spaces actually installs.

Running the app

streamlit run app.py
# opens http://localhost:8501

The 8 tabs map 1-to-1 to the 8 files tab1.py through tab8.py. Shared helpers live in helper.py.

Verifying changes before commit

Run the structural validator:

python scripts/repo_validate.py

This compiles every *.py with py_compile, parses requirements.txt, and sanity-checks the README HF Spaces frontmatter. The same script runs on every PR via .github/workflows/repo_validate.yml.

For source-code changes, the reviewer subagent procedure in CLAUDE.md is mandatory before commit. The commit-msg hook will block any commit that modifies substantive files without a fresh .decode-reviewer-clean marker, unless the commit message contains [override-reviewer: <reason>].

Per-OS notes

Windows

  • Use Git Bash (or WSL) for git operations. PowerShell/CMD will not invoke the .githooks/ bash scripts.
  • If pip install of opencv-python-headless is slow, that is expected; it ships large native wheels.
  • The local Python interpreter should be 3.12. If you only have 3.13, you can still run the app for most tabs, but the requirements.lock resolution will not match HF Spaces. Install Python 3.12 via the official installer or via uv python install 3.12.

macOS

  • Standard Python 3.12 via Homebrew (brew install python@3.12), pyenv, or uv works equivalently.
  • No additional notes.

Linux

  • HF Spaces itself runs on Linux, so this is the closest match to production.
  • Standard python3.12 + python3.12-venv from your distro is enough.

Troubleshooting

Symptom Likely cause Fix
Commit blocked by commit-msg hook Reviewer marker stale or missing Run the reviewer procedure in CLAUDE.md, then retry
Sync to Hugging Face hub workflow fails HF_TOKEN secret expired or scope wrong Rotate the token in GitHub repo settings; see SECURITY.md
pip install -r requirements.lock fails on transitive Local Python is not 3.12 Switch to Python 3.12 (see above)
Streamlit complains about port 8501 Port already in use streamlit run app.py --server.port 8502
Hooks silently not running core.hooksPath not set Re-run bash scripts/setup.sh

What this runbook does NOT cover

  • Deploying to HF Spaces — that happens automatically on push to main. See docs/guides/protected-boundary-policy.md.
  • Editing CI workflows — see docs/guides/git-and-pr-rules.md and SECURITY.md for the deploy-boundary rules first.
  • Adding a new tool — see docs/policies/naming-conventions.md for the tab<N>.py rule.