Skip to content

Commit

Permalink
fix: implement _exists for SharedMemoryDataset (#4121)
Browse files Browse the repository at this point in the history
* fix: implement `_exists` for `SharedMemoryDataset`

Signed-off-by: Felix Scherz <felixwscherz@gmail.com>

* docs: updated RELEASE.md

Signed-off-by: Felix Scherz <felixwscherz@gmail.com>

* fix: ignore mypy warning on exists return type

Signed-off-by: Felix Scherz <felixwscherz@gmail.com>

---------

Signed-off-by: Felix Scherz <felixwscherz@gmail.com>
Signed-off-by: Ankita Katiyar <110245118+ankatiyar@users.noreply.github.com>
Co-authored-by: Ankita Katiyar <110245118+ankatiyar@users.noreply.github.com>
  • Loading branch information
felixscherz and ankatiyar committed Sep 24, 2024
1 parent 53280bd commit 7537eae
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* Enhanced `OmegaConfigLoader` configuration validation to detect duplicate keys at all parameter levels, ensuring comprehensive nested key checking.
## Bug fixes and other changes
* Fixed bug where using dataset factories breaks with `ThreadRunner`.
* Fixed a bug where `SharedMemoryDataset.exists` would not call the underlying `MemoryDataset`.
* Fixed template projects example tests.
* Made credentials loading consistent between `KedroContext._get_catalog()` and `resolve_patterns` so that both us
e `_get_config_credentials()`
Expand All @@ -30,6 +31,7 @@ e `_get_config_credentials()`
* [ethanknights](https://github.com/ethanknights)
* [Manezki](https://github.com/Manezki)
* [MigQ2](https://github.com/MigQ2)
* [Felix Scherz](https://github.com/felixscherz)

# Release 0.19.8

Expand Down
5 changes: 5 additions & 0 deletions kedro/io/shared_memory_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,8 @@ def save(self, data: Any) -> None:
def _describe(self) -> dict[str, Any]:
"""SharedMemoryDataset doesn't have any constructor argument to return."""
return {}

def _exists(self) -> bool:
if not self.shared_memory_dataset:
return False
return self.shared_memory_dataset.exists() # type: ignore[no-any-return]
6 changes: 6 additions & 0 deletions tests/io/test_shared_memory_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,9 @@ def test_saving_none(self, shared_memory_dataset):
def test_str_representation(self, shared_memory_dataset):
"""Test string representation of the dataset"""
assert "MemoryDataset" in str(shared_memory_dataset)

def test_exists(self, shared_memory_dataset, input_data):
"""Check that exists returns the expected values"""
assert not shared_memory_dataset.exists()
shared_memory_dataset.save(input_data)
assert shared_memory_dataset.exists()

0 comments on commit 7537eae

Please sign in to comment.