Skip to content

Handle missing cache files in generate_fingerprint (#9103) - #9111

Open
zhengdaodeguL wants to merge 1 commit into
huggingface:mainfrom
zhengdaodeguL:fix/fingerprint-missing-cache-file-9103
Open

zhengdaodeguL wants to merge 1 commit into
huggingface:mainfrom
zhengdaodeguL:fix/fingerprint-missing-cache-file-9103

Conversation

@zhengdaodeguL

Copy link
Copy Markdown

Fixes #9103

generate_fingerprint() hashed cache-file modification times with no existence check, so a routine cache-state change — a user, cleanup_cache_files, or another process deleting a cache file — turned into a hard FileNotFoundError at Dataset construction time, naming an internal cache path.

The fix catches the missing file, logs a warning naming it, and returns a fresh random fingerprint. A random fingerprint is the safe fallback: it cannot collide with another dataset's cache identity, so the dataset is recomputed rather than loading stale results. Fingerprint behavior for intact cache files is unchanged.

Thanks to PCTEJA for reporting the issue with a precise root-cause analysis.

Verification

  • New tests in tests/test_fingerprint.py: the reporter's repro (deleted cache file, with and without indices) no longer crashes and yields a fresh random fingerprint each call, with the warning logged; Dataset construction against a missing cache file gets a valid fingerprint; and mtime-based fingerprinting for intact files is unchanged. All 5 pass; the 3 missing-file cases fail on base (verified with a source-only base control).
  • Targeted suites: 28 passed, 9 optional-dependency skips; ruff lint/format clean.

Use a random fingerprint when a cache file has disappeared so stale paths cannot produce an unsafe reusable cache identity. Keep timestamp hashing unchanged for intact files and log the fallback.

Thanks to PCTEJA for reporting the issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

generate_fingerprint() crashes with FileNotFoundError if any listed cache file is missing on disk

1 participant