Repository navigation
Fix
- Snapshot downloads send one
snapshot-identifierper task.download_repo,snapshot_download,ms-hub downloadand report mode previously generated a fresh UUID for every file request (and thus counted repeatedly). The identifier is now created once at the task entry and propagated down through every file, worker, range part, route probe, resume and integrity retry. - Standalone file downloads no longer send the header.
download_file,model_file_download,dataset_file_download, compat single-file calls and CLI explicit file arguments now omitsnapshot-identifier, so the dataset service applies its per-file counting to them instead of attributing a whole-snapshot hit. - Resumed report-mode tasks reuse the identifier. The task ID and an
openflag are persisted in the existing hidden tracker JSON; a task that endsPARTIALorCANCELLEDkeeps its ID on rerun, while the run after aCOMPLETEtracker starts a new task. - Cached dataset meta files no longer cost a counted request.
LegacyHubApinow checks the local meta-file cache before calling thedatasets/.../repoendpoint instead of after.
Enhance
- Tracker hardening: the persisted snapshot ID is validated against a 32-char hex pattern and folded into the existing scope check; malformed, foreign-scope or unreadable hints clear it and fall back to normal actual-file validation, never implying success.
- Explicit API surface:
_build_download_headers(..., snapshot_id=...),download_repo(..., _snapshot_id=...),_download_file(..., _snapshot_id=...)and_download_with_resume(..., snapshot_id=...); a non-blank caller-supplied ID is preserved, and the header builder never generates one itself. - No extra disk writes: the ID rides in the same JSON scope header, adding no per-file state writes.
Docs
- README: new "Download counting" section documenting task granularity, the two-hour server deduplication window, counted-at-first-request/irreversible-cancellation semantics, and the absence of exactly-once guarantees; tracker notes extended with ID reuse rules; v0.7.2 news entry.
- Docstrings:
download_file,download_repo,download_repo_report,download_snapshotand module header now describe identifier scope and cached-file behavior.
Tests
- New
tests/test_download_snapshot_identifier.py(454 lines): whole-repo inline+LFS, multi-worker, sequential and concurrent tasks on one instance, Range/disconnect/integrity retries, single-file and filtered downloads, full cache hit, root vs nested metadata files, report cancel/cross-process resume/post-COMPLETErerun, corrupt/unwritable trackers, realPreparedRequestheader capture. - Extended
tests/test_modelscope_download_compatibility.pyandtests/test_download_integrity.pyfor compat passthrough and identifier stability.
What's Changed
- Use real commit hashes as ref target commits when the platform expose by @tastelikefeet in #84
- Task-scoped download counting by @wangxingjun778 in #85
- Fix UTs by @wangxingjun778 in #86
Full Changelog: v0.7.1...v0.7.2