Every Python team that runs work in production eventually hits the same wall: the function that trains a model is easy to write, but the contract around it is not. Which arguments are required, what type each one has, who owns the container image, how a retry should behave, and where the outputs land are all decisions that quietly leak into shell scripts and wiki pages. The moment a second person runs the job, the absence of a typed boundary becomes expensive.

Flyte sells a boundary. A task is described once, with named inputs and outputs, each carrying a type, and that description travels from a Python notebook to a Kubernetes cluster without being rewritten by hand. The promise is not a nicer scheduler; it is that the same typed object is what compiles, what is registered, and what executes.

This tour reads the real main tree of flyteorg/flyte, checked out at the commit the default branch pointed to when this post was written. One honest note up front: the ergonomic decorator layer that Python users type, @task, @workflow, and friends, is not vendored in this repository. The flytekit package lives in its own project. What this monorepo contains is the newer contract: the flyteidl2 protocol definitions, the generated Python bindings that mirror them, and the Go control plane that consumes them. Reading this tree is reading where those decorators ultimately land.

Flyte architecture overview: proto type system, task and service specs, buf-generated Python bindings, executor controller and plugin registry

Overview of Flyte's contract path: proto files define types, interfaces and services, buf emits Python modules and Connect clients, and the executor consumes the same TaskSpec while dispatching work to a plugin.

Reading the overview from left to right:

  • SimpleType, L10 is a ten-value enum, from NONE and INTEGER through BOOLEAN, DATETIME, BINARY and STRUCT, and it is the floor every richer type builds on.
  • LiteralType, L132 wraps those scalars in a oneof of eight variants, including schema, collection, map, blob, enum, structured dataset and tagged union.
  • TypedInterface, L39 holds an input VariableMap and an output VariableMap, which is the whole signature of a task in two fields.
  • Parameter, L46 layers launch-time behavior onto a variable with a oneof for a default Literal, a required flag, or an artifact query.
  • TaskTemplate, L373 binds a task type, metadata, its typed interface, and an execution target such as a Container, K8sPod or Sql.
  • TaskSpec, L168 makes that template required and adds ordered default inputs, a short name, an optional environment and a cluster pool.
  • DeployTask, L17 is the RPC a client calls to register a TaskSpec as a versioned task on the server.
  • CreateRun, L23 is the first of seventeen RPCs on the run service, the call that turns a registered task plus literal inputs into a run.
  • TaskActionSpec, L110 is the custom resource the executor reconciles, carrying the run name, project, and action type that the rest of the control plane watches.

The overview has five clusters: the core type system, the task and service specs, the Python bindings, the execution runtime, and the plugin layer. The detail view opens each one.

Flyte detail architecture: LiteralType variants, TypedInterface and Parameter, TaskTemplate targets, buf Python outputs, TaskAction controller, caches, conditions and plugin implementations

Detail view: scalar and composite types feed literals, an interface collects variables, a template selects a container target, buf mirrors all of it into Python, and the reconciler drives a TaskAction through cache and condition branches into an AWS, Kubernetes, web-API or core plugin.

A Type System That Travels as Protobuf

The type system is deliberately small and deliberately explicit. flyteidl2/core/types.proto is 208 lines and starts with a scalar enum before reaching the composite messages. LiteralType at line 132 is the hinge: its oneof lists simple, schema, collection_type, map_value_type, blob, enum_type, structured_dataset_type and union_type. A collection is not a separate message; it is a LiteralType that contains another LiteralType, so arrays of arrays are single-field recursion rather than a growing type hierarchy.

That recursion keeps the layer language-neutral: a Python List[Dict[str, int]] and its Go equivalent share one nested message, with no separate enum per compound shape. UnionType at line 106 goes the other way, storing tagged variants so an optional value can be modeled as “this type or null”.

The values follow in flyteidl2/core/literals.proto, 279 lines long. Literal at line 96 has a oneof for a single scalar, a nested collection, a map, or offloaded metadata for large values. Scalar fans out to primitives, blobs, binary blobs, schemas, null, errors, generic structs, structured datasets and unions. A comment even names flytekit, noting that it copies runtime type information into a structured-dataset literal when a plugin does not supply it.

A PromiseAttribute doc comment in the same file even shows a @workflow example, t2(o.a["b"][0]), because Python is the audience the IDL serves.

Typed Interfaces Are the Compile-Time Promise

flyteidl2/core/interface.proto is only 70 lines, which is part of the point. Variable pairs a LiteralType with an optional description and artifact metadata. VariableMap is not a protobuf map; it is a repeated VariableEntry, and the comment says why: ordering must be maintained across languages. A signature is therefore an ordered list, which matters when a caller binds positional arguments in one language to named fields in another.

TypedInterface at line 39 is just inputs and outputs, both VariableMap. TaskTemplate consumes it in field 4, and the comment above that field is the design statement worth quoting: a strongly typed interface “enables others to use this task within a workflow and guarantees compile-time validation of the workflow to avoid costly runtime failures.” The type system exists so that a bad edge is rejected before a container is scheduled.

Parameter is where launch-time policy lives. Instead of weakening Variable, it wraps one and adds a oneof: a default Literal, a required boolean, an artifact query, or a concrete artifact identifier. That separation is why a task can declare epochs: int while a launch plan separately says this particular caller must provide it. If you have configured Celery task signatures, the instinct is familiar: validate early and fail cheaply.

From .proto to Python Import

