Skip to main content
Model environments help configure behavior based on deployment stage (for example, production vs. staging). You can access the environment details via kwargs in the Model class.

Retrieve the environment

Access the environment in __init__:
def __init__(self, **kwargs):
    self._environment = kwargs["environment"]

Configure behavior per environment

Use the environment in your load() method to set up environment-specific behavior:
def load(self):
    if self._environment.get("name") == "production":
        self.setup_sentry()
        self.setup_logging(level="INFO")
        self.load_production_weights()
    else:
        self.setup_logging(level="DEBUG")
        self.load_default_weights()
This lets you:
  • Customize logging levels.
  • Load environment-specific model weights.
  • Enable monitoring tools (for example, Sentry).
When you promote a deployment without re-deploying, load() doesn’t re-run, so environment-specific configuration from the original deployment persists. You can configure an environment to create a fresh deployment on every promotion. See Re-deploy on promotion for details.