Skip to content

Commit efedc30

Browse files
authored
Merge branch 'main' into mike/flyte-proxy-app
2 parents 4e53058 + 33548bf commit efedc30

7 files changed

Lines changed: 880 additions & 7 deletions

File tree

src/flyte/cli/_common.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
PREFERRED_ACCENT_COLOR = "bold #FFD700"
3838
HEADER_STYLE = f"{PREFERRED_ACCENT_COLOR} on black"
3939

40+
#: Name of the built-in example under both `flyte run` and `flyte serve`. It lives here
41+
#: rather than in either module because both spell the same command.
42+
HELLO_CMD = "hello"
43+
4044
PROJECT_OPTION = click.Option(
4145
param_decls=["-p", "--project"],
4246
required=False,

src/flyte/cli/_gen.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ def docs(
4545
raise click.ClickException("Invalid documentation type: {}".format(doc_type))
4646

4747

48+
#: FileGroups whose subcommands are one-per-user-file, except for a few static ones.
49+
_GROUPS_WITH_STATIC_COMMANDS = frozenset({"TaskFiles", "AppFiles"})
50+
51+
#: Subcommands of `flyte run` and `flyte serve` that exist regardless of what is in the working
52+
#: directory, and so belong in the docs. Everything else there is one command per user file.
53+
_STATIC_COMMANDS = frozenset({"deployed-task", "hello"})
54+
55+
4856
def walk_commands(ctx: click.Context) -> Generator[Tuple[str, click.Command, click.Context], None, None]:
4957
"""
5058
Recursively walk a Click command tree, starting from the given context.
@@ -59,14 +67,14 @@ def walk_commands(ctx: click.Context) -> Generator[Tuple[str, click.Command, cli
5967
elif isinstance(command, common.FileGroup):
6068
# If the command is a FileGroup, yield its file path and the command itself
6169
# No need to recurse further into FileGroup as most subcommands are dynamically generated
62-
# The exception is TaskFiles which has the special 'deployed-task' subcommand that should be documented
63-
if type(command).__name__ == "TaskFiles":
64-
# For TaskFiles, we only want the special non-file-based subcommands like 'deployed-task'
65-
# Exclude all dynamic file-based commands
70+
# The exception is TaskFiles and AppFiles, which have static subcommands like
71+
# 'deployed-task' and 'hello' that should be documented
72+
if type(command).__name__ in _GROUPS_WITH_STATIC_COMMANDS:
73+
# Only the static, non-file-based subcommands. Exclude all dynamic file-based commands.
6674
try:
6775
names = command.list_commands(ctx)
6876
for name in names:
69-
if name == "deployed-task": # Only include the deployed-task command
77+
if name in _STATIC_COMMANDS:
7078
try:
7179
subcommand = command.get_command(ctx, name)
7280
if subcommand is not None:

0 commit comments

Comments
 (0)