Skip to content

Commit 6a13f4b

Browse files
authored
feat(backend): Add support for job and task placeholders in the KFP backend (kubeflow#11599)
This adds support for the following placeholders in the KFP backend: - dsl.PIPELINE_JOB_NAME_PLACEHOLDER - dsl.PIPELINE_JOB_RESOURCE_NAME_PLACEHOLDER - dsl.PIPELINE_JOB_ID_PLACEHOLDER - dsl.PIPELINE_TASK_NAME_PLACEHOLDER - dsl.PIPELINE_TASK_ID_PLACEHOLDER Resolves: kubeflow#10453 Signed-off-by: mprahl <[email protected]>
1 parent 926aec5 commit 6a13f4b

File tree

15 files changed

+153
-5
lines changed

15 files changed

+153
-5
lines changed

backend/src/apiserver/template/v2_template.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ func (t *V2Spec) RunWorkflow(modelRun *model.Run, options RunWorkflowOptions) (u
296296
if err := protojson.Unmarshal(bytes, spec); err != nil {
297297
return nil, util.NewInternalServerError(err, "Failed to parse pipeline spec")
298298
}
299-
job := &pipelinespec.PipelineJob{PipelineSpec: spec}
299+
job := &pipelinespec.PipelineJob{PipelineSpec: spec, DisplayName: modelRun.DisplayName}
300300
jobRuntimeConfig, err := modelToPipelineJobRuntimeConfig(&modelRun.RuntimeConfig)
301301
if err != nil {
302302
return nil, util.NewInternalServerError(err, "Failed to convert to PipelineJob RuntimeConfig")

backend/src/v2/cmd/driver/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ var (
4646
driverType = flag.String(driverTypeArg, "", "task driver type, one of ROOT_DAG, DAG, CONTAINER")
4747
pipelineName = flag.String("pipeline_name", "", "pipeline context name")
4848
runID = flag.String("run_id", "", "pipeline run uid")
49+
runName = flag.String("run_name", "", "pipeline run name (Kubernetes object name)")
50+
runDisplayName = flag.String("run_display_name", "", "pipeline run display name")
4951
componentSpecJson = flag.String("component", "{}", "component spec")
5052
taskSpecJson = flag.String("task", "", "task spec")
5153
runtimeConfigJson = flag.String("runtime_config", "", "jobruntime config")
@@ -153,6 +155,8 @@ func drive() (err error) {
153155
options := driver.Options{
154156
PipelineName: *pipelineName,
155157
RunID: *runID,
158+
RunName: *runName,
159+
RunDisplayName: *runDisplayName,
156160
Namespace: namespace,
157161
Component: componentSpec,
158162
Task: taskSpec,

backend/src/v2/compiler/argocompiler/argo.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,11 @@ func runID() string {
343343
return "{{workflow.uid}}"
344344
}
345345

346+
func runResourceName() string {
347+
// This translates to the Argo Workflow object name.
348+
return "{{workflow.name}}"
349+
}
350+
346351
func workflowParameter(name string) string {
347352
return fmt.Sprintf("{{workflow.parameters.%s}}", name)
348353
}

backend/src/v2/compiler/argocompiler/container.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ func (c *workflowCompiler) addContainerDriverTemplate() string {
166166
"--type", "CONTAINER",
167167
"--pipeline_name", c.spec.GetPipelineInfo().GetName(),
168168
"--run_id", runID(),
169+
"--run_name", runResourceName(),
170+
"--run_display_name", c.job.DisplayName,
169171
"--dag_execution_id", inputValue(paramParentDagID),
170172
"--component", inputValue(paramComponent),
171173
"--task", inputValue(paramTask),

backend/src/v2/compiler/argocompiler/dag.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,8 @@ func (c *workflowCompiler) addDAGDriverTemplate() string {
561561
"--type", inputValue(paramDriverType),
562562
"--pipeline_name", c.spec.GetPipelineInfo().GetName(),
563563
"--run_id", runID(),
564+
"--run_name", runResourceName(),
565+
"--run_display_name", c.job.DisplayName,
564566
"--dag_execution_id", inputValue(paramParentDagID),
565567
"--component", inputValue(paramComponent),
566568
"--task", inputValue(paramTask),

backend/src/v2/compiler/argocompiler/testdata/create_mount_delete_dynamic_pvc.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ spec:
4747
- my-pipeline
4848
- --run_id
4949
- '{{workflow.uid}}'
50+
- --run_name
51+
- '{{workflow.name}}'
52+
- --run_display_name
53+
- ''
5054
- --dag_execution_id
5155
- '{{inputs.parameters.parent-dag-id}}'
5256
- --component
@@ -283,6 +287,10 @@ spec:
283287
- my-pipeline
284288
- --run_id
285289
- '{{workflow.uid}}'
290+
- --run_name
291+
- '{{workflow.name}}'
292+
- --run_display_name
293+
- ''
286294
- --dag_execution_id
287295
- '{{inputs.parameters.parent-dag-id}}'
288296
- --component

backend/src/v2/compiler/argocompiler/testdata/create_pod_metadata.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ spec:
3535
- namespace/n1/pipeline/hello-world
3636
- --run_id
3737
- '{{workflow.uid}}'
38+
- --run_name
39+
- '{{workflow.name}}'
40+
- --run_display_name
41+
- ''
3842
- --dag_execution_id
3943
- '{{inputs.parameters.parent-dag-id}}'
4044
- --component
@@ -226,6 +230,10 @@ spec:
226230
- namespace/n1/pipeline/hello-world
227231
- --run_id
228232
- '{{workflow.uid}}'
233+
- --run_name
234+
- '{{workflow.name}}'
235+
- --run_display_name
236+
- ''
229237
- --dag_execution_id
230238
- '{{inputs.parameters.parent-dag-id}}'
231239
- --component

backend/src/v2/compiler/argocompiler/testdata/exit_handler.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ spec:
5252
- pipeline-with-exit-handler
5353
- --run_id
5454
- '{{workflow.uid}}'
55+
- --run_name
56+
- '{{workflow.name}}'
57+
- --run_display_name
58+
- ''
5559
- --dag_execution_id
5660
- '{{inputs.parameters.parent-dag-id}}'
5761
- --component
@@ -289,6 +293,10 @@ spec:
289293
- pipeline-with-exit-handler
290294
- --run_id
291295
- '{{workflow.uid}}'
296+
- --run_name
297+
- '{{workflow.name}}'
298+
- --run_display_name
299+
- ''
292300
- --dag_execution_id
293301
- '{{inputs.parameters.parent-dag-id}}'
294302
- --component

backend/src/v2/compiler/argocompiler/testdata/hello_world.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ spec:
3333
- namespace/n1/pipeline/hello-world
3434
- --run_id
3535
- '{{workflow.uid}}'
36+
- --run_name
37+
- '{{workflow.name}}'
38+
- --run_display_name
39+
- ''
3640
- --dag_execution_id
3741
- '{{inputs.parameters.parent-dag-id}}'
3842
- --component
@@ -216,6 +220,10 @@ spec:
216220
- namespace/n1/pipeline/hello-world
217221
- --run_id
218222
- '{{workflow.uid}}'
223+
- --run_name
224+
- '{{workflow.name}}'
225+
- --run_display_name
226+
- ''
219227
- --dag_execution_id
220228
- '{{inputs.parameters.parent-dag-id}}'
221229
- --component

backend/src/v2/compiler/argocompiler/testdata/importer.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ spec:
105105
- pipeline-with-importer
106106
- --run_id
107107
- '{{workflow.uid}}'
108+
- --run_name
109+
- '{{workflow.name}}'
110+
- --run_display_name
111+
- ''
108112
- --dag_execution_id
109113
- '{{inputs.parameters.parent-dag-id}}'
110114
- --component

0 commit comments

Comments
 (0)