Skip to content

task aliases in the SDK and CLI - #1565

Draft
dansola wants to merge 2 commits into
mainfrom
danielsola/task-aliases
Draft

dansola wants to merge 2 commits into
mainfrom
danielsola/task-aliases

Conversation

@dansola

@dansola dansola commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Overview

Adds the client and CLI for task aliases — mutable named pointers to immutable task versions. Backend is in the Union cloud repo; the contract is in the companion flyteorg/flyte proto PR.

An alias like prod lets an external caller launch a task without knowing which version is promoted, and lets an operator move that pointer without redeploying.

What changed

alias= as a third version selector, sitting exactly where version= and auto_version= already do — not a new concept, a new way to name one:

task = flyte.remote.Task.get("event_driven.ingest", alias="prod")
run = flyte.run(task, payload=event["detail"])

Exactly one of the three is required; the alias is sent on the wire and resolved server-side, so the caller never learns a version.

flyte.remote.TaskAlias with set / get / listall / history / delete. set returns (alias, previous_version) so callers can render prod: v1.4.0 -> v1.7.0 without a second lookup.

A flyte alias command group:

flyte alias set prod event_driven.ingest --to v1.4.0   # promote, or roll back
flyte alias get prod event_driven.ingest
flyte alias list event_driven.ingest
flyte alias history prod event_driven.ingest
flyte alias delete prod event_driven.ingest

set is deliberately one command for both directions — pointing at an older version is a rollback and needs no rebuild or redeploy.

_protocols.py switches to lazy annotations. Protocol bodies are evaluated at class-creation time, so naming SetTaskAliasRequest in a type hint turned an import-time AttributeError into a hard failure for anyone on a flyteidl2 that has not shipped the alias messages — including every task container, which installs a released flyteidl2. from __future__ import annotations fixes it. Worth a look on review: it means this module tolerates an older idl than it was built against, which is the safer default for all of these Protocols, not just the new ones.

How this was tested

  • pytest tests/cli — 462 pass. ruff check / ruff format clean.
  • Every subcommand's --help renders. An earlier revision used cls=common.GroupBase on the group, which puts --project/--domain on the group callback and made flyte alias set --help fail with alias() got an unexpected keyword argument 'project'; the group now matches the get/delete/update convention and the options come from CommandBase on each subcommand.
  • End to end against a k3d devbox running the backend: deploy r1, point prod at it, launch by alias with a payload, deploy r2 and r3, confirm prod still resolves to r1, promote to r3, roll back, read history. All steps pass, with the payload arriving intact (processed 'first' on r1). Full output in the cloud PR's test plan.
  • Two bugs this found and fixed: the import-time break above, and TaskAlias.set_by reading a subject field that does not exist — EnrichedIdentity is a oneof of User/Application, now rendered the way TaskDetails already renders deployed_by.

Dependency

Needs a flyteidl2 release carrying the alias messages; pyproject.toml currently pins flyteidl2==2.0.44. Merge after the proto PR lands and the pin is bumped.

https://github.com/unionai/cloud/pull/18303
flyteorg/flyte#8013

Replace the standalone `flyte alias` group with subcommands on the existing
verbs, matching how triggers are managed:

  flyte update alias NAME TASK_NAME --to VERSION
  flyte get alias TASK_NAME [NAME] [--history]
  flyte delete alias NAME TASK_NAME

`get alias` takes TASK_NAME first so NAME can be optional for listing, the
same shape as `flyte get trigger`. History is a `--history` flag rather than
its own subcommand. project/domain are now passed through to TaskAlias
explicitly. Adds CLI tests for all three commands.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: davidmirror-ops <david.espejo@union.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants