Skip to content

Commit

Permalink
Merge branch 'main' into build/update-intersphinx-mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
astrojuanlu authored Aug 2, 2024
2 parents 71e02a5 + 94ae223 commit 4673c08
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 14 deletions.
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ authors:
- family-names: Brugman
given-names: Simon
title: Kedro
version: 0.19.6
date-released: 2024-05-23
version: 0.19.7
date-released: 2024-08-01
url: https://github.com/kedro-org/kedro
24 changes: 20 additions & 4 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
# Upcoming Release 0.19.7
# Upcoming Release 0.19.8

## Major features and improvements

## Bug fixes and other changes

## Breaking changes to the API

## Documentation changes

## Community contributions

# Release 0.19.7

## Major features and improvements
* Exposed `load` and `save` publicly for each dataset in the core `kedro` library, and enabled other datasets to do the same. If a dataset doesn't expose `load` or `save` publicly, Kedro will fall back to using `_load` or `_save`, respectively.
* Kedro commands are now lazily loaded to add performance gains when running Kedro commands.
* Implemented key completion support for accessing datasets in the `DataCatalog`.
* Implemented dataset pretty printing.
* Implemented `DataCatalog` pretty printing.
* Moved to an opt-out model for telemetry, enabling it by default without requiring prior consent.

