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 warning for catch-all patterns [dataset factories] #2774

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
8 changes: 8 additions & 0 deletions kedro/io/data_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,14 @@ def _get_dataset(
self._load_versions.get(data_set_name),
self._save_version,
)
if self._specificity(matched_pattern) == 0:
self._logger.warning(
"Config from the dataset factory pattern '%s' in the catalog will be used to "
"override the default MemoryDataset creation for the dataset '%s'",
matched_pattern,
data_set_name,
)

self.add(data_set_name, data_set)
if data_set_name not in self._data_sets:
error_msg = f"Dataset '{data_set_name}' not found in the catalog"
Expand Down
9 changes: 8 additions & 1 deletion tests/io/test_data_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,11 +818,18 @@ def test_sorting_order_patterns(self, config_with_dataset_factories_only_pattern
]
assert list(catalog._dataset_patterns.keys()) == sorted_keys_expected

def test_default_dataset(self, config_with_dataset_factories_with_default):
def test_default_dataset(self, config_with_dataset_factories_with_default, caplog):
"""Check that default dataset is used when no other pattern matches"""
catalog = DataCatalog.from_config(**config_with_dataset_factories_with_default)
assert "jet@planes" not in catalog._data_sets
jet_dataset = catalog._get_dataset("jet@planes")
log_record = caplog.records[0]
assert log_record.levelname == "WARNING"
assert (
"Config from the dataset factory pattern '{default_dataset}' "
"in the catalog will be used to override the default "
"MemoryDataset creation for the dataset 'jet@planes'" in log_record.message
)
assert isinstance(jet_dataset, CSVDataSet)

def test_unmatched_key_error_when_parsing_config(
Expand Down