Flyte 2 Features

April 2, 2026 · View on GitHub

Flyte 2 is a fundamental shift from constrained DSLs to pure Python. Write pipelines, serve models, and orchestrate agents exactly like you write Python — because it is Python.

Highlights

Pure Python Workflows

No more workflow DSL. Use loops, conditionals, try/except, and any Python construct:

@env.task
async def dynamic_pipeline(config: dict) -> list[str]:
    results = []
    for dataset in config["datasets"]:
        try:
            if dataset["type"] == "batch":
                result = await process_batch(dataset)
            else:
                result = await process_stream(dataset)
            results.append(result)
        except ValidationError as e:
            results.append(await handle_error(dataset, e))
    return results

App Serving

Serve models and apps as first-class Flyte deployments:

from fastapi import FastAPI
from flyte.app.extras import FastAPIAppEnvironment
import flyte

app = FastAPI()
env = FastAPIAppEnvironment(
    name="hello-api",
    app=app,
    image=flyte.Image.from_debian_base(python_version=(3, 12)).with_pip_packages(
        "fastapi", "uvicorn"
    ),
)

@app.get("/predict")
async def predict(x: float) -> dict:
    return {"result": x * 2 + 5}
flyte serve serving.py env

Async Parallelism

Native asyncio for distributed parallel execution — no custom map functions:

@env.task
async def parallel_training(hyperparams: list[dict]) -> dict:
    models = await asyncio.gather(*[
        train_model.aio(params) for params in hyperparams
    ])
    evaluations = await asyncio.gather(*[
        evaluate_model.aio(model) for model in models
    ])
    best_idx = max(range(len(evaluations)),
                   key=lambda i: evaluations[i]["accuracy"])
    return {"best_model": models[best_idx], "accuracy": evaluations[best_idx]}

Feature Reference

FeatureWhat it doesWhy you need itExample
Task EnvironmentsGroup tasks with shared container config, resources, and imagesDefine infrastructure once, reuse across tasksbasics/container_images.py
Reusable ContainersKeep containers warm between task invocationsEliminate cold-start latency for iterative workloadsreuse/reusable.py
CachingContent-based or version-based task result cachingSkip redundant computation, save time and costcaching/content_based_caching.py
TracingFunction-level checkpointing with @flyte.traceResume from the last successful step on failurebasics/hello.py
File & Dir I/Oflyte.io.File and flyte.io.Dir for large data transferMove large artifacts between tasks without manual S3/GCS plumbingbasics/file.py
StreamingStream results as they become availableProcess outputs incrementally instead of waiting for completionstreaming/basic_as_completed.py
GPU / AcceleratorsRequest GPUs, TPUs, Trainium, HabanaRun training and inference on specialized hardwareaccelerators/gpu.py
TriggersSchedule tasks on time or eventsAutomate recurring pipelines and event-driven workflowstriggers/basic.py
ConnectorsBigQuery, Snowflake, Databricks integrationsQuery external data systems directly from tasksconnectors/snowflake_example.py
ReportsInteractive data visualizations and dashboardsGenerate rich HTML reports from task outputsreports/dataframe_report.py
GenAI AgentsBuild and orchestrate AI agentsRun LLM-powered agents with tool use and handoffsgenai/hello_agent.py
AppsServe FastAPI, Streamlit, Gradio, Panel appsDeploy and scale web apps alongside your pipelinesapps/single_script_fastapi.py
Remote TasksCall tasks deployed in other environmentsCompose pipelines across teams and infrastructureremote_management/remote_validate.py
PluginsSpark, Ray, Dask, PyTorch distributedRun workloads on specialized distributed compute frameworksplugins/spark_example.py
Higher-Order PatternsCircuit breakers, auto-batching, OOM retriersProduction resilience patterns out of the boxhigher_order_patterns/circuit_breaker.py
VolumesMount GCSFuse and other volumes into tasksAccess cloud storage as a local filesystemvolumes/gcsfuse_example.py

CLI

The Flyte CLI follows a verb noun structure. Full reference: CLI Docs

flyte run hello.py main --numbers '[1,2,3]'     # Run a task
flyte serve serving.py env                        # Serve an app
flyte deploy my_workflow.py                       # Deploy environments
flyte build my_workflow.py --push                 # Build and push images
flyte get logs <run-name>                         # Get logs for a run
flyte abort run <run-name>                        # Abort a run

Migration from Flyte 1

Flyte 1Flyte 2
@workflow + @task@env.task only
flytekit.map()await asyncio.gather()
@dynamic workflowsRegular @env.task with loops
flytekit.conditional()Python if/else
LaunchPlan schedules@env.task(on_schedule=...)
Workflow failure handlersPython try/except