Skip to content

hub: reset and clean staging and snapshot scratch directories - #290

Open
Pybsama wants to merge 1 commit into
huggingface:mainfrom
Pybsama:fix/hub-staging-snapshot-cleanup
Open

Pybsama wants to merge 1 commit into
huggingface:mainfrom
Pybsama:fix/hub-staging-snapshot-cleanup

Conversation

@Pybsama

@Pybsama Pybsama commented Dec 1, 2026

Copy link
Copy Markdown

Summary

  • Reset .r2e_staging before staging tasks in push_to_hub and always clean it up in a finally: block so a leftover staging directory from a previously failed or interrupted push cannot leak deleted local tasks into manifest.json or upload_folder, and upload errors do not leave scratch directories behind.
  • Reset .r2e_snapshot before snapshot_download in pull_from_hub and always remove it in a finally: block so stale tasks from an earlier interrupted pull cannot be materialized alongside a fresh (or single-task task=...) pull, and invalid layouts do not leak .r2e_snapshot.
  • Add unit tests in tests/test_hub_metadata_read.py covering stale staging/snapshot cleanup and failure-path removal.

Test plan

  • pytest -q tests/test_hub_metadata_read.py tests/test_cli_push_pull.py tests/test_hub_asset_aliases.py tests/test_pipeline_contract.py (93 passed)
  • ruff check . (All checks passed)
  • ruff format --check . (515 files already formatted)

Out of scope

  • pull_from_harbor and pull_from_github already use tempfile.TemporaryDirectory, so they are left unchanged.

This branch has not been deployed

No deployments
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.

1 participant