Philosophy and imports
Key paradigm shifts
| Concept | Flyte 1 (flytekit) | Flyte 2 (flyte) |
|---|---|---|
| Workflow definition | @workflow decorator (DSL-constrained) |
Tasks calling tasks (pure Python) |
| Task configuration | Per-task decorator parameters | TaskEnvironment (shared config) |
| Parallelism | map_task() function |
flyte.map() or asyncio.gather() |
| Conditionals | flytekit.conditional() |
Native Python if/else |
| Error handling | Decorator-based retries | Python try/except + retries |
| Execution model | Static DAG compilation | Dynamic pure Python execution |
What Flyte 2 eliminates
@workflowdecorator: No longer exists. Workflows are just tasks that call other tasks.@dynamicdecorator: No longer needed. All tasks can have dynamic behavior.- DSL constraints: No more restrictions on what Python constructs you can use.
- Separate workflow/task execution contexts: Everything runs as a task.
What Flyte 2 introduces
TaskEnvironment: Centralized configuration for groups of tasks.- Native async support: First-class
async/awaitwith distributed execution. flyte.map(): Simplified parallel execution with generator support.Trigger: Task-based scheduling (replaces LaunchPlan schedules).- Pure Python workflows: Full Python flexibility in orchestration logic.
For more on the pure Python model, see Pure Python. For more on the async model, see Asynchronous model.
Package imports
Basic import changes
import flytekit
from flytekit import task, workflow, dynamic, map_task
from flytekit import ImageSpec, Resources, Secret
from flytekit import current_context, LaunchPlan, CronScheduleimport flyte
from flyte import TaskEnvironment, Resources, Secret
from flyte import Image, Trigger, CronImport mapping table
| Flyte 1 import | Flyte 2 import | Notes |
|---|---|---|
flytekit.task |
env.task |
Decorator from TaskEnvironment |
flytekit.workflow |
env.task |
Workflows are now tasks |
flytekit.dynamic |
env.task |
All tasks can be dynamic |
flytekit.map_task |
flyte.map / asyncio.gather |
Different API |
flytekit.ImageSpec |
flyte.Image |
Different API |
flytekit.Resources |
flyte.Resources |
Similar API |
flytekit.Secret |
flyte.Secret |
Different access pattern |
flytekit.current_context() |
flyte.ctx() |
Different API |
flytekit.LaunchPlan |
flyte.Trigger |
Different concept |
flytekit.CronSchedule |
flyte.Cron |
Used with Trigger |
flytekit.conditional |
Native if/else |
No longer needed |