--load-versions rejects a dataset name that the catalog resolves through a catch-all pattern
Description
--load-versions is rejected for a dataset that the catalog does resolve, when the name is served by a user catch-all pattern rather than by an explicit entry or a named dataset pattern.
The validation in DataCatalog.from_config considers two of the three ways a name can resolve:
missing_keys = [
ds_name
for ds_name in load_versions
if not (
ds_name in config_resolver.config
or config_resolver.match_dataset_pattern(ds_name)
)
]Resolution itself uses three (catalog_config_resolver.py):
self.match_dataset_pattern(ds_name)
or self.match_user_catch_all_pattern(ds_name)
or self.match_runtime_pattern(ds_name)and so does membership, DataCatalog.__contains__:
... or self._config_resolver.match_dataset_pattern(dataset_name) is not None
or self._config_resolver.match_user_catch_all_pattern(dataset_name)So "cars" in catalog is True, catalog["cars"] returns the versioned dataset the catch-all describes, and load_versions={"cars": ...} still raises DatasetNotFoundError.
Context
I use a catch-all pattern in catalog.yml so that every dataset lands in the same place with the same type, which is a common way to keep the catalog short:
"{name}":
type: pandas.CSVDataset
filepath: data/01_raw/{name}.csv
versioned: trueEvery dataset in such a project is versioned, which is exactly the setup where --load-versions is useful, and it is the setup where it cannot be used at all. Replacing the catch-all with one explicit entry for the dataset makes the same command work.
Steps to Reproduce
- Put the catch-all above in
conf/base/catalog.yml. - Run
kedro run --load-versions=seed:2023-01-01T00.00.00.
Without a project:
from kedro.io import DataCatalog
config = {"{name}": {"type": "pandas.CSVDataset", "filepath": "data/{name}.csv", "versioned": True}}
cat = DataCatalog.from_config(config)
print("cars" in cat) # True
print(type(cat["cars"]).__name__) # CSVDataset
print(cat["cars"]._version is not None) # True
DataCatalog.from_config(config, load_versions={"cars": "2023-01-01T00.00.00"})
# DatasetNotFoundErrorExpected Result
The load version is accepted for any name the catalog can resolve, matching what __contains__ and the resolver already agree on.
Actual Result
DatasetNotFoundError: 'load_versions' keys [cars] are not found in the catalog.Your Environment
- Kedro version used: 1.6.0 (installed from source at
8d9abdf) - Python version used: 3.12.13
- Operating system and version: macOS 15
Possible fix
Add match_user_catch_all_pattern to the missing_keys check, so the validation uses the same notion of "in the catalog" as the resolver. Whether the runtime pattern should count too is a separate question: a MemoryDataset is not versioned, so rejecting that case still looks right to me. I have a fix and a regression test ready and I am happy to open a PR if you agree with the approach.
Source: kedro-org/kedro