feat(hub): add copyFiles API for remote file copy between buckets and repositories#2121
Draft
feat(hub): add copyFiles API for remote file copy between buckets and repositories#2121
copyFiles API for remote file copy between buckets and repositories#2121Conversation
… repositories Implements the 'copy files remotely' API in @huggingface/hub, porting the Python huggingface_hub.HfApi.copy_files functionality to TypeScript/JS. Supports: - Bucket-to-bucket copy (server-side, no data transfer) - Repo (model/dataset/space) to bucket copy - xet-backed files: server-side copy by hash - non-xet files: download + re-upload via commit - Single file and recursive folder copy - hf:// handle parsing with revision support Reference: huggingface/huggingface_hub#3874 Co-authored-by: Lucain <Wauplin@users.noreply.github.com>
Contributor
Author
|
closing in favor of @julien-c 's PR to come |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the "copy files remotely" API in
@huggingface/hub, porting the PythonHfApi.copy_filesfunctionality to TypeScript/JS.This enables the "Copy to Bucket" feature on the Hub UI, allowing instant server-side file copy between buckets and from repositories to buckets.
Supported operations
commit()Not supported (yet)
Features
copyFiles()— main function, exported from@huggingface/hubparseHfCopyHandle()— parseshf://handles (buckets, models, datasets, spaces, with@revisionsupport)POST /api/buckets/{id}/batchwith NDJSONcopyFileoperationscommit()infrastructureUsage
Reference
Python implementation: huggingface/huggingface_hub#3874
How to test locally
Unit tests (handle parsing)
The
parseHfCopyHandleunit tests run without any network access.Integration tests (require CI Hub access)
The integration tests (
copyFilesdescribe block) run against the CI Hub athttps://hub-ci.huggingface.co. They:copyFilesTo run them:
Manual testing
You can also test manually against the production Hub:
Slack Thread