modal-classes-lifecycle
Installation
SKILL.md
Modal Classes and Lifecycle
Use this skill when using class-based Functions for stateful workloads, lifecycle management, or parametrization.
When to Use This Skill
- Loading an ML model once per container (not per request)
- Sharing state between method calls
- Running setup/teardown logic per container
- Creating separate container pools per parameter set (e.g., per user)
- Combining GPU inference with lifecycle hooks
Core Pattern: Class with Lifecycle
import modal
app = modal.App()