Skip to content

Commit

Permalink
add python EOL notice
Browse files Browse the repository at this point in the history
  • Loading branch information
connor-mccarthy committed Oct 23, 2023
1 parent 0cb2217 commit 902d738
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 0 deletions.
1 change: 1 addition & 0 deletions sdk/RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Support collecting outputs from conditional branches using `dsl.OneOf` [\#10067](https://github.com/kubeflow/pipelines/pull/10067)

## Deprecations
* Add notice of Python 3.7 support removal on April 23, 2024 [\#10139](https://github.com/kubeflow/pipelines/pull/10139)

## Bug fixes and other changes
* Fix type on `dsl.ParallelFor` sub-DAG output when a `dsl.Collected` is used. Non-functional fix. [\#10069](https://github.com/kubeflow/pipelines/pull/10069)
Expand Down
11 changes: 11 additions & 0 deletions sdk/python/kfp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@

__version__ = '2.3.0'

import sys
import warnings

if sys.version_info < (3, 8):
warnings.warn(
('Python 3.7 has reached end-of-life. KFP will drop support for Python 3.7 on April 23, 2024. To use new versions of the KFP SDK after that date, you will need to upgrade to Python >= 3.8. See https://devguide.python.org/versions/ for more details.'
),
FutureWarning,
stacklevel=2,
)

TYPE_CHECK = True

import os
Expand Down
6 changes: 6 additions & 0 deletions sdk/python/kfp/dsl/component_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,12 @@ def create_component_from_func(
args = []
if base_image is None:
base_image = _DEFAULT_BASE_IMAGE
warnings.warn(
("Python 3.7 has reached end-of-life. The default base_image used by the @dsl.component decorator will switch from 'python:3.7' to 'python:3.8' on April 23, 2024. To ensure your existing components work with versions of the KFP SDK released after that date, you should provide an explicit base_image argument and ensure your code works as intended on Python 3.8."
),
FutureWarning,
stacklevel=2,
)

component_image = base_image

Expand Down
14 changes: 14 additions & 0 deletions sdk/python/kfp/dsl/component_factory_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,5 +287,19 @@ def comp(output_list: Output[List[Artifact]]):
return dsl.ContainerSpec(image='alpine')


class TestPythonEOLWarning(unittest.TestCase):

def test_default_base_image(self):

with self.assertWarnsRegex(
FutureWarning,
r"Python 3\.7 has reached end-of-life\. The default base_image used by the @dsl\.component decorator will switch from 'python:3\.7' to 'python:3\.8' on April 23, 2024\. To ensure your existing components work with versions of the KFP SDK released after that date, you should provide an explicit base_image argument and ensure your component works as intended on Python 3\.8\."
):

@dsl.component
def foo():
pass


if __name__ == '__main__':
unittest.main()
34 changes: 34 additions & 0 deletions sdk/python/kfp/init_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2023 The Kubeflow Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# 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.

import sys
import unittest


class TestPythonEOLWarning(unittest.TestCase):

def test(self):
# remove module if it is already loaded
if 'kfp' in sys.modules:
del sys.modules['kfp']

with self.assertWarnsRegex(
FutureWarning,
r'Python 3\.7 has reached end-of-life\. KFP will drop support for Python 3\.7 on April 23, 2024\. To use new versions of the KFP SDK after that date, you will need to upgrade to Python >= 3\.8\. See https:\/\/devguide\.python\.org\/versions\/ for more details\.'
):
import kfp # noqa


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

0 comments on commit 902d738

Please sign in to comment.