Skip to content

Commit 126a141

Browse files
authored
fix(test): overriding kfp version when loading component def from yaml (#12364)
Signed-off-by: Nelesh Singla <[email protected]>
1 parent de3feb5 commit 126a141

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

sdk/python/kfp/compiler/compiler.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def compile(
5252
pipeline_func: base_component.BaseComponent,
5353
package_path: str,
5454
pipeline_name: Optional[str] = None,
55+
pipeline_display_name: Optional[str] = None,
5556
pipeline_parameters: Optional[Dict[str, Any]] = None,
5657
type_check: bool = True,
5758
kubernetes_manifest_options: Optional[
@@ -64,6 +65,7 @@ def compile(
6465
pipeline_func: Pipeline function constructed with the ``@dsl.pipeline`` or component constructed with the ``@dsl.component`` decorator.
6566
package_path: Output YAML file path. For example, ``'~/my_pipeline.yaml'`` or ``'~/my_component.yaml'``.
6667
pipeline_name: Name of the pipeline.
68+
pipeline_display_name: Display name of the pipeline
6769
pipeline_parameters: Map of parameter names to argument values.
6870
type_check: Whether to enable type checking of component interfaces during compilation.
6971
kubernetes_manifest_options: KubernetesManifestOptions object for Kubernetes manifest output during pipeline compilation.
@@ -82,7 +84,7 @@ def compile(
8284
pipeline_spec=pipeline_func.pipeline_spec,
8385
pipeline_name=pipeline_name,
8486
pipeline_parameters=pipeline_parameters,
85-
)
87+
pipeline_display_name=pipeline_display_name)
8688

8789
builder.write_pipeline_spec_to_file(
8890
pipeline_spec=pipeline_spec,

sdk/python/test/test_utils/comparison_utils.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,14 @@ def compare_pipeline_spec_dicts(cls, actual: dict, expected: dict,
5757
# Override SDK Version in the args as well to match the current version
5858
if key == 'command':
5959
for index, command in enumerate(value):
60-
if re.search("kfp==[0-9].[0-9]+.[0-9]+",
61-
command) is not None:
62-
value[index] = re.sub(
63-
"kfp==[0-9].[0-9]+.[0-9]+",
64-
f"kfp=={kfp.__version__}", command)
60+
value[index] = cls.override_sdk_version(command)
61+
for index, command in enumerate(actual[key]):
62+
actual[key][index] = cls.override_sdk_version(
63+
command)
6564
assert value == actual[
6665
key], f'Value for "{key}" is not the same'
66+
67+
@classmethod
68+
def override_sdk_version(cls, text: str) -> str:
69+
return re.sub("kfp==[0-9].[0-9]+.[0-9]+", f"kfp=={kfp.__version__}",
70+
text)

0 commit comments

Comments
 (0)