From dbc4c2324bef3f3e1780d61408cfb622c7d5c003 Mon Sep 17 00:00:00 2001 From: aniketpatil Date: Thu, 21 Aug 2025 22:21:40 +0530 Subject: [PATCH 1/4] chore: remove _KFP_RUNTIME check from kfp/__init__.py Signed-off-by: aniketpatil --- sdk/python/kfp/__init__.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sdk/python/kfp/__init__.py b/sdk/python/kfp/__init__.py index 72311fc78f9..33475f984a5 100644 --- a/sdk/python/kfp/__init__.py +++ b/sdk/python/kfp/__init__.py @@ -26,7 +26,10 @@ if sys.version_info < (3, 9): warnings.warn( - ('KFP will drop support for Python 3.9 on Oct 1, 2025. To use new versions of the KFP SDK after that date, you will need to upgrade to Python >= 3.10. See https://devguide.python.org/versions/ for more details.' + ( + 'KFP will drop support for Python 3.9 on Oct 1, 2025. ' + 'To use new versions of the KFP SDK after that date, you will need to upgrade to Python >= 3.10. ' + 'See https://devguide.python.org/versions/ for more details.' ), FutureWarning, stacklevel=2, @@ -34,12 +37,9 @@ TYPE_CHECK = True -import os - # compile-time only dependencies -if os.environ.get('_KFP_RUNTIME', 'false') != 'true': - # make `from kfp import components` and `from kfp import dsl` valid; - # related to namespace packaging issue - from kfp import components # noqa: keep unused import - from kfp import dsl # noqa: keep unused import - from kfp.client import Client # noqa: keep unused import +# make `from kfp import components` and `from kfp import dsl` valid; +# related to namespace packaging issue +from kfp import components # noqa: keep unused import +from kfp import dsl # noqa: keep unused import +from kfp.client import Client # noqa: keep unused import From 6f3fa766e169b827ffa0bae802d10b29362520f2 Mon Sep 17 00:00:00 2001 From: aniketpatil Date: Fri, 22 Aug 2025 17:41:39 +0530 Subject: [PATCH 2/4] Remove KFP dependency executor and related fixes Signed-off-by: aniketpatil --- sdk/python/kfp/__init__.py | 18 ++++++++---------- sdk/python/kfp/cli/cli.py | 9 +++++++-- sdk/python/kfp/version.py | 3 ++- ...htweight_python_functions_with_outputs.yaml | 8 ++++---- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/sdk/python/kfp/__init__.py b/sdk/python/kfp/__init__.py index 33475f984a5..0b843a0d73a 100644 --- a/sdk/python/kfp/__init__.py +++ b/sdk/python/kfp/__init__.py @@ -14,12 +14,13 @@ # `kfp` is a namespace package. # https://packaging.python.org/guides/packaging-namespace-packages/#pkgutil-style-namespace-packages + __path__ = __import__('pkgutil').extend_path(__path__, __name__) try: from .version import __version__ except ImportError: - __version__ = 'dev' + __version__ = "0.0.0+dev" import sys import warnings @@ -28,18 +29,15 @@ warnings.warn( ( 'KFP will drop support for Python 3.9 on Oct 1, 2025. ' - 'To use new versions of the KFP SDK after that date, you will need to upgrade to Python >= 3.10. ' - 'See https://devguide.python.org/versions/ for more details.' + 'To use new versions of the KFP SDK after that date, you will need to upgrade to Python >= 3.10.' ), FutureWarning, stacklevel=2, ) -TYPE_CHECK = True - # compile-time only dependencies -# make `from kfp import components` and `from kfp import dsl` valid; -# related to namespace packaging issue -from kfp import components # noqa: keep unused import -from kfp import dsl # noqa: keep unused import -from kfp.client import Client # noqa: keep unused import +from kfp import components # noqa +from kfp import dsl # noqa +from kfp.client import Client # noqa +from . import version +from .version import __version__ # make top-level __version__ available diff --git a/sdk/python/kfp/cli/cli.py b/sdk/python/kfp/cli/cli.py index dc16f40361f..56d6855ac69 100644 --- a/sdk/python/kfp/cli/cli.py +++ b/sdk/python/kfp/cli/cli.py @@ -27,7 +27,9 @@ from kfp.cli import run from kfp.cli.output import OutputFormat from kfp.cli.utils import aliased_plurals_group -from kfp.cli.utils import parsing +from kfp.cli.utils import parsing +from kfp import version as _version + COMMANDS = { 'client': { @@ -95,7 +97,10 @@ def _install_completion(shell: str) -> None: show_default=True, help='The formatting style for command output.') @click.pass_context -@click.version_option(version=kfp.__version__, message='%(prog)s %(version)s') +@click.version_option(version=_version.__version__, message='%(prog)s %(version)s') + + + def cli(ctx: click.Context, endpoint: str, iap_client_id: str, namespace: str, other_client_id: str, other_client_secret: str, existing_token: str, output: OutputFormat, show_completion: str, install_completion: str): diff --git a/sdk/python/kfp/version.py b/sdk/python/kfp/version.py index 9bce5fa7ef8..5c346f19bc3 100644 --- a/sdk/python/kfp/version.py +++ b/sdk/python/kfp/version.py @@ -1 +1,2 @@ -__version__ = '2.14.2' +__version__ = "2.14.2" + diff --git a/sdk/python/test_data/pipelines/lightweight_python_functions_with_outputs.yaml b/sdk/python/test_data/pipelines/lightweight_python_functions_with_outputs.yaml index 8ea9edeba37..06ffe253e88 100644 --- a/sdk/python/test_data/pipelines/lightweight_python_functions_with_outputs.yaml +++ b/sdk/python/test_data/pipelines/lightweight_python_functions_with_outputs.yaml @@ -89,7 +89,7 @@ deploymentSpec: printf "%s" "$0" > "$program_path/ephemeral_component.py" - _KFP_RUNTIME=true python3 -m kfp.dsl.executor_main --component_module_path "$program_path/ephemeral_component.py" "$@" + python3 -m kfp.dsl.executor_main --component_module_path "$program_path/ephemeral_component.py" "$@" ' - "\nimport kfp\nfrom kfp import dsl\nfrom kfp.dsl import *\nfrom typing import\ @@ -118,7 +118,7 @@ deploymentSpec: printf "%s" "$0" > "$program_path/ephemeral_component.py" - _KFP_RUNTIME=true python3 -m kfp.dsl.executor_main --component_module_path "$program_path/ephemeral_component.py" "$@" + python3 -m kfp.dsl.executor_main --component_module_path "$program_path/ephemeral_component.py" "$@" ' - "\nimport kfp\nfrom kfp import dsl\nfrom kfp.dsl import *\nfrom typing import\ @@ -147,7 +147,7 @@ deploymentSpec: printf "%s" "$0" > "$program_path/ephemeral_component.py" - _KFP_RUNTIME=true python3 -m kfp.dsl.executor_main --component_module_path "$program_path/ephemeral_component.py" "$@" + python3 -m kfp.dsl.executor_main --component_module_path "$program_path/ephemeral_component.py" "$@" ' - "\nimport kfp\nfrom kfp import dsl\nfrom kfp.dsl import *\nfrom typing import\ @@ -176,7 +176,7 @@ deploymentSpec: printf "%s" "$0" > "$program_path/ephemeral_component.py" - _KFP_RUNTIME=true python3 -m kfp.dsl.executor_main --component_module_path "$program_path/ephemeral_component.py" "$@" + python3 -m kfp.dsl.executor_main --component_module_path "$program_path/ephemeral_component.py" "$@" ' - "\nimport kfp\nfrom kfp import dsl\nfrom kfp.dsl import *\nfrom typing import\ From 78220c73d60fc90714fa185cee74797bacad502f Mon Sep 17 00:00:00 2001 From: Aniket Patil Date: Fri, 12 Sep 2025 14:38:03 +0530 Subject: [PATCH 3/4] style: fix imports with isort Signed-off-by: Aniket Patil --- sdk/python/kfp/client/__init__.py | 3 +-- sdk/python/kfp/compiler/pipeline_spec_builder.py | 3 +-- sdk/python/kfp/dsl/component_factory.py | 3 +-- sdk/python/kfp/dsl/structures.py | 3 +-- sdk/python/kfp/dsl/v1_modelbase.py | 4 +--- sdk/python/test_kfp_version.py | 3 +++ 6 files changed, 8 insertions(+), 11 deletions(-) create mode 100644 sdk/python/test_kfp_version.py diff --git a/sdk/python/kfp/client/__init__.py b/sdk/python/kfp/client/__init__.py index fde5f6cacb7..f6127911a73 100644 --- a/sdk/python/kfp/client/__init__.py +++ b/sdk/python/kfp/client/__init__.py @@ -18,8 +18,7 @@ ] from kfp.client.client import Client -from kfp.client.set_volume_credentials import \ - ServiceAccountTokenVolumeCredentials +from kfp.client.set_volume_credentials import ServiceAccountTokenVolumeCredentials from kfp.client.token_credentials_base import TokenCredentialsBase KF_PIPELINES_SA_TOKEN_ENV = 'KF_PIPELINES_SA_TOKEN_PATH' diff --git a/sdk/python/kfp/compiler/pipeline_spec_builder.py b/sdk/python/kfp/compiler/pipeline_spec_builder.py index b01a7fc135f..c2b0cd3b53f 100644 --- a/sdk/python/kfp/compiler/pipeline_spec_builder.py +++ b/sdk/python/kfp/compiler/pipeline_spec_builder.py @@ -16,8 +16,7 @@ import copy import json import typing -from typing import (Any, DefaultDict, Dict, List, Mapping, Optional, Tuple, - Union) +from typing import Any, DefaultDict, Dict, List, Mapping, Optional, Tuple, Union import warnings from google.protobuf import json_format diff --git a/sdk/python/kfp/dsl/component_factory.py b/sdk/python/kfp/dsl/component_factory.py index ba469d20f11..da2de0617d7 100644 --- a/sdk/python/kfp/dsl/component_factory.py +++ b/sdk/python/kfp/dsl/component_factory.py @@ -17,8 +17,7 @@ import pathlib import re import textwrap -from typing import (Any, Callable, Dict, List, Mapping, Optional, Tuple, Type, - Union) +from typing import Any, Callable, Dict, List, Mapping, Optional, Tuple, Type, Union import warnings import docstring_parser diff --git a/sdk/python/kfp/dsl/structures.py b/sdk/python/kfp/dsl/structures.py index 874d40448fe..8e1c6db8126 100644 --- a/sdk/python/kfp/dsl/structures.py +++ b/sdk/python/kfp/dsl/structures.py @@ -27,8 +27,7 @@ from kfp.dsl import utils from kfp.dsl import v1_structures from kfp.dsl.component_task_config import TaskConfigPassthrough -from kfp.dsl.container_component_artifact_channel import \ - ContainerComponentArtifactChannel +from kfp.dsl.container_component_artifact_channel import ContainerComponentArtifactChannel from kfp.dsl.task_config import TaskConfig from kfp.dsl.types import artifact_types from kfp.dsl.types import type_annotations diff --git a/sdk/python/kfp/dsl/v1_modelbase.py b/sdk/python/kfp/dsl/v1_modelbase.py index c1facf6c8e2..21323b31fec 100644 --- a/sdk/python/kfp/dsl/v1_modelbase.py +++ b/sdk/python/kfp/dsl/v1_modelbase.py @@ -15,9 +15,7 @@ from collections import abc from collections import OrderedDict import inspect -from typing import (Any, cast, Dict, get_type_hints, List, Mapping, - MutableMapping, MutableSequence, Sequence, Type, TypeVar, - Union) +from typing import Any, cast, Dict, get_type_hints, List, Mapping, MutableMapping, MutableSequence, Sequence, Type, TypeVar, Union T = TypeVar('T') diff --git a/sdk/python/test_kfp_version.py b/sdk/python/test_kfp_version.py new file mode 100644 index 00000000000..bf4f1b6fa1e --- /dev/null +++ b/sdk/python/test_kfp_version.py @@ -0,0 +1,3 @@ +import kfp + +print("KFP version:", kfp.__version__) From b20267716f488e5999ff8f1a4a1ffc53381aaa3d Mon Sep 17 00:00:00 2001 From: Aniket Patil Date: Wed, 17 Sep 2025 10:57:14 +0530 Subject: [PATCH 4/4] style: clean imports, remove unused imports, linter-safe Signed-off-by: Aniket Patil --- sdk/python/kfp/cli/cli.py | 5 +- .../kfp/compiler/pipeline_spec_builder.py | 11 ++++- sdk/python/kfp/dsl/component_factory.py | 48 +++++++++++++------ sdk/python/kfp/dsl/v1_modelbase.py | 5 +- sdk/python/test_kfp_version.py | 3 -- 5 files changed, 49 insertions(+), 23 deletions(-) delete mode 100644 sdk/python/test_kfp_version.py diff --git a/sdk/python/kfp/cli/cli.py b/sdk/python/kfp/cli/cli.py index 56d6855ac69..a2c3cf6fe3c 100644 --- a/sdk/python/kfp/cli/cli.py +++ b/sdk/python/kfp/cli/cli.py @@ -95,9 +95,10 @@ def _install_completion(shell: str) -> None: type=click.Choice(list(map(lambda x: x.name, OutputFormat))), default=OutputFormat.table.name, show_default=True, - help='The formatting style for command output.') + help='The formatting style for command output.' +) @click.pass_context -@click.version_option(version=_version.__version__, message='%(prog)s %(version)s') +@click.version_option(version=kfp.__version__, message='%(prog)s %(version)s') diff --git a/sdk/python/kfp/compiler/pipeline_spec_builder.py b/sdk/python/kfp/compiler/pipeline_spec_builder.py index c2b0cd3b53f..497b2390858 100644 --- a/sdk/python/kfp/compiler/pipeline_spec_builder.py +++ b/sdk/python/kfp/compiler/pipeline_spec_builder.py @@ -16,7 +16,16 @@ import copy import json import typing -from typing import Any, DefaultDict, Dict, List, Mapping, Optional, Tuple, Union +from typing import ( + Any, + DefaultDict, + Dict, + List, + Mapping, + Optional, + Tuple, + Union, +) import warnings from google.protobuf import json_format diff --git a/sdk/python/kfp/dsl/component_factory.py b/sdk/python/kfp/dsl/component_factory.py index da2de0617d7..aa29c9e7e1f 100644 --- a/sdk/python/kfp/dsl/component_factory.py +++ b/sdk/python/kfp/dsl/component_factory.py @@ -10,33 +10,51 @@ # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and -# limitations under the License. +# limitations under the License. + import dataclasses import inspect import itertools import pathlib import re import textwrap -from typing import Any, Callable, Dict, List, Mapping, Optional, Tuple, Type, Union import warnings +from typing import ( + Any, + Callable, + Dict, + List, + Mapping, + Optional, + Tuple, + Type, + Union, +) import docstring_parser -import kfp from kfp import dsl -from kfp.dsl import container_component_artifact_channel -from kfp.dsl import container_component_class -from kfp.dsl import graph_component -from kfp.dsl import pipeline_config -from kfp.dsl import placeholders -from kfp.dsl import python_component -from kfp.dsl import structures -from kfp.dsl import task_final_status +from kfp.dsl import ( + container_component_artifact_channel, + container_component_class, + graph_component, + pipeline_config, + placeholders, + python_component, + structures, + task_final_status, +) + from kfp.dsl.component_task_config import TaskConfigPassthrough +from kfp.dsl.container_component_artifact_channel import ( + ContainerComponentArtifactChannel, +) from kfp.dsl.task_config import TaskConfig -from kfp.dsl.types import artifact_types -from kfp.dsl.types import custom_artifact_types -from kfp.dsl.types import type_annotations -from kfp.dsl.types import type_utils +from kfp.dsl.types import ( + artifact_types, + custom_artifact_types, + type_annotations, + type_utils, +) _DEFAULT_BASE_IMAGE = 'python:3.9' SINGLE_OUTPUT_NAME = 'Output' diff --git a/sdk/python/kfp/dsl/v1_modelbase.py b/sdk/python/kfp/dsl/v1_modelbase.py index 21323b31fec..fce822a673e 100644 --- a/sdk/python/kfp/dsl/v1_modelbase.py +++ b/sdk/python/kfp/dsl/v1_modelbase.py @@ -15,11 +15,12 @@ from collections import abc from collections import OrderedDict import inspect -from typing import Any, cast, Dict, get_type_hints, List, Mapping, MutableMapping, MutableSequence, Sequence, Type, TypeVar, Union +from typing import (Any, cast, Dict, get_type_hints, List, Mapping, + MutableMapping, MutableSequence, Sequence, Type, TypeVar, + Union) T = TypeVar('T') - def verify_object_against_type(x: Any, typ: Type[T]) -> T: """Verifies that the object is compatible to the specified type (types from the typing package can be used).""" diff --git a/sdk/python/test_kfp_version.py b/sdk/python/test_kfp_version.py deleted file mode 100644 index bf4f1b6fa1e..00000000000 --- a/sdk/python/test_kfp_version.py +++ /dev/null @@ -1,3 +0,0 @@ -import kfp - -print("KFP version:", kfp.__version__)