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

Add deprecation warning to get_pkg_version #3947

Merged
merged 3 commits into from
Jun 12, 2024
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
3 changes: 3 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

## Breaking changes to the API

## Upcoming deprecations for Kedro 0.20.0
* The utility method `get_pkg_version()` is deprecated and will be removed in Kedro 0.20.0.

## Documentation changes

## Community contributions
Expand Down
7 changes: 7 additions & 0 deletions kedro/framework/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import textwrap
import traceback
import typing
import warnings
from collections import defaultdict
from importlib import import_module
from itertools import chain
Expand All @@ -21,6 +22,8 @@
import importlib_metadata
from omegaconf import OmegaConf

from kedro import KedroDeprecationWarning

CONTEXT_SETTINGS = {"help_option_names": ["-h", "--help"]}
MAX_SUGGESTIONS = 3
CUTOFF = 0.5
Expand Down Expand Up @@ -218,6 +221,10 @@ def get_pkg_version(reqs_path: (str | Path), package_name: str) -> str:
KedroCliError: If the file specified in ``reqs_path`` does not exist
or ``package_name`` was not found in that file.
"""
warnings.warn(
"`get_pkg_version()` has been deprecated and will be removed in Kedro 0.20.0",
KedroDeprecationWarning,
)
reqs_path = Path(reqs_path).absolute()
if not reqs_path.is_file():
raise KedroCliError(f"Given path '{reqs_path}' is not a regular file.")
Expand Down
10 changes: 9 additions & 1 deletion tests/framework/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
import click
from click.testing import CliRunner
from omegaconf import OmegaConf
from pytest import fixture, mark, raises
from pytest import fixture, mark, raises, warns

from kedro import KedroDeprecationWarning
from kedro import __version__ as version
from kedro.framework.cli import load_entry_points
from kedro.framework.cli.catalog import catalog_cli
Expand Down Expand Up @@ -245,6 +246,13 @@ def test_get_pkg_version(self, requirements_file):
non_existent_file = str(requirements_file) + "-nonexistent"
get_pkg_version(non_existent_file, "pandas")

def test_get_pkg_version_deprecated(self, requirements_file):
with warns(
KedroDeprecationWarning,
match=r"\`get_pkg_version\(\)\` has been deprecated",
):
_ = get_pkg_version(requirements_file, "pandas")

def test_clean_pycache(self, tmp_path, mocker):
"""Test `clean_pycache` utility function"""
source = Path(tmp_path)
Expand Down