This guide covers environment setup, development workflow, and tooling for contributing to flash-examples.
- Environment Setup
- Makefile Commands
- Development Workflow
- Code Quality
- Testing
- Common Tasks
- Troubleshooting
- Python 3.10+ (3.12 recommended)
- One of: uv, pip, poetry, conda, or pipenv
- Git
The project Makefile auto-detects your package manager and sets up the environment:
git clone https://github.com/runpod/flash-examples.git
cd flash-examples
make setupThis works with any of these package managers:
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
# Setup project
make setupWhat it does:
- Creates
.venvif not exists - Syncs all dependency groups from
uv.lock - Installs package in editable mode
# Setup project (creates venv automatically)
make setupWhat it does:
- Creates
.venvusingpython -m venv - Installs from
requirements.txt(or generates it) - Installs package in editable mode
# Install poetry
curl -sSL https://install.python-poetry.org | python3 -
# Setup project
make setupWhat it does:
- Uses poetry's virtual environment management
- Installs dev dependencies
- Installs package in editable mode
# Setup project
make setupWhat it does:
- Creates conda environment at
./.venv - Installs dependencies via pip
- Installs package in editable mode
# Install pipenv
pip install pipenv
# Setup project
make setupWhat it does:
- Creates pipenv environment
- Installs dev dependencies
- Installs package in editable mode
Force a specific package manager:
PKG_MANAGER=pip make setup
PKG_MANAGER=conda make setupCheck that everything is configured correctly:
make verify-setupOutput:
═══════════════════════════════════════════════════════════════
Flash Examples - Setup Verification
═══════════════════════════════════════════════════════════════
→ Checking Python version...
✓ Python 3.12.1 (>= 3.10 required)
→ Checking virtual environment...
✓ Virtual environment exists (.venv)
→ Checking Flash CLI...
✓ Flash CLI installed (flash, version 0.1.0)
→ Checking RUNPOD_API_KEY...
✓ RUNPOD_API_KEY set in environment
═══════════════════════════════════════════════════════════════
Setup verification complete!
═══════════════════════════════════════════════════════════════
make venv-infoOutput:
Package Manager: uv
Python Runner: uv run
Virtual Environment: Active (.venv exists)
Python Version: Python 3.12.10
After make setup completes, you can run Flash in two ways:
Option A: Using Package Manager Prefix (recommended for uv/poetry/pipenv/conda)
Run commands with the package manager prefix without activation:
# With uv
uv run flash run
# With poetry
poetry run flash run
# With pipenv
pipenv run flash run
# With conda
conda run -p ./.venv flash runOption B: Activate Virtual Environment (works with all managers)
Alternatively, activate the virtual environment first:
# Unix/macOS
source .venv/bin/activate
# Windows
.venv\Scripts\activate
# Then run normally
flash runOnce activated, you can run Flash and other commands directly without a prefix.
make helpShows all available commands with your detected environment manager.
| Command | Description |
|---|---|
make setup |
Setup development environment (auto-detects package manager) |
make verify-setup |
Verify environment is configured correctly |
make venv-info |
Display environment manager and venv status |
make clean-venv |
Remove .venv directory |
make update-deps |
Update dependencies to latest versions |
| Command | Description |
|---|---|
make requirements.txt |
Generate requirements.txt from pyproject.toml |
make environment.yml |
Generate conda environment.yml |
make sync-deps |
Generate all dependency files |
When to use:
requirements.txt- For pip users, Docker builds, CI/CDenvironment.yml- For conda users- After updating
pyproject.tomldependencies
| Command | Description |
|---|---|
make lint |
Check code with ruff |
make lint-fix |
Auto-fix linting issues |
make format |
Format code with ruff |
make format-check |
Check formatting without changes |
make typecheck |
Run mypy type checker |
| Command | Description | Use Case |
|---|---|---|
make quality-check |
Format check + lint | Fast pre-commit check |
make quality-check-strict |
Format + lint + typecheck | Thorough validation |
make ci-quality-github |
CI with GitHub Actions formatting | GitHub Actions only |
| Command | Description |
|---|---|
make clean |
Remove build artifacts, __pycache__, .pyc files |
make clean-venv |
Remove virtual environment |
The Flash CLI provides commands for local development, building, and deployment.
flash login # Authenticate with Runpod (opens browser)Or set RUNPOD_API_KEY in your .env file.
# Run development server
flash run # Default: localhost:8888
flash run --port 9000 # Custom port
flash run --host 0.0.0.0 # Network accessible
# Build deployment package
flash build # Standard build
flash build --exclude torch # Optimize size# Environment management
flash env create dev
flash env create staging
flash env create production
# Deploy to environment
flash deploy --env dev
flash deploy --env production --exclude torch,torchvision
# Manage deployments
flash undeploy list # Show all endpoints
flash undeploy <name> # Remove specific endpointSee comprehensive CLI documentation:
- CLI Reference - All commands and options
- Getting Started - Tutorial for new users
- Commands - Detailed command documentation
- Workflows - Common development patterns
- Troubleshooting - Problem solutions
# Clone and setup
git clone https://github.com/runpod/flash-examples.git
cd flash-examples
make setup
# Verify setup
make venv-infogit checkout -b feature/your-feature-nameFollow these principles:
- Test-driven development (TDD)
- Single responsibility per function
- Type hints are mandatory
- Early returns for guard clauses
# Before committing
make quality-check
# For stricter validation
make quality-check-strictgit add .
git commit -m "feat: your descriptive commit message"Commit message format:
type(scope): subject
Longer description if needed
- Bullet points for multiple changes
Types: feat, fix, refactor, test, docs, perf, chore
git push origin feature/your-feature-nameCheck issues:
make lintAuto-fix:
make lint-fix
make formatConfiguration: pyproject.toml
Run type checker:
make typecheckType hints are mandatory:
# Good
def process_data(items: list[dict[str, Any]]) -> pd.DataFrame:
"""Process items and return DataFrame."""
pass
# Bad
def process_data(items):
"""Process items and return DataFrame."""
passBefore every commit:
make quality-checkIf it fails:
- Fix issues manually or use
make lint-fix+make format - Re-run
make quality-check - Commit
# All tests
pytest
# Unit tests only
pytest tests/unit/
# Stop on first failure
pytest -xvs
# With coverage
pytest --cov=src --cov-report=htmlFollow Arrange-Act-Assert pattern:
def test_user_creation():
# Arrange
user_data = {"email": "test@example.com", "name": "Test User"}
# Act
user = User.create(**user_data)
# Assert
assert user.email == user_data["email"]
assert user.id is not None- Test behavior, not implementation
- Use fixtures for reusable setup
- Mock external services, not internal code
- Test unhappy paths thoroughly
1. Edit pyproject.toml:
[project]
dependencies = [
"runpod-flash",
"new-package>=1.0.0",
]2. Sync environment:
# With uv
uv sync
# With other managers
make setup3. Generate dependency files:
make sync-depsmake update-depsThen review and test changes before committing.
1. Create directory and worker files:
mkdir 01_getting_started/05_new_example
cd 01_getting_started/05_new_example2. Create files:
touch README.md gpu_worker.py pyproject.tomlEach worker file (named *_worker.py by convention) is self-contained with @Endpoint decorated functions. flash run discovers all .py files with @Endpoint functions automatically -- no main.py, no workers/ directories needed.
3. Declare dependencies:
Add a pyproject.toml with runpod-flash as the only local dependency. Runtime deps (torch, etc.) go in Endpoint(dependencies=[...]).
4. Verify discovery:
cd ../../ # Back to root
flash run # Discovers all .py files with @Endpoint functionsRemove build artifacts:
make cleanRemove virtual environment:
make clean-venvFresh start:
make clean-venv
make setupThe root directory provides a programmatic discovery system that automatically finds and loads all examples when you run flash run from the project root.
- Scans all example category directories (
01_getting_started/,02_ml_inference/, etc.) - Detects
@remotedecorated functions in.pyfiles via AST parsing - Dynamically generates routes with unique prefixes (e.g.,
/01_hello_world/gpu/) - Generates metadata and documentation automatically
- Add new examples without modifying any central configuration
- Consistent routing across all examples
- Single entry point for exploring all functionality
- Automatic discovery eliminates manual registration
Each example follows this flat-file pattern:
example_name/
├── README.md # Documentation and deployment guide
├── gpu_worker.py # @remote decorated functions (GPU)
├── cpu_worker.py # @remote decorated functions (CPU, optional)
├── pyproject.toml # Project dependencies
└── .gitignore # Git ignore patterns
The unified app requires all example dependencies to be installed in the root environment for discovery to work.
Automatic Dependency Syncing:
When adding a new example with additional dependencies:
- Define dependencies in your example's
pyproject.toml - Run
make sync-example-depsto update the root dependencies - Run
uv sync --all-groups(ormake setup) to install new packages - Run
make requirements.txtto regenerate the lockfile
The sync script automatically:
- Scans all example directories for
pyproject.tomlfiles - Merges dependencies into the root configuration
- Filters out transitive dependencies already provided by
runpod-flash - Detects version conflicts and uses the most permissive constraint
- Preserves essential root dependencies (numpy, torch, runpod-flash)
Example:
# After adding a new example with pillow and structlog dependencies
make sync-example-deps # Syncs example deps to root pyproject.toml
uv sync --all-groups # Installs new dependencies
make requirements.txt # Regenerates lockfileSymptom:
make: *** No package manager found
Solution: Install one of: uv, pip, poetry, conda, or pipenv
# Easiest: pip (comes with Python)
python -m ensurepip
# Recommended: uv
curl -LsSf https://astral.sh/uv/install.sh | shWrong Python version in venv:
make clean-venv
make setupDependencies out of sync:
# With uv
uv sync
# With pip
pip install -r requirements.txt
# Or recreate
make clean-venv
make setupFormatting issues:
make formatLinting issues:
make lint-fixType errors:
Review mypy output and add type hints:
make typecheckCheck which environment manager is detected:
make venv-infoForce specific manager:
PKG_MANAGER=pip make setupRun commands directly:
You can either use package manager prefixes or activate the environment first:
# Option 1: Use package manager prefix
uv run ruff check . # With uv
poetry run ruff check . # With poetry
# Option 2: Activate environment first (works with all managers)
source .venv/bin/activate # Unix/macOS
.venv\Scripts\activate # Windows
ruff check .Package not installed in editable mode:
# With uv
uv pip install -e .
# With pip
pip install -e .
# Or use Makefile
make setupWrong virtual environment activated:
# Deactivate current
deactivate
# Use Makefile (auto-detects)
make lint
# Or activate correct venv
source .venv/bin/activate # Unix
.venv\Scripts\activate # WindowsThe project includes quality checks optimized for GitHub Actions:
- name: Run quality checks
run: make ci-quality-githubThis produces collapsible output groups in GitHub Actions logs.
Test what CI will run:
make quality-check-strictThis runs the same checks as CI (format + lint + typecheck).
Install extensions:
- Python (ms-python.python)
- Ruff (charliermarsh.ruff)
- Mypy Type Checker (ms-python.mypy-type-checker)
Enable external tools:
- Settings → Tools → External Tools
- Add Makefile commands
Use ALE or null-ls with ruff and mypy configured.
- Contributing Guidelines - Contribution process
- README - Project overview
- Check existing issues: https://github.com/runpod/flash-examples/issues
- Join Discord: https://discord.gg/runpod
- Read docs: https://docs.runpod.io