From 7128973b64b1432d68afddbda5639adc2d69222b Mon Sep 17 00:00:00 2001 From: Yaqi Date: Tue, 5 Oct 2021 11:04:03 -0700 Subject: [PATCH] release notes + test --- sdk/RELEASE.md | 2 ++ .../components/experimental/component_spec.py | 21 ++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/sdk/RELEASE.md b/sdk/RELEASE.md index dc7454758948..2bb0dc873494 100644 --- a/sdk/RELEASE.md +++ b/sdk/RELEASE.md @@ -12,6 +12,8 @@ ## Bug Fixes and Other Changes +* update v2 yaml format [\#6661](https://github.com/kubeflow/pipelines/pull/6661) + ## Documentation Updates # 1.8.4 diff --git a/sdk/python/kfp/v2/components/experimental/component_spec.py b/sdk/python/kfp/v2/components/experimental/component_spec.py index d0147ff5ef9a..408feee699b7 100644 --- a/sdk/python/kfp/v2/components/experimental/component_spec.py +++ b/sdk/python/kfp/v2/components/experimental/component_spec.py @@ -17,10 +17,7 @@ import itertools import json from typing import Any, Dict, Mapping, Optional, Sequence, Union -try: - from typing import OrderedDict -except ImportError: - from collections import OrderedDict + from kfp.components import _components from kfp.components import structures import pydantic @@ -136,8 +133,8 @@ class IfPresentPlaceholderStructure(BaseModel): then: Sequence[ValidCommandArgs] otherwise: Optional[Sequence[ValidCommandArgs]] = None - @pydantic.validator('otherwise') - def empty_sequence(cls, v): + @pydantic.validator('otherwise', allow_reuse=True) + def empty_otherwise_sequence(cls, v): if v == []: return None return v @@ -191,13 +188,13 @@ class ContainerSpec(BaseModel): env: Optional[Mapping[str, ValidCommandArgs]] = None resources: Optional[ResourceSpec] = None - @pydantic.validator('commands', 'arguments') + @pydantic.validator('commands', 'arguments', allow_reuse=True) def empty_sequence(cls, v): if v == []: return None return v - @pydantic.validator('env') + @pydantic.validator('env', allow_reuse=True) def empty_map(cls, v): if v == {}: return None @@ -286,6 +283,10 @@ class ComponentSpec(BaseModel): implementation: The implementation of the component. Either an executor (container, importer) or a DAG consists of other components. """ + try: + from typing import OrderedDict + except: + from typing import MutableMapping as OrderedDict name: str description: Optional[str] = None @@ -293,13 +294,13 @@ class ComponentSpec(BaseModel): outputs: Optional[OrderedDict[str, OutputSpec]] = None implementation: Implementation - @pydantic.validator('inputs', 'outputs') + @pydantic.validator('inputs', 'outputs', allow_reuse=True) def empty_map(cls, v): if v == {}: return None return v - @pydantic.root_validator + @pydantic.root_validator(allow_reuse=True) def validate_placeholders(cls, values): if values.get('implementation').container is None: return values