Skip to content

Commit c88c791

Browse files
author
arpechenin
committed
- rebase brunch
- add feature to regenerate all specs Signed-off-by: arpechenin <[email protected]>
1 parent 75d5d31 commit c88c791

File tree

127 files changed

+10129
-15835
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+10129
-15835
lines changed

backend/test/compiler/argo_ginkgo_test.go

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,17 @@
1515
package compiler
1616

1717
import (
18+
"flag"
1819
"fmt"
20+
"github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
21+
matcher "github.com/kubeflow/pipelines/backend/test/compiler/matchers"
1922
"os"
2023
"path/filepath"
24+
"sigs.k8s.io/yaml"
2125
"strings"
2226

2327
"github.com/kubeflow/pipelines/backend/src/apiserver/config/proxy"
2428
"github.com/kubeflow/pipelines/backend/src/v2/compiler/argocompiler"
25-
matcher "github.com/kubeflow/pipelines/backend/test/compiler/matchers"
2629
workflowutils "github.com/kubeflow/pipelines/backend/test/compiler/utils"
2730
. "github.com/kubeflow/pipelines/backend/test/constants"
2831
"github.com/kubeflow/pipelines/backend/test/logger"
@@ -32,6 +35,8 @@ import (
3235
. "github.com/onsi/gomega"
3336
)
3437

38+
var regenerateAllSkipTests = flag.Bool("regenerate", false, "Regenerate all compiled workflow and skip tests")
39+
3540
var _ = BeforeEach(func() {
3641
logger.Log("Initializing proxy config...")
3742
proxy.InitializeConfigWithEmptyForTests()
@@ -67,10 +72,26 @@ var _ = Describe("Verify Spec Compilation to Workflow >", Label(POSITIVE, WORKFL
6772
fileNameWithoutExtension := strings.TrimSuffix(pipelineSpecFileName, fileExtension)
6873
compiledWorkflowFileName := fileNameWithoutExtension + ".yaml"
6974
compiledWorkflowFilePath := filepath.Join(argoYAMLDir, compiledWorkflowFileName)
75+
76+
if *regenerateAllSkipTests {
77+
pipelineSpecs, platformSpec := workflowutils.LoadPipelineSpecsFromIR(
78+
pipelineSpecFilePath,
79+
param.compilerOptions.CacheDisabled,
80+
nil,
81+
)
82+
regeneratedWf := workflowutils.GetCompiledArgoWorkflow(pipelineSpecs, platformSpec, &param.compilerOptions)
83+
err := RegenerateSpec(compiledWorkflowFilePath, *regeneratedWf)
84+
if err != nil {
85+
Fail(fmt.Sprintf("Critical error: %v", err))
86+
}
87+
continue
88+
}
7089
It(fmt.Sprintf("When I compile %s pipeline spec, then the compiled yaml should be %s", pipelineSpecFileName, compiledWorkflowFileName), func() {
7190
test_utils.CheckIfSkipping(pipelineSpecFileName)
91+
7292
pipelineSpecs, platformSpec := workflowutils.LoadPipelineSpecsFromIR(pipelineSpecFilePath, param.compilerOptions.CacheDisabled, nil)
7393
compiledWorkflow := workflowutils.GetCompiledArgoWorkflow(pipelineSpecs, platformSpec, &param.compilerOptions)
94+
7495
if *createMissingGoldenFiles || *updateGoldenFiles {
7596
configuredWorkflow := workflowutils.ConfigureCacheSettings(compiledWorkflow, true)
7697
_, err := os.Stat(compiledWorkflowFilePath)
@@ -82,6 +103,7 @@ var _ = Describe("Verify Spec Compilation to Workflow >", Label(POSITIVE, WORKFL
82103
}
83104
}
84105
expectedWorkflow := workflowutils.UnmarshallWorkflowYAML(compiledWorkflowFilePath)
106+
85107
if param.compilerOptions.CacheDisabled {
86108
expectedWorkflow = workflowutils.ConfigureCacheSettings(expectedWorkflow, false)
87109
}
@@ -107,3 +129,23 @@ var _ = Describe("Verify Spec Compilation to Workflow >", Label(POSITIVE, WORKFL
107129
})
108130
}
109131
})
132+
133+
func RegenerateSpec(path string, wf v1alpha1.Workflow) error {
134+
wfYml, _ := yaml.Marshal(wf)
135+
wfYmlStr := string(wfYml)
136+
file, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
137+
if err != nil {
138+
return err
139+
}
140+
var wfLines []string
141+
for _, line := range strings.Split(wfYmlStr, "\n") {
142+
if !strings.Contains(line, "- --cache_disabled") {
143+
wfLines = append(wfLines, line)
144+
}
145+
}
146+
_, err = file.WriteString(strings.Join(wfLines, "\n"))
147+
if err != nil {
148+
return err
149+
}
150+
return nil
151+
}

backend/test/compiler/matchers/workflow_matcher.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func CompareWorkflows(actual *v1alpha1.Workflow, expected *v1alpha1.Workflow) {
129129
gomega.Expect(actual.Spec.Templates[index].HTTP).To(gomega.Equal(template.HTTP), "HTTP is not same")
130130
gomega.Expect(actual.Spec.Templates[index].Memoize).To(gomega.Equal(template.Memoize), "Memoize is not same")
131131
gomega.Expect(actual.Spec.Templates[index].Metadata).To(gomega.Equal(template.Metadata), "Metadata is not same")
132-
gomega.Expect(actual.Spec.Templates[index].Plugin).To(gomega.Equal(template.Plugin), "Plugin is not same")
132+
// gomega.Expect(actual.Spec.Templates[index].Plugin).To(gomega.Equal(template.Plugin), "Plugin is not same")
133133
gomega.Expect(actual.Spec.Templates[index].PriorityClassName).To(gomega.Equal(template.PriorityClassName), "PriorityClassName is not same")
134134
gomega.Expect(actual.Spec.Templates[index].Resource).To(gomega.Equal(template.Resource), "Resource is not same")
135135
gomega.Expect(actual.Spec.Templates[index].Script).To(gomega.Equal(template.Script), "Script is not same")

manifests/kustomize/base/pipeline/ml-pipeline-apiserver-deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ spec:
126126
value: ghcr.io/kubeflow/kfp-driver:2.14.3
127127
- name: V2_LAUNCHER_IMAGE
128128
value: ghcr.io/kubeflow/kfp-launcher:2.14.3
129-
image: ntny/kfp-api-server:central-driver-poc
129+
image: ntny/kfp-api-server:central-driver-poc01
130130
imagePullPolicy: IfNotPresent
131131
name: ml-pipeline-api-server
132132
ports:

test_data/compiled-workflows/add_numbers.yaml

Lines changed: 56 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -29,56 +29,7 @@ spec:
2929
pipelines.kubeflow.org/v2_component: "true"
3030
serviceAccountName: pipeline-runner
3131
templates:
32-
- container:
33-
args:
34-
- --type
35-
- CONTAINER
36-
- --pipeline_name
37-
- add-numbers
38-
- --run_id
39-
- '{{workflow.uid}}'
40-
- --run_name
41-
- '{{workflow.name}}'
42-
- --run_display_name
43-
- ""
44-
- --dag_execution_id
45-
- '{{inputs.parameters.parent-dag-id}}'
46-
- --component
47-
- '{{inputs.parameters.component}}'
48-
- --task
49-
- '{{inputs.parameters.task}}'
50-
- --task_name
51-
- '{{inputs.parameters.task-name}}'
52-
- --container
53-
- '{{inputs.parameters.container}}'
54-
- --iteration_index
55-
- '{{inputs.parameters.iteration-index}}'
56-
- --cached_decision_path
57-
- '{{outputs.parameters.cached-decision.path}}'
58-
- --pod_spec_patch_path
59-
- '{{outputs.parameters.pod-spec-patch.path}}'
60-
- --condition_path
61-
- '{{outputs.parameters.condition.path}}'
62-
- --kubernetes_config
63-
- '{{inputs.parameters.kubernetes-config}}'
64-
- --http_proxy
65-
- ""
66-
- --https_proxy
67-
- ""
68-
- --no_proxy
69-
- ""
70-
command:
71-
- driver
72-
image: ghcr.io/kubeflow/kfp-driver:latest
73-
name: ""
74-
resources:
75-
limits:
76-
cpu: 500m
77-
memory: 512Mi
78-
requests:
79-
cpu: 100m
80-
memory: 64Mi
81-
inputs:
32+
- inputs:
8233
parameters:
8334
- name: component
8435
- name: task
@@ -96,16 +47,40 @@ spec:
9647
- name: pod-spec-patch
9748
valueFrom:
9849
default: ""
99-
path: /tmp/outputs/pod-spec-patch
50+
jsonPath: $.pod-spec-patch
10051
- default: "false"
10152
name: cached-decision
10253
valueFrom:
10354
default: "false"
104-
path: /tmp/outputs/cached-decision
55+
jsonPath: $.cached-decision
10556
- name: condition
10657
valueFrom:
10758
default: "true"
108-
path: /tmp/outputs/condition
59+
jsonPath: $.condition
60+
plugin:
61+
driver-plugin:
62+
args:
63+
cache_disabled: true
64+
cached_decision_path: '{{outputs.parameters.cached-decision.path}}'
65+
component: '{{inputs.parameters.component}}'
66+
condition_path: '{{outputs.parameters.condition.path}}'
67+
container: '{{inputs.parameters.container}}'
68+
dag_execution_id: '{{inputs.parameters.parent-dag-id}}'
69+
http_proxy: ""
70+
https_proxy: ""
71+
iteration_index: '{{inputs.parameters.iteration-index}}'
72+
kubernetes_config: '{{inputs.parameters.kubernetes-config}}'
73+
log_level: ""
74+
no_proxy: ""
75+
pipeline_name: add-numbers
76+
pod_spec_patch_path: '{{outputs.parameters.pod-spec-patch.path}}'
77+
publish_logs: ""
78+
run_display_name: ""
79+
run_id: '{{workflow.uid}}'
80+
run_name: '{{workflow.name}}'
81+
task: '{{inputs.parameters.task}}'
82+
task_name: '{{inputs.parameters.task-name}}'
83+
type: CONTAINER
10984
- dag:
11085
tasks:
11186
- arguments:
@@ -168,7 +143,7 @@ spec:
168143
resources:
169144
limits:
170145
cpu: 500m
171-
memory: 128Mi
146+
memory: 256Mi
172147
requests:
173148
cpu: 100m
174149
volumeMounts:
@@ -228,54 +203,7 @@ spec:
228203
metadata: {}
229204
name: root
230205
outputs: {}
231-
- container:
232-
args:
233-
- --type
234-
- '{{inputs.parameters.driver-type}}'
235-
- --pipeline_name
236-
- add-numbers
237-
- --run_id
238-
- '{{workflow.uid}}'
239-
- --run_name
240-
- '{{workflow.name}}'
241-
- --run_display_name
242-
- ""
243-
- --dag_execution_id
244-
- '{{inputs.parameters.parent-dag-id}}'
245-
- --component
246-
- '{{inputs.parameters.component}}'
247-
- --task
248-
- '{{inputs.parameters.task}}'
249-
- --task_name
250-
- '{{inputs.parameters.task-name}}'
251-
- --runtime_config
252-
- '{{inputs.parameters.runtime-config}}'
253-
- --iteration_index
254-
- '{{inputs.parameters.iteration-index}}'
255-
- --execution_id_path
256-
- '{{outputs.parameters.execution-id.path}}'
257-
- --iteration_count_path
258-
- '{{outputs.parameters.iteration-count.path}}'
259-
- --condition_path
260-
- '{{outputs.parameters.condition.path}}'
261-
- --http_proxy
262-
- ""
263-
- --https_proxy
264-
- ""
265-
- --no_proxy
266-
- ""
267-
command:
268-
- driver
269-
image: ghcr.io/kubeflow/kfp-driver:latest
270-
name: ""
271-
resources:
272-
limits:
273-
cpu: 500m
274-
memory: 512Mi
275-
requests:
276-
cpu: 100m
277-
memory: 64Mi
278-
inputs:
206+
- inputs:
279207
parameters:
280208
- name: component
281209
- default: ""
@@ -296,15 +224,38 @@ spec:
296224
parameters:
297225
- name: execution-id
298226
valueFrom:
299-
path: /tmp/outputs/execution-id
227+
jsonPath: $.execution-id
300228
- name: iteration-count
301229
valueFrom:
302230
default: "0"
303-
path: /tmp/outputs/iteration-count
231+
jsonPath: $.iteration-count
304232
- name: condition
305233
valueFrom:
306234
default: "true"
307-
path: /tmp/outputs/condition
235+
jsonPath: $.condition
236+
plugin:
237+
driver-plugin:
238+
args:
239+
cache_disabled: true
240+
component: '{{inputs.parameters.component}}'
241+
condition_path: '{{outputs.parameters.condition.path}}'
242+
dag_execution_id: '{{inputs.parameters.parent-dag-id}}'
243+
execution_id_path: '{{outputs.parameters.execution-id.path}}'
244+
http_proxy: ""
245+
https_proxy: ""
246+
iteration_count_path: '{{outputs.parameters.iteration-count.path}}'
247+
iteration_index: '{{inputs.parameters.iteration-index}}'
248+
log_level: ""
249+
no_proxy: ""
250+
pipeline_name: add-numbers
251+
publish_logs: ""
252+
run_display_name: ""
253+
run_id: '{{workflow.uid}}'
254+
run_name: '{{workflow.name}}'
255+
runtime_config: '{{inputs.parameters.runtime-config}}'
256+
task: '{{inputs.parameters.task}}'
257+
task_name: '{{inputs.parameters.task-name}}'
258+
type: '{{inputs.parameters.driver-type}}'
308259
- dag:
309260
tasks:
310261
- arguments:

0 commit comments

Comments
 (0)