Feature Request / Discussion: Skip origin_metadata fetch when streaming=True?
Hi team!
I've been looking into the initialization process of the DatasetBuilder and noticed that the ETag/origin metadata caching path is executed unconditionally.
While fetching the origin_metadata and calculating the ETag is necessary for safely managing a local disk cache when using as_dataset(), it seems this might be redundant for streaming. When a user requests streaming=True, the pipeline drops into as_streaming_dataset(). Because streaming does not use a local cache, it appears the streaming pipeline ignores the generated _cache_dir string and never calls _get_dataset_fingerprint(). As a result, the origin metadata is fetched and hashed without being used.
I wanted to start a discussion to understand if there is another purpose for the etag/origin_metadata when streaming. If not, would it be possible/desirable to skip this fetch when streaming=True to improve initialization latency and save unnecessary network calls?
Thanks!
I think it's great that it checks that every file does exist by default. It's relatively cheap since it uses fsspec which caches file info at folder level.
On the other hand why not add skip_origin_metadata=False from @TheDerbiedOne by default to DatasetBuilder and document what it does (load_dataset passes kwargs to DatasetBuilder)
Hi @lhoestq Thanks for taking a look at this! Regarding the file existence check: skipping _get_origin_metadata actually doesn't remove that safeguard. I think th verification that files exist happens earlier during pattern resolution (around L372-L384 in data_files.py (https://github.com/huggingface/datasets/blob/main/src/datasets/data_files.py#L372-L384)). The _get_single_origin_metadata function (around L498-L519 (https://github.com/huggingface/datasets/blob/main/src/datasets/data_files.py#L498-L519)) runs strictly after resolution, and its only purpose is to extract the ETag or mtime to build the local cache fingerprint. Since streaming completely bypasses the local cache, calculating this fingerprint shouldn't be necessary. Correct me if I misunderstand this part.
Regarding skip_origin_metadata flag, I think it's a good idea to add it.