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
| Attribute | Type | Description |
|---|---|---|
| app | fastapi.FastAPI | The FastAPI application instance to be served and managed within the Flyte environment. |
| type | str = FastAPI | A string identifier representing the environment type, defaulting to 'FastAPI'. |
| uvicorn_config | `uvicorn.Config | None` = null |
Constructor
Signature
def FastAPIAppEnvironment(
app: fastapi.FastAPI,
type: str = "FastAPI",
uvicorn_config: uvicorn.Config | None = null
)
Parameters
| Name | Type | Description |
|---|---|---|
| app | fastapi.FastAPI | The FastAPI application instance. |
| type | str = "FastAPI" | The type of the application environment. |
| uvicorn_config | `uvicorn.Config | None` = 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
| Name | Type | Description |
|---|---|---|
| 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
| Type | Description |
|---|---|
list[str] | A list of strings representing the shell command and its arguments. |