Skip to main content

FastAPIAppEnvironment

This class provides an environment for running FastAPI applications within a Flyte context. It handles the configuration and execution of a Uvicorn server while ensuring the FastAPI application state is picklable for serialization. The class also automatically configures application links and manages the underlying server lifecycle.

Attributes

AttributeTypeDescription
appfastapi.FastAPIThe FastAPI application instance to be served and managed within the Flyte environment.
typestr = FastAPIA string identifier representing the environment type, defaulting to 'FastAPI'.
uvicorn_config`uvicorn.ConfigNone` = null

Constructor

Signature

def FastAPIAppEnvironment(
app: fastapi.FastAPI,
type: str = "FastAPI",
uvicorn_config: uvicorn.Config | None = null
)

Parameters

NameTypeDescription
appfastapi.FastAPIThe FastAPI application instance.
typestr = "FastAPI"The type of the application environment.
uvicorn_config`uvicorn.ConfigNone` = null

Methods


container_command()

@classmethod
def container_command(
serialization_context: [SerializationContext](../../../models/serializationcontext.md?sid=flyte_models_serializationcontext)
) - > list[str]

Generates the command-line arguments required to run the FastAPI application within a container. Currently returns an empty list as the execution logic is handled by the server runner.

Parameters

NameTypeDescription
serialization_context[SerializationContext](../../../models/serializationcontext.md?sid=flyte_models_serializationcontext)The context containing settings and state for serializing the Flyte entity into a container command.

Returns

TypeDescription
list[str]A list of strings representing the shell command and its arguments.