## Bug fixes and other changes
* Updated error message for invalid catalog entries.
* Updated error message for catalog entries when the dataset class is not found with hints on how to resolve the issue.
* Fixed a bug in the `DataCatalog` `shallow_copy()` method to ensure it returns the type of the used catalog and doesn't cast it to `DataCatalog`.
* Implemented key completion support for accessing datasets in the `DataCatalog`.
* Made [kedro-telemetry](https://github.com/kedro-org/kedro-plugins/tree/main/kedro-telemetry) a core dependency.
* Implemented dataset pretty printing.
* Implemented `DataCatalog` pretty printing.
* Fixed a bug when `OmegaConfigLoader` is printed, there are few missing arguments.
* Fixed a bug when where iterating `OmegaConfigLoader`'s `keys` return empty dictionary.

Expand All @@ -25,6 +38,9 @@
* Extended documentation with an example of logging customisation at runtime

## Community contributions
Many thanks to the following Kedroids for contributing PRs to this release:
* [nickolasrm](https://github.com/nickolasrm)
* [yury-fedotov](https://github.com/yury-fedotov)

# Release 0.19.6

Expand Down
2 changes: 1 addition & 1 deletion docs/source/development/commands_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Returns output similar to the following, depending on the version of Kedro used
| |/ / _ \/ _` | '__/ _ \
| < __/ (_| | | | (_) |
|_|\_\___|\__,_|_| \___/
v0.19.6
v0.19.7
Kedro is a Python framework for
creating reproducible, maintainable
Expand Down
1 change: 1 addition & 0 deletions docs/source/robots.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
User-agent: *
Disallow: /
Allow: /en/stable/
Allow: /en/0.19.7*
Allow: /en/0.19.6*
Allow: /en/0.19.5*
Allow: /en/0.19.4*
Expand Down
2 changes: 1 addition & 1 deletion kedro/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import sys
import warnings

__version__ = "0.19.6"
__version__ = "0.19.7"


class KedroDeprecationWarning(DeprecationWarning):
Expand Down
23 changes: 22 additions & 1 deletion kedro/framework/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from __future__ import annotations

import importlib
import logging
import sys
import traceback
from collections import defaultdict
Expand Down Expand Up @@ -38,6 +39,9 @@
v{version}
"""

logger = logging.getLogger(__name__)
logger.addHandler(logging.StreamHandler(sys.stderr))


@click.group(context_settings=CONTEXT_SETTINGS, name="Kedro")
@click.version_option(version, "--version", "-V", help="Show version and exit")
Expand Down Expand Up @@ -154,6 +158,9 @@ def main(
self._cli_hook_manager.hook.before_command_run(
project_metadata=self._metadata, command_args=args
)

hook_called = False

try:
super().main(
args=args,
Expand All @@ -169,6 +176,8 @@ def main(
self._cli_hook_manager.hook.after_command_run(
project_metadata=self._metadata, command_args=args, exit_code=exc.code
)
hook_called = True

# When CLI is run outside of a project, project_groups are not registered
catch_exception = "click.exceptions.UsageError: No such command"
# click convert exception handles to error message
Expand Down Expand Up @@ -198,7 +207,19 @@ def main(
)
click.echo(message)
click.echo(hint)
sys.exit(exc.code)
sys.exit(exc.code)
except Exception as error:
logger.error(f"An error has occurred: {error}")
self._cli_hook_manager.hook.after_command_run(
project_metadata=self._metadata, command_args=args, exit_code=1
)
hook_called = True
sys.exit(1)
finally:
if not hook_called:
self._cli_hook_manager.hook.after_command_run(
project_metadata=self._metadata, command_args=args, exit_code=0
)

@property
def global_groups(self) -> Sequence[click.MultiCommand]:
Expand Down
4 changes: 2 additions & 2 deletions kedro/io/lambda_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ def _to_str(func: Any) -> str | None:

return descr

def load(self) -> Any:
def _load(self) -> Any:
if not self.__load:
raise DatasetError(
"Cannot load data set. No 'load' function "
"provided when LambdaDataset was created."
)
return self.__load()

def save(self, data: Any) -> None:
def _save(self, data: Any) -> None:
if not self.__save:
raise DatasetError(
"Cannot save to data set. No 'save' function "
Expand Down
32 changes: 32 additions & 0 deletions tests/framework/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from itertools import cycle
from os import rename
from pathlib import Path
from unittest.mock import MagicMock, patch

import click
from click.testing import CliRunner
Expand Down Expand Up @@ -432,6 +433,37 @@ def test_kedro_cli_with_project(self, mocker, fake_metadata):
assert "Global commands from Kedro" in result.output
assert "Project specific commands from Kedro" in result.output

@patch("sys.exit")
def test_main_hook_exception_handling(self, fake_metadata):
kedro_cli = KedroCLI(fake_metadata.project_path)
kedro_cli._cli_hook_manager.hook.after_command_run = MagicMock()

with patch.object(
click.CommandCollection, "main", side_effect=Exception("Test Exception")
):
result = CliRunner().invoke(kedro_cli, [])

kedro_cli._cli_hook_manager.hook.after_command_run.assert_called_once_with(
project_metadata=kedro_cli._metadata, command_args=[], exit_code=1
)

assert "An error has occurred: Test Exception" in result.output

@patch("sys.exit")
def test_main_hook_finally_block(self, fake_metadata):
kedro_cli = KedroCLI(fake_metadata.project_path)
kedro_cli._cli_hook_manager.hook.after_command_run = MagicMock()

# No exception is raised, so it should go to the finally block and call the hook
with patch.object(click.CommandCollection, "main"):
result = CliRunner().invoke(kedro_cli, [])

kedro_cli._cli_hook_manager.hook.after_command_run.assert_called_once_with(
project_metadata=kedro_cli._metadata, command_args=[], exit_code=0
)

assert "An error has occurred:" not in result.output


@mark.usefixtures("chdir_to_dummy_project")
class TestRunCommand:
Expand Down
14 changes: 11 additions & 3 deletions tests/framework/cli/test_starters.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,9 +825,11 @@ def test_alias(self, fake_kedro_cli, mock_determine_repo_dir, mock_cookiecutter)
)
kwargs = {
"template": "git+https://github.com/kedro-org/kedro-starters.git",
"checkout": version,
"directory": "spaceflights-pandas",
}
starters_version = mock_determine_repo_dir.call_args[1].pop("checkout", None)

assert starters_version in [version, "main"]
assert kwargs.items() <= mock_determine_repo_dir.call_args[1].items()
assert kwargs.items() <= mock_cookiecutter.call_args[1].items()

Expand All @@ -853,11 +855,14 @@ def test_git_repo(self, fake_kedro_cli, mock_determine_repo_dir, mock_cookiecutt
["new", "--starter", "git+https://github.com/fake/fake.git"],
input=_make_cli_prompt_input(),
)

kwargs = {
"template": "git+https://github.com/fake/fake.git",
"checkout": version,
"directory": None,
}
starters_version = mock_determine_repo_dir.call_args[1].pop("checkout", None)

assert starters_version in [version, "main"]
assert kwargs.items() <= mock_determine_repo_dir.call_args[1].items()
del kwargs["directory"]
assert kwargs.items() <= mock_cookiecutter.call_args[1].items()
Expand Down Expand Up @@ -899,11 +904,14 @@ def test_git_repo_custom_directory(
],
input=_make_cli_prompt_input(),
)

kwargs = {
"template": "git+https://github.com/fake/fake.git",
"checkout": version,
"directory": "my_directory",
}
starters_version = mock_determine_repo_dir.call_args[1].pop("checkout", None)

assert starters_version in [version, "main"]
assert kwargs.items() <= mock_determine_repo_dir.call_args[1].items()
assert kwargs.items() <= mock_cookiecutter.call_args[1].items()

Expand Down

0 comments on commit 4673c08

Please sign in to comment.