Auto-generated by /analyze-repos on 2026-02-22. Manual edits will be overwritten on next analysis.
worker-flash (v1.0.1), a RunPod Serverless worker that executes @remote functions and classes inside GPU/CPU containers. Receives serialized FunctionRequest (cloudpickle + base64), installs dependencies on-the-fly, executes user code, returns FunctionResponse. Two modes: Live Serverless (dynamic code per-request) and Flash Deployed Apps (pre-deployed artifacts). Dual entry points: RunPod serverless handler (QB) and FastAPI LB handler. Python 3.10-3.14, base images: pytorch 2.9.1 (GPU), python:3.12-slim (CPU).
- RemoteExecutor (
src/remote_executor.py:30) -- Central orchestrator using composition pattern. Coordinates dependency installation, execution routing (function vs class), log streaming. - DependencyInstaller (
src/dependency_installer.py:12) -- Python (uv/pip) and system (apt/nala) package installation with env-aware config (Docker vs local). - FunctionExecutor (
src/function_executor.py:12) -- Sync/async function execution viaexec()with stdout/stderr/log capture. - ClassExecutor (
src/class_executor.py:14) -- Class instantiation, method dispatch, instance persistence in unbounded registry. - CacheSyncManager (
src/cache_sync_manager.py:12) -- Bidirectional cache sync between local/root/.cacheand network volume tarballs.
- QB Handler (
src/handler.py) -- RunPod serverless entry viarunpod.serverless.start(). Receives jobs from queue, delegates toRemoteExecutor. - LB Handler (
src/lb_handler.py) -- FastAPI app served by uvicorn. HTTP endpoints for load-balanced requests.
src/
handler.py # RunPod serverless entry point (QB mode)
lb_handler.py # FastAPI Load Balancer entry point (LB mode)
remote_executor.py # Central orchestrator (composition: DependencyInstaller + Executors)
function_executor.py # Function execution with stdout/stderr/log capture
class_executor.py # Class instantiation, method dispatch, instance persistence
dependency_installer.py # Python (uv/pip) + system (apt/nala) package installation
serialization_utils.py # CloudPickle + base64 encode/decode utilities
subprocess_utils.py # Centralized subprocess with logging via run_logged_subprocess
log_streamer.py # Thread-safe log buffering for captured output
logger.py # Logging configuration
cache_sync_manager.py # Network volume <-> local cache bidirectional sync
manifest_reconciliation.py # TTL-based flash_manifest.json refresh
unpack_volume.py # Build artifact extraction from network volume
constants.py # Named constants (NAMESPACE, LARGE_SYSTEM_PACKAGES)
No public Python API. The worker exposes its interface through:
- QB protocol:
FunctionRequestin,FunctionResponseout (viarunpod.serverless.start()) - LB protocol: HTTP endpoints mapped from
@remote(method=..., path=...)decorators - Protocol definitions: imported from
runpod_flash.protos.remote_execution
| Variable | Required | Purpose |
|---|---|---|
RUNPOD_API_KEY |
Yes | RunPod API authentication |
RUNPOD_ENDPOINT_ID |
Auto | Workspace isolation (set by RunPod) |
FLASH_ENDPOINT_TYPE |
Auto | QB vs LB mode selection |
FLASH_RESOURCE_NAME |
Auto | Resource identification |
FLASH_MAIN_FILE |
Deploy | Entry file for deployed apps |
FLASH_APP_VARIABLE |
Deploy | App variable name for deployed apps |
FLASH_BUILD_ARTIFACT_PATH |
Deploy | Path to build artifacts |
FLASH_DISABLE_UNPACK |
Deploy | Skip artifact extraction |
LOG_LEVEL |
No | Logging verbosity (default: INFO) |
HF_HUB_ENABLE_HF_TRANSFER |
No | Accelerated HuggingFace downloads |
HF_HOME |
No | HuggingFace cache location (default: /hf-cache) |
HF_TOKEN |
No | Auth for private/gated HF models |
- flash (
runpod_flashpackage) -- importsFunctionRequest,FunctionResponse,RemoteExecutorStub,ServiceRegistry,StateManagerClientfromrunpod_flash.protosandrunpod_flash.runtime. - runpod-python (
runpodpackage) --runpod.serverless.start()for QB mode handler registration.
- flash -- builds Docker images that run this worker. Docker image names hardcoded in flash's
core/resources/constants.py. - flash-examples -- indirectly; user code runs inside this worker.
- FunctionRequest/FunctionResponse protocol -- the primary contract between flash and flash-worker. Any field changes require coordinated releases across both repos.
FunctionResponseas generic envelope --subprocess_utils.pyreusesFunctionResponsefor subprocess results (coupling to protocol schema).- Docker image tags -- flash deploys specific image tags; worker image names/tags must match flash's
constants.py. - Manifest schema --
manifest_reconciliation.pyparsesflash_manifest.jsongenerated by flash's build step.
flash-examples --> flash (runpod_flash) --> runpod-python (runpod)
flash-worker --> flash (protocols) --> runpod-python (serverless.start)
- Python version: runpod-python supports 3.8+, flash-worker requires 3.10+
- Coverage thresholds: runpod-python 90%, flash 35%, flash-worker 35%
make setup # Initialize project and sync dependencies
make dev # Install all development dependencies
uv sync --all-groups # Alternative: sync all dependency groupsmake test # Run all tests
make test-unit # Unit tests only
make test-integration # Integration tests only
make test-coverage # Tests with coverage report
make test-fast # Tests with fail-fast mode
make test-handler # Test handler locally with all test_*.json files (matches CI)make quality-check # REQUIRED BEFORE ALL COMMITS (format + lint + tests + coverage)
make lint # Ruff linter
make lint-fix # Auto-fix lint issues
make format # Ruff formatter
make format-check # Check formatting
make typecheck # mypy type checkingmake build # Build GPU Docker image (single-platform, loads locally)
make build-cpu # Build CPU-only Docker image
make build-lb # Build Load Balancer image
make build-wip # Multi-platform build, pushes to Docker Hub (NOT visible in docker images)
make smoketest # Test built images locally
make smoketest-lb # Test LB images locallymake index # Rebuild MCP code intelligence index- None critical. Architecture is clean with composition pattern.
ExecuteFunctionis 150 lines (remote_executor.py:58) -- main execution path, consider extracting sub-methodssync_to_volumeis 170 lines (cache_sync_manager.py:103) -- complex tarball sync logicRemoteExecutoronly tested indirectly -- direct unit tests needed
_UNPACKEDflag set before extraction completes (unpack_volume.py:130) -- race condition if extraction fails- Off-by-one retry sleep in
unpack_volume.py:147-- first retry has no backoff - Unbounded instance registry in
class_executor.py:19-- memory leak for long-running workers with many unique classes - No mutable defaults, no bare except, no
print(), no TODOs, no commented-out code -- clean
tests/unit/-- component-level testing with mockingtests/integration/-- end-to-end workflow testingtests/conftest.py-- shared fixtures and mock objectssrc/tests/-- handler test JSON files formake test-handler- Coverage threshold: 35% minimum
| File | Coverage | Risk |
|---|---|---|
log_streamer.py |
None | MEDIUM -- thread-safe buffering untested |
subprocess_utils.py |
None | HIGH -- all subprocess calls flow through here |
logger.py |
None | LOW |
remote_executor.py |
Indirect only | HIGH -- central orchestrator needs direct tests |
- Arrange-Act-Assert in all tests
- Mock external services (RunPod API, file system for volumes)
- Use
make test-handlerfor handler validation (matches CI behavior) - Do NOT run individual test files manually with
RUNPOD_TEST_INPUT-- usemake test-handler
- Docker containers should never reference
src/paths directly - Use
make buildfor local testing (visible indocker images) - Use
make build-wiponly for pushing to Docker Hub (NOT visible locally)
Server: worker-flash-code-intel
Always prefer MCP tools over Grep/Glob for semantic code searches.
| Tool | Use Case | Example |
|---|---|---|
find_symbol(symbol) |
Find classes, functions, methods by name | find_symbol("RemoteExecutor") |
list_classes() |
Get all classes in codebase | Exploring class hierarchy |
get_class_interface(class_name) |
Inspect class methods/properties | get_class_interface("DependencyInstaller") |
list_file_symbols(file_path) |
View file structure | list_file_symbols("src/handler.py") |
find_by_decorator(decorator) |
Find decorated items | find_by_decorator("remote") |
Indexed codebase includes:
- Project source (
src/) -- all 83 worker-flash symbols runpod_flashdependency -- all 552 protocol definitions, resources, and core components
When to use Grep instead: Content searches (error messages, string literals, log statements, env var usage).
Rebuild index when dependencies change: make index
Last analyzed: 2026-02-22