# Migration from Flyte 1 to Flyte 2

> **📝 Note**
>
> An LLM-optimized bundle of this entire section is available at [`section.md`](https://www.union.ai/docs/v2/union/api-reference/migration/section.md).
> This single file contains all pages in this section, optimized for AI coding agent context.

This section provides a comprehensive reference for migrating Flyte 1 (flytekit) workflows to Flyte 2 (flyte SDK).

For a quick-start overview of the migration process, see [Migration](https://www.union.ai/docs/v2/union/user-guide/flyte-2/migration/page.md) in the User Guide.

## Key API changes at a glance

| Use case                      | Flyte 1                     | Flyte 2                                 |
| ----------------------------- | --------------------------- | --------------------------------------- |
| Environment management        | N/A                         | `TaskEnvironment`                       |
| Perform basic computation     | `@task`                     | `@env.task`                             |
| Combine tasks into a workflow | `@workflow`                 | `@env.task`                             |
| Create dynamic workflows      | `@dynamic`                  | `@env.task`                             |
| Fanout parallelism            | `flytekit.map`              | Python `for` loop with `asyncio.gather` |
| Conditional execution         | `flytekit.conditional`      | Python `if-elif-else`                   |
| Catching workflow failures    | `@workflow(on_failure=...)` | Python `try-except`                     |

## Topics

### [Philosophy and imports](https://www.union.ai/docs/v2/union/api-reference/migration/overview/page.md)

Key paradigm shifts and package import mapping from flytekit to flyte.

### [Container images](https://www.union.ai/docs/v2/union/api-reference/migration/images/page.md)

Migrate from ImageSpec to flyte.Image with the fluent builder API.

### [Configuration and CLI](https://www.union.ai/docs/v2/union/api-reference/migration/configuration-and-cli/page.md)

Config file format changes and CLI command mapping.

### [Tasks and workflows](https://www.union.ai/docs/v2/union/api-reference/migration/tasks-and-workflows/page.md)

Migrate @task, @workflow, and @dynamic to TaskEnvironment and @env.task.

### [Secrets, resources, and caching](https://www.union.ai/docs/v2/union/api-reference/migration/secrets-resources-caching/page.md)

Updated patterns for secrets access, resource configuration, and caching.

### [Parallelism and async](https://www.union.ai/docs/v2/union/api-reference/migration/parallelism-and-async/page.md)

Migrate map_task to flyte.map and asyncio.gather patterns.

### [Triggers and dynamic workflows](https://www.union.ai/docs/v2/union/api-reference/migration/triggers-and-dynamic/page.md)

Migrate LaunchPlan schedules to Triggers and @dynamic to regular tasks.

### [Examples and common gotchas](https://www.union.ai/docs/v2/union/api-reference/migration/examples-and-gotchas/page.md)

Complete migration examples and common pitfalls to avoid.

## Subpages

- [Philosophy and imports](https://www.union.ai/docs/v2/union/api-reference/migration/overview/page.md)
  - Key paradigm shifts
  - What Flyte 2 eliminates
  - What Flyte 2 introduces
  - Package imports
  - Basic import changes
  - Flyte 1
  - Flyte 2
  - Import mapping table
- [Container images](https://www.union.ai/docs/v2/union/api-reference/migration/images/page.md)
  - Basic migration
  - Flyte 1
  - Flyte 2
  - Image constructor methods
  - Image builder methods (chainable)
  - Builder configuration (local vs remote)
  - Private registry with secrets
  - Flyte 1
  - Flyte 2
  - Parameter mapping
- [Configuration and CLI](https://www.union.ai/docs/v2/union/api-reference/migration/configuration-and-cli/page.md)
  - Configuration files
  - Config file location
  - Config format
  - Flyte 1
  - Flyte 2
  - Key config differences
  - Specifying config via CLI
  - Flyte 1
  - Flyte 2
  - Specifying config in code
  - CLI commands
  - Command mapping
  - Running tasks
  - Flyte 1
  - Flyte 2
  - Key CLI flag differences
  - Deploying
  - Flyte 1
  - Flyte 2
  - Running deployed tasks
  - Complete Flyte 2 CLI options
- [Tasks and workflows](https://www.union.ai/docs/v2/union/api-reference/migration/tasks-and-workflows/page.md)
  - Basic task migration
  - Flyte 1
  - Flyte 2
  - Workflow to task migration
  - Flyte 1
  - Flyte 2 Sync
  - Flyte 2 Async
  - TaskEnvironment configuration
  - Parameter mapping: @task to TaskEnvironment + @env.task
- [Secrets, resources, and caching](https://www.union.ai/docs/v2/union/api-reference/migration/secrets-resources-caching/page.md)
  - Secrets
  - Declaring and accessing secrets
  - Flyte 1
  - Flyte 2
  - Secret configuration options
  - Secret name convention changes
  - Creating secrets via CLI
  - Resources
  - Basic resource configuration
  - Flyte 1
  - Flyte 2
  - GPU configuration
  - Flyte 1
  - Flyte 2
  - Supported GPU types (Flyte 2)
  - Resource parameter mapping
  - Caching
  - Basic caching
  - Flyte 1
  - Flyte 2
  - Cache behavior options (Flyte 2)
- [Parallelism and async](https://www.union.ai/docs/v2/union/api-reference/migration/parallelism-and-async/page.md)
  - Basic map_task migration
  - Flyte 1
  - Flyte 2
  - map_task with concurrency
  - Flyte 1
  - Flyte 2
  - Async parallel execution with asyncio.gather
  - Concurrency control with semaphore
  - Error handling with asyncio.gather
  - flyte.map vs asyncio.gather comparison
  - Recommended pattern selection
  - Sync and async task patterns
  - Sync tasks calling sync tasks
  - Async tasks calling async tasks
  - Sequential execution with await
  - Flyte 1
  - Flyte 2
- [Triggers and dynamic workflows](https://www.union.ai/docs/v2/union/api-reference/migration/triggers-and-dynamic/page.md)
  - LaunchPlan to Trigger migration
  - Flyte 1
  - Flyte 2
  - Trigger options
  - Deploying triggers
  - Dynamic workflows
  - @dynamic to regular tasks
  - Flyte 1
  - Flyte 2 Sync
  - Flyte 2 Async
  - Conditional execution
  - Flyte 1
  - Flyte 2
  - Subworkflows to nested tasks
  - Flyte 1
  - Flyte 2
- [Examples and common gotchas](https://www.union.ai/docs/v2/union/api-reference/migration/examples-and-gotchas/page.md)
  - Complete migration examples
  - Example 1: Simple ML pipeline
  - Flyte 1
  - Flyte 2
  - Example 2: Parallel processing with map_task
  - Flyte 1
  - Flyte 2 Sync
  - Flyte 2 Async
  - Common gotchas
  - 1. current_context() is replaced
  - 2. Workflow >> ordering notation is gone
  - 3. flyte.map returns a generator
  - 4. Image configuration location
  - 5. Resource configuration
  - 6. Cache version
  - 7. Entrypoint task naming
  - 8. Memory parameter name
  - 9. Type annotations
  - Quick reference cheat sheet

---
**Source**: https://github.com/unionai/unionai-docs/blob/main/content/api-reference/migration/_index.md
**HTML**: https://www.union.ai/docs/v2/union/api-reference/migration/
