ParagEkbote opened a new issue, #77905:
URL: https://github.com/apache/airflow/issues/77905

   ### Description
   
   Add support for transferring task files to and from [Hugging Face 
Buckets](https://huggingface.co/docs/huggingface_hub/v2.5.0/guides/buckets#buckets)
 in the [Hugging Face 
provider](https://github.com/apache/airflow/tree/main/providers/huggingface).
   
   Buckets provide mutable, S3-like object storage on the Hub. They are useful 
for large files such as training checkpoints, logs, and intermediate artifacts 
that do not need Git history. The provider currently supports dataset 
repositories, but does not expose the Buckets API to Airflow tasks.
   
   The `huggingface_hub` library provides `sync_bucket` for synchronizing a 
local directory with a bucket. A single operator can use it for upload or 
download based on the source and destination, while keeping the API aligned 
with the upstream library.
   
   ### Scope
   
   - Add `HuggingFaceBucketSyncOperator`. Use the existing `HuggingFaceHook` to 
resolve the configured connection and pass its token to `sync_bucket`; no new 
hook method is needed unless the selected API requires one.
   - Accept local paths and `hf://buckets/<namespace>/<bucket>[/<prefix>]` URIs 
as source and destination. Support both upload and download directions.
   - Expose the `sync_bucket` options needed for common workflows, including 
include/exclude patterns and dry-run behavior where supported by the chosen 
`huggingface_hub` version.
   - Make remote deletion opt-in and default it to `False`. When enabled, 
document that destination files absent from the source are removed.
   - Return the bucket URI as the operator result; do not return file contents 
or large metadata through XCom.
   - Raise the `huggingface-hub` dependency floor only as far as needed for the 
Buckets API, and state the selected floor and reason in the PR.
   - Add operator documentation and a how-to example showing upload and 
download.
   
   Out of scope: bucket creation, deletion, visibility changes, and a 
general-purpose bucket lifecycle API. These can be proposed separately if users 
need them.
   
   ### Done when
   
   - The hook method and operator are implemented with unit tests for both 
transfer directions, connection authentication, filters, and the deletion 
default/opt-in behavior.
   - A system test under `providers/huggingface/tests/system/huggingface/` 
uploads a small file to a uniquely named bucket and downloads it again to 
verify its contents.
   - The system test cleans up its temporary bucket, including when an 
assertion fails.
   - A how-to page documents the required token permissions, worker-local path 
requirements, task timeout considerations for large transfers, and the 
destructive effect of enabling deletion.
   - The supported `huggingface_hub` floor is documented in the PR with the API 
compatibility reason.
   
   ### End-to-end verification
   
   Transfers should be verified against a real Hugging Face Bucket in addition 
to mocked unit tests.
   
   Setup:
   
   - Run Airflow with the Hugging Face provider installed from the PR branch.
   - Configure a Hugging Face token through an Airflow connection with 
permission to create and write to a dedicated test namespace.
   - Use a unique temporary bucket name per system test run and upload only 
small test fixtures.
   - Never print or commit the token. Ensure cleanup removes the temporary 
bucket after success or failure.
   
   Scenarios:
   
   1. Upload a local file or small directory to a bucket prefix and verify the 
remote file exists with the expected content.
   2. Download that file to a local destination and verify the contents match.
   3. Verify include/exclude filtering and that the default sync does not 
delete unrelated remote files.
   4. Verify that deletion occurs only when explicitly enabled, using a 
separate temporary bucket or prefix.
   
   ### Use case/motivation
   
   An Airflow Dag can submit a training job to Hugging Face hardware, then use 
the resulting checkpoint or logs in later tasks for evaluation or promotion. 
The job and Airflow task may run on different machines, and large intermediate 
files are not a good fit for XCom or a Git-backed Hub repository. A Bucket 
provides shared storage between those steps, while a sync operator moves files 
between the task's local filesystem and that storage using the task's Hugging 
Face connection.
   
   The operator should make this transfer straightforward in both directions: 
upload prepared inputs or artifacts before a job and download checkpoints or 
outputs for downstream Airflow tasks. This makes Buckets useful as a storage 
handoff for workflows such as the Hugging Face Jobs feature proposed in #77831, 
without coupling the operator to job submission or lifecycle management.
   
   ### Related issues
   
   _No response_
   
   ### Are you willing to submit a PR?
   
   - [x] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to