Skip to content

Commit

Permalink
chore(sdk): Remove v2 components fork, use v1 instead. (kubeflow#5042)
Browse files Browse the repository at this point in the history
* Remove v2.components fork

* fix setup.py
  • Loading branch information
chensun authored Jan 29, 2021
1 parent 35bc50e commit ecb14f4
Show file tree
Hide file tree
Showing 21 changed files with 29 additions and 2,071 deletions.
11 changes: 7 additions & 4 deletions sdk/python/kfp/components/_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import copy
from collections import OrderedDict
import pathlib
from typing import Any, Callable, List, Mapping, NamedTuple, Sequence, Union
from typing import Any, Callable, List, Mapping, NamedTuple, Optional, Sequence, Union
from ._naming import _sanitize_file_name, _sanitize_python_function_name, generate_unique_name_conversion_table
from ._yaml_utils import load_yaml
from .structures import *
Expand Down Expand Up @@ -483,6 +483,7 @@ def _resolve_command_line_and_paths(
argument_serializer: Callable[[str], str] = serialize_value,
input_uri_generator: Callable[[str], str] = _generate_input_uri,
output_uri_generator: Callable[[str], str] = _generate_output_uri,
input_value_generator: Optional[Callable[[str], str]] = None,
input_metadata_path_generator: Callable[
[str], str] = _generate_input_metadata_path,
output_metadata_path_generator: Callable[
Expand Down Expand Up @@ -522,9 +523,11 @@ def expand_command_part(arg) -> Union[str, List[str], None]:
input_spec = inputs_dict[input_name]
input_value = argument_values.get(input_name, None)
if input_value is not None:
serialized_argument = argument_serializer(input_value, input_spec.type)
inputs_consumed_by_value[input_name] = serialized_argument
return serialized_argument
if input_value_generator is not None:
inputs_consumed_by_value[input_name] = input_value_generator(input_name)
else:
inputs_consumed_by_value[input_name] = argument_serializer(input_value, input_spec.type)
return inputs_consumed_by_value[input_name]
else:
if input_spec.optional:
return None
Expand Down
4 changes: 2 additions & 2 deletions sdk/python/kfp/dsl/_component_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import collections
import copy
from typing import Any, Mapping
from typing import Any, Mapping, Optional
from ..components.structures import ComponentSpec, ComponentReference
from ..components._components import _default_component_name, _resolve_command_line_and_paths
from ..components._naming import _sanitize_python_function_name, generate_unique_name_conversion_table
Expand All @@ -24,7 +24,7 @@
def _create_container_op_from_component_and_arguments(
component_spec: ComponentSpec,
arguments: Mapping[str, Any],
component_ref: ComponentReference = None,
component_ref: Optional[ComponentReference] = None,
) -> 'dsl.ContainerOp':
# Check types of the reference arguments and serialize PipelineParams
arguments = arguments.copy()
Expand Down
4 changes: 2 additions & 2 deletions sdk/python/kfp/v2/compiler/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from kfp.compiler._k8s_helper import sanitize_k8s_name
from kfp.v2 import dsl
from kfp.v2.compiler import compiler_utils
from kfp.v2.components import python_op
from kfp.components import _python_op
from kfp.v2.dsl import importer_node
from kfp.v2.dsl import type_utils
from kfp.pipeline_spec import pipeline_spec_pb2
Expand Down Expand Up @@ -141,7 +141,7 @@ def _create_pipeline(

# Create the arg list with no default values and call pipeline function.
# Assign type information to the PipelineParam
pipeline_meta = python_op._extract_component_interface(pipeline_func)
pipeline_meta = _python_op._extract_component_interface(pipeline_func)
pipeline_name = pipeline_name or pipeline_meta.name

args_list = []
Expand Down
32 changes: 1 addition & 31 deletions sdk/python/kfp/v2/compiler/compiler_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import tempfile
import unittest

from kfp import components
from kfp.v2 import compiler
from kfp.v2 import components
from kfp.v2 import dsl


Expand Down Expand Up @@ -319,36 +319,6 @@ def my_pipeline():
pipeline_root='dummy',
output_path='output.json')

def test_compile_pipeline_with_outputpath_should_warn(self):

with self.assertWarnsRegex(
UserWarning, 'Local file paths are currently unsupported for I/O.'):
component_op = components.load_component_from_text("""
name: compoent use outputPath
outputs:
- {name: metrics, type: Metrics}
implementation:
container:
image: dummy
args:
- {outputPath: metrics}
""")

def test_compile_pipeline_with_inputpath_should_warn(self):

with self.assertWarnsRegex(
UserWarning, 'Local file paths are currently unsupported for I/O.'):
component_op = components.load_component_from_text("""
name: compoent use inputPath
inputs:
- {name: data, type: Datasets}
implementation:
container:
image: dummy
args:
- {inputPath: data}
""")

def test_compile_pipeline_with_invalid_name_should_raise_error(self):

def my_pipeline():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from kfp.v2 import components
from kfp import components
from kfp.v2 import dsl
import kfp.v2.compiler as compiler

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import pathlib

from kfp.v2 import components
from kfp import components
from kfp.v2 import dsl
import kfp.v2.compiler as compiler

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import pathlib

from kfp.v2 import components
from kfp import components
from kfp import dsl
import kfp.v2.compiler as compiler

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from kfp.v2 import components
from kfp import components
from kfp.v2 import dsl
import kfp.v2.compiler as compiler
import pathlib
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from kfp.v2 import components
from kfp import components
from kfp.v2 import dsl
import kfp.v2.compiler as compiler
import pathlib
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import pathlib

from kfp.v2 import components
from kfp import components
from kfp.v2 import compiler
from kfp.v2 import dsl

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import pathlib

from kfp.v2 import components
from kfp import components
from kfp.v2 import dsl
import kfp.v2.compiler as compiler

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import pathlib

from kfp.v2 import components
from kfp import components
from kfp.v2 import dsl
import kfp.v2.compiler as compiler

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import pathlib

from kfp.v2 import components
from kfp import components
from kfp.v2 import dsl
import kfp.v2.compiler as compiler

Expand Down
17 changes: 0 additions & 17 deletions sdk/python/kfp/v2/components/__init__.py

This file was deleted.

Loading

0 comments on commit ecb14f4

Please sign in to comment.