Skip to content

Commit 87c7471

Browse files
Add Argo workflow title & description support (#2628)
fixes #2626 Adds support for Argo Workflow Title & description. --------- Co-authored-by: Sakari Ikonen <sakari.a.ikonen@gmail.com>
1 parent f04cdc1 commit 87c7471

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

metaflow/plugins/argo/argo_workflows.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ def __init__(
121121
incident_io_metadata: List[str] = None,
122122
enable_heartbeat_daemon=True,
123123
enable_error_msg_capture=False,
124+
workflow_title=None,
125+
workflow_description=None,
124126
):
125127
# Some high-level notes -
126128
#
@@ -177,6 +179,8 @@ def __init__(
177179
)
178180
self.enable_heartbeat_daemon = enable_heartbeat_daemon
179181
self.enable_error_msg_capture = enable_error_msg_capture
182+
self.workflow_title = workflow_title
183+
self.workflow_description = workflow_description
180184
self.parameters = self._process_parameters()
181185
self.config_parameters = self._process_config_parameters()
182186
self.triggers, self.trigger_options = self._process_triggers()
@@ -430,6 +434,25 @@ def _base_kubernetes_annotations(self):
430434
"metaflow/project_flow_name": current.project_flow_name,
431435
}
432436
)
437+
438+
# Add Argo Workflows title and description annotations
439+
# https://argo-workflows.readthedocs.io/en/latest/title-and-description/
440+
# Use CLI-provided values or auto-populate from metadata
441+
title = (
442+
(self.workflow_title.strip() if self.workflow_title else None)
443+
or current.get("project_flow_name")
444+
or self.flow.name
445+
)
446+
447+
description = (
448+
self.workflow_description.strip() if self.workflow_description else None
449+
) or (self.flow.__doc__.strip() if self.flow.__doc__ else None)
450+
451+
if title:
452+
annotations["workflows.argoproj.io/title"] = title
453+
if description:
454+
annotations["workflows.argoproj.io/description"] = description
455+
433456
return annotations
434457

435458
def _get_schedule(self):
@@ -894,7 +917,16 @@ def _compile_workflow_template(self):
894917
.annotations(
895918
{
896919
**annotations,
897-
**self._base_annotations,
920+
**{
921+
k: v
922+
for k, v in self._base_annotations.items()
923+
if k
924+
# Skip custom title/description for workflows as this makes it harder to find specific runs.
925+
not in [
926+
"workflows.argoproj.io/title",
927+
"workflows.argoproj.io/description",
928+
]
929+
},
898930
**{"metaflow/run_id": "argo-{{workflow.name}}"},
899931
}
900932
)

metaflow/plugins/argo/argo_workflows_cli.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,18 @@ def argo_workflows(obj, name=None):
227227
show_default=True,
228228
help="Capture stack trace of first failed task in exit hook.",
229229
)
230+
@click.option(
231+
"--workflow-title",
232+
default=None,
233+
type=str,
234+
help="Custom title for the workflow displayed in Argo Workflows UI. Defaults to `project_flow_name`. Supports markdown formatting.",
235+
)
236+
@click.option(
237+
"--workflow-description",
238+
default=None,
239+
type=str,
240+
help="Custom description for the workflow displayed in Argo Workflows UI. Defaults to the flow's docstring if available. Supports markdown formatting and multi-line text.",
241+
)
230242
@click.pass_obj
231243
def create(
232244
obj,
@@ -248,6 +260,8 @@ def create(
248260
incident_io_alert_source_config_id=None,
249261
incident_io_metadata=None,
250262
enable_heartbeat_daemon=True,
263+
workflow_title=None,
264+
workflow_description=None,
251265
deployer_attribute_file=None,
252266
enable_error_msg_capture=False,
253267
):
@@ -312,6 +326,8 @@ def create(
312326
incident_io_metadata,
313327
enable_heartbeat_daemon,
314328
enable_error_msg_capture,
329+
workflow_title,
330+
workflow_description,
315331
)
316332

317333
if only_json:
@@ -658,6 +674,8 @@ def make_flow(
658674
incident_io_metadata,
659675
enable_heartbeat_daemon,
660676
enable_error_msg_capture,
677+
workflow_title,
678+
workflow_description,
661679
):
662680
# TODO: Make this check less specific to Amazon S3 as we introduce
663681
# support for more cloud object stores.
@@ -750,6 +768,8 @@ def make_flow(
750768
incident_io_metadata=incident_io_metadata,
751769
enable_heartbeat_daemon=enable_heartbeat_daemon,
752770
enable_error_msg_capture=enable_error_msg_capture,
771+
workflow_title=workflow_title,
772+
workflow_description=workflow_description,
753773
)
754774

755775

0 commit comments

Comments
 (0)