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()
Installs
5
GitHub Stars
4
First Seen
Jun 9, 2026