Skip to content

Commit

Permalink
Deprecate LambdaDataset (#4321)
Browse files Browse the repository at this point in the history
* deprecation draft

* update test name

* add deprecation note to docs
  • Loading branch information
ravi-kumar-pilla authored Nov 12, 2024
1 parent 6e3e4d1 commit 075d59b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ Many thanks to the following Kedroids for contributing PRs to this release:

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

## Documentation changes
* Improved documentation for configuring dataset parameters in the data catalog
Expand Down
4 changes: 4 additions & 0 deletions docs/source/nodes_and_pipelines/run_a_pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ Out[11]: {'v': 0.666666666666667}

We can also use IO to save outputs to a file. In this example, we define a custom `LambdaDataset` that would serialise the output to a file locally:

```{warning}
`LambdaDataset` has been deprecated and will be removed in Kedro `0.20.0`.
```

<details>
<summary><b>Click to expand</b></summary>

Expand Down
8 changes: 8 additions & 0 deletions kedro/io/lambda_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

from __future__ import annotations

import warnings
from typing import Any, Callable

from kedro import KedroDeprecationWarning
from kedro.io.core import AbstractDataset, DatasetError


Expand Down Expand Up @@ -100,6 +102,12 @@ def __init__(
DatasetError: If a method is specified, but is not a Callable.
"""

warnings.warn(
"`LambdaDataset` has been deprecated and will be removed in Kedro 0.20.0.",
KedroDeprecationWarning,
)

for name, value in [
("load", load),
("save", save),
Expand Down
9 changes: 9 additions & 0 deletions tests/io/test_lambda_dataset.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest

from kedro import KedroDeprecationWarning
from kedro.io import DatasetError, LambdaDataset


Expand Down Expand Up @@ -81,6 +82,14 @@ def test_ephemeral_attribute(mocked_dataset):
assert mocked_dataset._EPHEMERAL is False


def test_lambda_dataset_deprecation():
with pytest.warns(
KedroDeprecationWarning,
match=r"\`LambdaDataset\` has been deprecated",
):
_ = LambdaDataset(None, None)


class TestLambdaDatasetLoad:
def test_load_invocation(self, mocker):
"""Test the basic `load` method invocation"""
Expand Down

0 comments on commit 075d59b

Please sign in to comment.