The build facts here are concrete and easy to audit. buf.gen.python.yaml at the repository root configures four remote plugins: protocolbuffers/python:v24.1 for message modules, protocolbuffers/pyi:v24.1 for type stubs, grpc/python:v1.58.1 for gRPC servicers, and connectrpc/python:v0.9.0 for Connect clients. Managed mode is on, with optimize_for forced to CODE_SIZE so the generated descriptors stay compact.

The output is large. flyteidl2 contains 88 .proto files, and gen/python holds 92 *_pb2.py modules, 92 *_pb2_grpc.py modules, and 26 *_connect.py clients. The mismatch between 88 protos and 92 modules is a reminder that generation follows imported files, not just local ones. The core namespace alone yields interface_pb2.py at 43 lines, types_pb2.py at 61, literals_pb2.py at 100, and tasks_pb2.py at 207; most of each file is a serialized descriptor blob.

For a Python caller the interesting file is gen/python/flyteidl2/task/task_service_connect.py, 330 lines that expose TaskService methods. Its run-side sibling mirrors the seventeen RPCs on the run service, including streaming watches. The practical consequence: a Python process that wants to deploy a task imports a generated request class, builds a TaskSpec, and calls DeployTask over Connect. No bespoke client library has to be maintained in lockstep, because the client is regenerated from the same schema the server compiles. This is the same regenerate-from-schema discipline that makes Dask task graphs portable; here the schema is Protobuf rather than a Python object graph.

One Task, Three Specs

It is easy to conflate the three descriptions of a task, so keep them separate. TaskTemplate in core/tasks.proto is the reusable core: type string, metadata, typed interface, an extensible Struct for custom data, and exactly one execution target. TaskSpec in task_definition.proto is the deployable envelope: it requires a template and adds ordered default inputs, a display name, an environment and a cluster pool. TaskActionSpec in the executor is the runtime instance: one action inside one run, with a run name and an action type of either a plugin-driven task or a human-in-the-loop condition.

TaskTemplate also records how execution should be shaped. Field 20 is a WorkerKind enum with five values: unspecified for ordinary container and plugin work, sandbox for an interpreter with no container, microVM for an isolated VM, reusable for a long-lived replica, and gVisor for a user-space kernel sandbox. Field 19 is a ReusePolicy for warm pools, so one template describes not only what to run but which worker class should run it.

The runtime half is a Kubernetes controller. executor/pkg/controller/taskaction_controller.go is 1,970 lines and imports controller-runtime, connectrpc.com/connect and the plugin machinery. It tracks four condition types on a TaskAction: Progressing, Succeeded, Failed, and CleanupPending, with twelve reasons ranging from Queued and Executing to RetryableFailure, PluginNotFound, Paused and TimedOut. A constant at line 68 sets the default requeue interval to ten seconds, and the controller wires finalizers so cleanup runs after a terminal phase. This is the layer that makes a typed task observable as ordinary Kubernetes state, which is why the executor relies on the same primitives as any other controller in a Kubernetes cluster.

Plugins Are the Execution Seam

Everything above is inert without a plugin. flyteplugins/go/tasks/pluginmachinery/core/plugin.go defines the Plugin interface at line 40 and a PluginLoader function type at line 15 that turns a setup context into a plugin. The executor’s pkg/plugin/registry.go maps task types to loaded implementations, and pkg/plugin/task_exec_context.go plus task_exec_metadata.go carry the per-attempt state a plugin needs.

The implementations live under flyteplugins/go/tasks/plugins in five families: awsutils, core, k8s, webapi, and testing. A core plugin runs containers directly, k8s plugins lean on Kubernetes objects, and webapi plugins submit to external HTTP services. Because the Plugin contract is narrow, a new backend is an implementation rather than a fork of the controller. That narrow waist is why the executor can stay a single reconciler while plugins grow.

The controller’s condition branch is worth a note for readers who equate orchestration with retries only. taskaction_condition.go implements actions that wait for an external signal instead of a container, so a run can pause for human approval, and taskaction_cache.go handles cache keys so completed outputs can be reused. Both are small files invoked from the main reconciler, keeping the state machine in one readable place.

Honest Limits

The first limit is where the Python ergonomics live. This repository does not contain flytekit, so the @task decorator, the type engine, the local execution path and FlyteRemote described in older Flyte material are not files you can open in this tree. Do not expect to find flytekit/core/type_engine.py or flytekit/remote/ here; they belong to the separate SDK project. This monorepo is the protocol and control plane the SDK serializes into, and reading it answers a different question than reading the decorator layer.

The second limit is generated code volume. With 92 message modules and 26 Connect clients, the Python surface is mostly generated, so a bug in a client is usually a schema change rather than a hand edit. Teams that pin the generated package must regenerate in step with the server, and the four-plugin buf template is the single source of truth for that step.

The third limit is that proto-first design trades convenience for discipline. Every new field starts in .proto, flows through buf, and only then reaches Python. That is excellent for cross-language correctness and slower for the developer who just wants to add a keyword argument. The CODE_SIZE optimization also keeps descriptors compact rather than fast to introspect.

Flyte’s bet is that a typed contract is worth more than a friendly default. In this tree the bet is visible: a ten-value scalar enum, a recursively nested type message, an ordered interface, four code generators, a 1,970-line reconciler and a plugin interface that any backend can satisfy. If you are building Python work that must survive handoffs, the contract is the feature, and this is where it is defined.

Watch PyShine on YouTube

Contents