﻿# Kedro CachedDataset: why replacing the underlying file does not refresh a warm cache

Understand CachedDataset load, save and release behavior when external jobs replace model inputs, and distinguish an in-memory cache from dataset version selection.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-kedro-cached-dataset-external-file-invalidation/
Language: en

## A corrected file with an unchanged result

An analyst corrects a validation table while a long-lived notebook retains its Kedro catalog. The next evaluation still reports the earlier labels. Checking the storage path shows the new file, which seems to contradict the output. The missing piece is a wrapper that can satisfy a load without consulting that file again.

First identify the catalog instance used by the evaluation. Reconstructing a catalog and reusing an existing object are different experiments, even when both configurations point to the same path. Record that distinction before blaming parsing or a model prediction cache.

## Follow the load path

The [CachedDataset implementation](https://docs.kedro.org/en/stable/api/io/kedro.io.CachedDataset/) checks its in-memory cache before loading the wrapped dataset. A cached value therefore represents a prior observation of storage, not a subscription to subsequent modifications. The wrapper is useful precisely because repeated access can avoid the underlying read.

In this scenario the external correction bypasses the wrapper's save method. It cannot be assumed to update the memory copy. Treat file replacement and catalog cache refresh as separate operations in the notebook procedure.

## Release establishes a different access point

The wrapper's release operation clears its cache and releases the underlying dataset. A later load can then consult storage again. This does not mean every pipeline automatically preserves a cache for its entire duration: runner-managed lifetimes also matter. Describe the lifetime that the actual application uses.

The [MemoryDataset API](https://docs.kedro.org/en/stable/api/io/kedro.io.MemoryDataset/) also documents copy modes. Refreshing freshness and preventing mutable aliasing are separate concerns; a fresh reference can still be changed accidentally by a consumer. Compare that risk with [explicit table contracts](/journal/data-guide-frictionless-table-schema/).

## Keep versions and cache ownership separate

The [catalog configuration guide](https://docs.kedro.org/en/stable/catalog-data/how_to_configure_the_data_catalog/) explains persistent dataset versions. Choosing a version answers which stored artifact should be read. The wrapper's memory cache answers whether the stored artifact is read on this access at all.

For a reviewed model evaluation, use an explicit input identity and a clean catalog lifetime rather than relying on a mutable path called latest. Release does not select the intended historical version on the analyst's behalf or verify the table's semantic compatibility.

## Reproduce the stale observation

A useful diagnostic loads a small table, replaces its backing file outside Kedro, and compares another load before and after release. Keep the correction recognizable without introducing unrelated model changes. Confirm behavior against the project's dataset implementation and execution mode.

The final evaluation record should bind its metrics to the table identity actually observed. [Dataset evidence documentation](/journal/data-guide-datasheets-dataset-evidence-gaps/) then describes what that identity represents; a cache hit alone cannot establish that the corrected population was evaluated.
