Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(sdk): Warn on container component without command. Fixes #4800 #6335

Merged
merged 2 commits into from
Aug 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions sdk/python/kfp/components/_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
from collections import OrderedDict
import pathlib
from typing import Any, Callable, List, Mapping, NamedTuple, Sequence, Union
import warnings

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 @@ -163,6 +165,17 @@ def _load_component_spec_from_component_text(text) -> ComponentSpec:
component_dict = load_yaml(text)
component_spec = ComponentSpec.from_dict(component_dict)

if isinstance(component_spec.implementation, ContainerImplementation) and (
component_spec.implementation.container.command is None):
warnings.warn(
'Container component must specify command to be compatible with KFP '
'v2 compatible mode and emissary executor, which will be the default'
' executor for KFP v2.'
'https://www.kubeflow.org/docs/components/pipelines/installation/choose-executor/',
category=FutureWarning,
)


# Calculating hash digest for the component
import hashlib
data = text if isinstance(text, bytes) else text.encode('utf-8')
Expand Down
15 changes: 15 additions & 0 deletions sdk/python/kfp/components_tests/test_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,21 @@ def test_fail_type_compatibility_check_for_types_with_different_schemas(self):
with self.assertRaises(TypeError):
b_task = task_factory_b(in1=a_task.outputs['out1'])

def test_container_component_without_command_should_warn(self):
component_a = '''\
name: component without command
inputs:
- {name: in1, type: String}
implementation:
container:
image: busybox
'''

with self.assertWarnsRegex(
FutureWarning,
'Container component must specify command to be compatible with '
'KFP v2 compatible mode and emissary executor'):
task_factory_a = comp.load_component_from_text(component_a)

if __name__ == '__main__':
unittest.main()