kaxil opened a new pull request, #77646:
URL: https://github.com/apache/airflow/pull/77646

   `StreamDatasetOperator` copies a pinned Hub dataset revision to another repo 
by [passing the stream to Datasets' 
`push_to_hub`](https://github.com/apache/airflow/blob/e494b868cf7aca91720031a973c7080b1cf2f661/providers/huggingface/src/airflow/providers/huggingface/operators/datasets.py#L565-L576).
 `push_to_hub` [defaults to 
`embed_external_files=True`](https://github.com/huggingface/datasets/blob/5.2.0/src/datasets/iterable_dataset.py#L5345-L5353),
 which makes it open every file that an `Image`, `Audio` or similar row 
references by path and write the bytes into the published Parquet shards. So 
what gets published can differ from the rows of the revision we pinned.
   
   This turns that off for Hub sources: the operator passes 
`embed_external_files=False` unless `push_kwargs` sets it. Bytes already in a 
row are copied, and a row that only references a file keeps the reference. 
Local sources are untouched.
   
   `PushToHubOperator` gets the same default. It has no effect on artifacts the 
provider wrote, since `_save()` [only accepts scalar, class-label and nested 
sequence 
features](https://github.com/apache/airflow/blob/e494b868cf7aca91720031a973c7080b1cf2f661/providers/huggingface/src/airflow/providers/huggingface/operators/datasets.py#L72-L92).
   
   On Datasets 5.2.0 this is a small change. 5.2.0 [decodes Hub folder-based 
streams to 
bytes](https://github.com/huggingface/datasets/blob/5.2.0/src/datasets/builder.py#L1186-L1193)
 before they reach the push, so an image folder is still copied whole (I 
streamed a public one-image repo to confirm: the row has the bytes and no 
path). 5.0.0 and 5.1.0 don't have that step, so there an image folder now 
publishes as file references. `push_kwargs={"embed_external_files": True}` 
brings back the old behaviour. Docs and a changelog note are included.
   
   I looked at embedding only the files that belong to the source revision. 
`push_to_hub` has just the one on/off flag, so we'd have to reimplement its 
embedding step in the operator.
   
   Ran it with `airflow dags test` against a local Hub stand-in, using a source 
with one row holding bytes and one holding only a path. Both were published as 
stored.
   


-- 
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