Skip to main content

Environment

Base class for execution environments, shared by TaskEnvironment and AppEnvironment. Defines common infrastructure settings such as container image, compute resources, secrets, and deployment dependencies.

Attributes​

AttributeTypeDescription
namestrName of the environment (required). Must be snake_case or kebab-case.
depends_onList[[Environment](environment.md?sid=flyte__environment_environment)] = []List of other environments to deploy alongside this one.
pod_templateOptional[Union[str, [PodTemplate](../pod/podtemplate.md?sid=flyte__pod_podtemplate)]] = nullKubernetes pod template as a string reference to a named template or a PodTemplate object.
descriptionOptional[str] = nullHuman-readable description (max 255 characters).
secretsOptional[SecretRequest] = nullSecrets to inject into the environment.
env_varsOptional[Dict[str, str]] = nullEnvironment variables as dict[str, str].
resourcesOptional[[Resources](../resources/resources.md?sid=flyte__resources_resources)] = nullCompute resources (CPU, memory, GPU, disk) via a Resources object.
interruptiblebool = falseWhether the environment can be scheduled on spot/preemptible instances.
imageUnion[str, [Image](../image/image.md?sid=flyte__image_image), Literal["auto"], None] = "auto"Docker image for the environment. Can be a string (image URI), an Image object, or "auto" to use the default image.
includeTuple[str, ...] = ()Extra files to bundle with the environment's code (e.g., HTML templates, config files, non-Python assets).

Constructor​

Signature​

def Environment(
name: str,
image: Union[str, [Image](../image/image.md?sid=flyte__image_image), Literal['auto'], None] = "auto",
resources: Optional[[Resources](../resources/resources.md?sid=flyte__resources_resources)] = None,
env_vars: Optional[Dict[str, str]] = None,
secrets: Optional[SecretRequest] = None,
pod_template: Optional[Union[str, [PodTemplate](../pod/podtemplate.md?sid=flyte__pod_podtemplate)]] = None,
description: Optional[str] = None,
interruptible: bool = False,
depends_on: List[[Environment](environment.md?sid=flyte__environment_environment)] = [],
include: Tuple[str, ...] = ()
) - > null

Parameters​

NameTypeDescription
namestrName of the environment. Must be in snake_case or kebab-case format.
imageUnion[str, [Image](../image/image.md?sid=flyte__image_image), Literal['auto'], None] = "auto"Docker image for the environment. Can be a URI string, an Image object, or 'auto' for the default image.
resourcesOptional[[Resources](../resources/resources.md?sid=flyte__resources_resources)] = NoneCompute resources such as CPU, memory, GPU, and disk requirements.
env_varsOptional[Dict[str, str]] = NoneA dictionary of environment variables to be set in the execution environment.
secretsOptional[SecretRequest] = NoneSecrets to be injected into the environment.
pod_templateOptional[Union[str, [PodTemplate](../pod/podtemplate.md?sid=flyte__pod_podtemplate)]] = NoneKubernetes pod template reference or object.
descriptionOptional[str] = NoneA human-readable description of the environment, capped at 255 characters.
interruptiblebool = FalseWhether the environment can run on spot or preemptible instances.
depends_onList[[Environment](environment.md?sid=flyte__environment_environment)] = []A list of other Environment instances that should be deployed alongside this one.
includeTuple[str, ...] = ()Extra files or directories to bundle with the environment's code.

Methods​


add_dependency()​

@classmethod
def add_dependency(
*env: [Environment](environment.md?sid=flyte__environment_environment)
) - > null

Add one or more environment dependencies so they are deployed together. When you deploy this environment, any environments added via add_dependency will also be deployed. This is an alternative to passing depends_on=[...] at construction time, useful when the dependency is defined after the environment is created. Duplicate dependencies are silently ignored. An environment cannot depend on itself.

Parameters​

NameTypeDescription
*env[Environment](environment.md?sid=flyte__environment_environment)One or more Environment instances to add as dependencies.

Returns​

TypeDescription
null

clone_with()​

@classmethod
def clone_with(
name: str,
image: Optional[Union[str, [Image](../image/image.md?sid=flyte__image_image), Literal["auto"]]],
resources: Optional[[Resources](../resources/resources.md?sid=flyte__resources_resources)],
env_vars: Optional[Dict[str, str]],
secrets: Optional[SecretRequest],
depends_on: Optional[List[[Environment](environment.md?sid=flyte__environment_environment)]],
description: Optional[str],
**kwargs: Any
) - > [Environment](environment.md?sid=flyte__environment_environment)

Creates a new instance of the environment with updated configuration values. This method is intended to be overridden by subclasses to support creating variations of existing environments.

Parameters​

NameTypeDescription
namestrThe unique name for the new cloned environment.
imageOptional[Union[str, [Image](../image/image.md?sid=flyte__image_image), Literal["auto"]]]The Docker image URI or Image object to use for the new environment.
resourcesOptional[[Resources](../resources/resources.md?sid=flyte__resources_resources)]The compute resource requirements (CPU, Memory, GPU) for the new environment.
env_varsOptional[Dict[str, str]]A dictionary of environment variables to be set in the execution context.
secretsOptional[SecretRequest]The secret requests defining sensitive data to be injected into the environment.
depends_onOptional[List[[Environment](environment.md?sid=flyte__environment_environment)]]A list of other Environment instances that must be deployed alongside this one.
descriptionOptional[str]A human-readable summary of the environment's purpose.
**kwargsAnyAdditional implementation-specific arguments for the cloned environment.

Returns​

TypeDescription
[Environment](environment.md?sid=flyte__environment_environment)A new Environment instance with the specified overrides applied.