Skip to content

Commit 920a790

Browse files
zzstoatzzclaude
andcommitted
feat(cli): migrate flow-run command to cyclopts (wave 3b)
Native cyclopts implementation of all flow-run subcommands: inspect, ls, delete, cancel, retry, logs, execute. Includes the _get_flow_run_by_id_or_name helper for retry-by-name support. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent fcda260 commit 920a790

File tree

6 files changed

+647
-11
lines changed

6 files changed

+647
-11
lines changed

.github/workflows/python-tests.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ jobs:
102102
# PREFECT_CLI_FAST=1 so invoke_and_assert routes through the
103103
# cyclopts runner. Only includes test files for commands that have
104104
# been migrated to cyclopts (config, profile, server, worker, shell,
105-
# version). Expand this list as more commands are migrated; when
105+
# version, flow, flow-run). Expand this list as more commands are migrated; when
106106
# the migration is complete replace with tests/cli/.
107107
- test-type:
108108
name: CLI Tests (Cyclopts)
@@ -115,6 +115,8 @@ jobs:
115115
tests/cli/test_server_services.py
116116
tests/cli/test_version.py
117117
tests/cli/test_root.py
118+
tests/cli/test_flow.py
119+
tests/cli/test_flow_run.py
118120
tests/cli/test_cyclopts_runner.py
119121
tests/cli/test_cyclopts_parity.py
120122
database: "postgres:14"

benches/cli-bench.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,15 @@ name = "prefect shell --help (cyclopts)"
6060
args = ["env", "PREFECT_CLI_FAST=1", "prefect", "shell", "--help"]
6161
category = "startup"
6262
description = "shell help via cyclopts"
63+
64+
[[commands]]
65+
name = "prefect flow ls (cyclopts)"
66+
args = ["env", "PREFECT_CLI_FAST=1", "prefect", "flow", "ls"]
67+
category = "startup"
68+
description = "flow ls via cyclopts"
69+
70+
[[commands]]
71+
name = "prefect flow-run ls (cyclopts)"
72+
args = ["env", "PREFECT_CLI_FAST=1", "prefect", "flow-run", "ls"]
73+
category = "startup"
74+
description = "flow-run ls via cyclopts"

src/prefect/cli/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
# to cyclopts instead of delegating to typer.
2727
_CYCLOPTS_COMMANDS: set[str] = {
2828
"config",
29+
"flow-run",
2930
"profile",
3031
"server",
3132
"shell",

src/prefect/cli/_cyclopts/__init__.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ def app():
212212
"events",
213213
"experimental",
214214
"flow",
215-
"flow-run",
216215
"global-concurrency-limit",
217216
"sdk",
218217
"task",
@@ -297,15 +296,9 @@ def flow_default(
297296

298297

299298
# --- flow-run ---
300-
flow_run_app = _delegated_app("flow-run", "Interact with flow runs.")
301-
_app.command(flow_run_app)
302-
299+
from prefect.cli._cyclopts.flow_run import flow_run_app
303300

304-
@flow_run_app.default
305-
def flow_run_default(
306-
*tokens: Annotated[str, cyclopts.Parameter(show=False, allow_leading_hyphen=True)],
307-
):
308-
_delegate("flow-run", tokens)
301+
_app.command(flow_run_app)
309302

310303

311304
# --- deployment ---

0 commit comments

Comments
 (0)