Spaces:
Sleeping
CONTRIBUTING.md
π οΈ Development Setup
This project uses uv for fast, reliable Python package management.
Prerequisites
- Python 3.11 or higher
- Git
Quick Start
Clone the repository
git clone https://github.com/amithjkamath/template-matching.git cd template-matchingRun setup
./setup.shOr if you prefer using Make:
make setupRun the app locally
./run_local.sh # or make run
Manual Setup
If you prefer to set things up manually:
Install uv (if not already installed)
curl -LsSf https://astral.sh/uv/install.sh | shInstall dependencies
uv sync --no-build-isolationRun the app
uv run --no-build-isolation streamlit run app.py
Alternative Simple Method
If you encounter build-related issues, you can use a simpler approach:
# Install dependencies
uv pip install -r requirements.txt
# Run the app
uv run streamlit run app.py
π Available Commands
Using Shell Scripts
./setup.sh- Initial setup (install uv and dependencies)./run_local.sh- Run the app locally./deploy.sh- Deploy to HuggingFace Spaces
Using Makefile
make help- Show all available commandsmake setup- Initial setupmake install- Install/update dependenciesmake run- Run the app locallymake deploy- Deploy to HuggingFacemake clean- Clean up cache and temporary filesmake format- Format code (requires black)make lint- Run linting checks (requires ruff)make update- Update all dependenciesmake info- Show project information
π§ͺ Testing Locally
Before deploying, always test your changes locally:
- Run the app:
./run_local.sh - Open your browser to http://localhost:8501
- Test all interactive features
- Check console for any errors
π Deployment Process
The app is deployed to HuggingFace Spaces. To deploy:
Ensure all changes are committed
git status git add . git commit -m "Your commit message"Deploy
./deploy.sh # or make deploy
The script will:
- Check for uncommitted changes
- Push to the remote repository
- HuggingFace Spaces will automatically rebuild
π¦ Dependency Management
Adding a new dependency
Add to pyproject.toml
dependencies = [ "new-package>=1.0.0", ... ]Update requirements.txt (for HuggingFace Spaces)
new-package>=1.0.0Sync dependencies
uv sync --no-build-isolation # or make install
Updating dependencies
uv sync --upgrade --no-build-isolation
# or
make update
π¨ Code Style
- Follow PEP 8 guidelines
- Use meaningful variable names
- Add docstrings to functions
- Keep functions focused and small
Formatting (optional)
Install formatting tools:
uv add --dev black ruff
Format code:
make format
Lint code:
make lint
π Making Changes
Create a new branch for your feature
git checkout -b feature/your-feature-nameMake your changes
Test locally
make runCommit your changes
git add . git commit -m "Description of changes"Push and create a pull request (if working with others)
git push origin feature/your-feature-nameOr merge to main and deploy
git checkout main git merge feature/your-feature-name make deploy
π Troubleshooting
Module not found error
If you see ModuleNotFoundError:
uv sync --no-build-isolation # or make install
# Alternative:
uv pip install -r requirements.txt
Build backend errors
The project is configured to skip build steps. If you still encounter hatchling/build errors:
./run_simple.sh
# or use pip directly:
uv pip install -r requirements.txt
uv run streamlit run app.py
Port already in use
If port 8501 is already in use:
uv run --no-build-isolation streamlit run app.py --server.port 8502
uv not found
Make sure uv is in your PATH. After installation, restart your terminal or run:
source ~/.cargo/env
π Project Structure
template-matching/
βββ app.py # Main Streamlit application
βββ requirements.txt # Dependencies for HuggingFace Spaces
βββ pyproject.toml # Python project configuration (uv)
βββ Dockerfile # Docker configuration for HF Spaces
βββ packages.txt # System packages for HF Spaces
βββ README.md # User-facing documentation
βββ CONTRIBUTING.md # This file - developer documentation
βββ LICENSE # MIT License
βββ setup.sh # Setup script
βββ run_local.sh # Local run script
βββ deploy.sh # Deployment script
βββ Makefile # Make commands for convenience
βββ .gitignore # Git ignore patterns
π€ Contributing Guidelines
- Keep the educational focus in mind
- Maintain interactive and engaging features
- Test thoroughly before deploying
- Update documentation for any new features
- Keep dependencies minimal and up-to-date
π License
This project is licensed under the MIT License - see the LICENSE file for details.