Skip to content

Commit

Permalink
Update lazy dataset representation (#4448)
Browse files Browse the repository at this point in the history
* Updated lazy dataset representation

Signed-off-by: Elena Khaustova <[email protected]>

* Updated unit tests

Signed-off-by: Elena Khaustova <[email protected]>

* Updated tests to reach coverage

Signed-off-by: Elena Khaustova <[email protected]>

* Updated release notes

Signed-off-by: Elena Khaustova <[email protected]>

* Updated release notes

Signed-off-by: Elena Khaustova <[email protected]>

---------

Signed-off-by: Elena Khaustova <[email protected]>
  • Loading branch information
ElenaKhaustova authored Jan 29, 2025
1 parent 6d89ace commit 9f84349
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
8 changes: 6 additions & 2 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@
{
"path": "detect_secrets.filters.allowlist.is_line_allowlisted"
},
{
"path": "detect_secrets.filters.common.is_baseline_file",
"filename": ".secrets.baseline"
},
{
"path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies",
"min_level": 2
Expand Down Expand Up @@ -211,9 +215,9 @@
"filename": "tests/io/test_kedro_data_catalog.py",
"hashed_secret": "15dd2c9ccec914f1470b4dccb45789844e49cf70",
"is_verified": false,
"line_number": 499
"line_number": 501
}
]
},
"generated_at": "2025-01-27T18:47:13Z"
"generated_at": "2025-01-28T14:51:20Z"
}
2 changes: 2 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Major features and improvements
## Bug fixes and other changes
* Updated `_LazyDataset` representation when printing `KedroDataCatalog`.

## Breaking changes to the API
## Documentation changes

Expand Down
4 changes: 3 additions & 1 deletion kedro/io/kedro_data_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
Version,
_validate_versions,
generate_timestamp,
parse_dataset_definition,
)
from kedro.io.memory_dataset import MemoryDataset, _is_memory_dataset
from kedro.utils import _format_rich, _has_rich_handler
Expand All @@ -48,7 +49,8 @@ def __init__(
self.save_version = save_version

def __repr__(self) -> str:
return f"{self.config.get('type', 'UnknownType')}"
class_type, _ = parse_dataset_definition(self.config)
return f"{class_type.__module__}.{class_type.__qualname__}"

def materialize(self) -> AbstractDataset:
return AbstractDataset.from_config(
Expand Down
8 changes: 5 additions & 3 deletions tests/io/test_kedro_data_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,14 @@ def test_init_with_raw_data(self, dummy_dataframe, dataset):
assert isinstance(catalog["ds"], CSVDataset)
assert isinstance(catalog["df"], MemoryDataset)

def test_repr(self, data_catalog):
assert data_catalog.__repr__() == str(data_catalog)
def test_repr(self, data_catalog_from_config):
assert data_catalog_from_config.__repr__() == str(data_catalog_from_config)

def test_repr_no_type_found(self, data_catalog_from_config):
del data_catalog_from_config._lazy_datasets["boats"].config["type"]
assert data_catalog_from_config.__repr__() == str(data_catalog_from_config)
pattern = "'type' is missing from dataset catalog configuration"
with pytest.raises(DatasetError, match=re.escape(pattern)):
_ = str(data_catalog_from_config)

def test_missing_keys_from_load_versions(self, correct_config):
"""Test load versions include keys missing in the catalog"""
Expand Down

0 comments on commit 9f84349

Please sign in to comment.