Problem
The current remote flow is save_to_disk(local_folder) then push_to_hub(local_folder). This uploads only after the whole dataset has been fully materialized on local disk, so peak local disk usage = size of the entire dataset. At TB scale (the use case raised in #478) this is the blocker: the machine may simply not have room to stage the full dataset before a single byte is uploaded.
Note this isn't a "missing S3 door in push_to_hub" problem — it's a timing problem: the upload happens post-materialization instead of being interleaved with per-sample writing.
Proposed direction
Make save_to_disk fsspec-aware so each sample is written directly to the target (local or remote) as it is produced. Then:
- uploads become incremental (per sample),
- peak local disk drops to ~1 sample instead of the whole dataset,
push_to_hub on a pre-written folder becomes just one special case rather than the only path to remote.
Scope
- In scope: file-based backends (cgns, zarr). They already write sample by sample in the writer loop (
for sample in gen_func(): sample.save_to_dir(...)), so redirecting those writes through an fsspec AbstractFileSystem is a natural, low-cost change — consistent with @tmolcard's point that per-sample upload for cgns/zarr "isn't very complicated."
- Out of scope: hf_datasets backend. The Arrow table is materialized locally regardless, so streaming writes to a remote target don't apply there.
Relation to #478
The sample_callback hook added in #478 is effectively a workaround for this limitation (upload-then-delete each sample by hand because the library writes locally only). An fsspec-aware save_to_disk would make the hook unnecessary for this use case (it may retain value for other per-sample side effects). #478 can land as the minimal immediate fix; this issue tracks the more direct solution.
Open questions
- fsspec handle management under
num_proc > 1 (independent handles per worker, process-safe).
- cgns/zarr writes that need a seekable handle may still need a small per-sample local temp buffer, uploaded then discarded — still bounded peak disk (~1 sample), unlike today.
- optional deps (
s3fs/gcsfs/…) gated behind a [remote] extra with a clear error when the protocol handler is missing.
Problem
The current remote flow is
save_to_disk(local_folder)thenpush_to_hub(local_folder). This uploads only after the whole dataset has been fully materialized on local disk, so peak local disk usage = size of the entire dataset. At TB scale (the use case raised in #478) this is the blocker: the machine may simply not have room to stage the full dataset before a single byte is uploaded.Note this isn't a "missing S3 door in
push_to_hub" problem — it's a timing problem: the upload happens post-materialization instead of being interleaved with per-sample writing.Proposed direction
Make
save_to_diskfsspec-aware so each sample is written directly to the target (local or remote) as it is produced. Then:push_to_hubon a pre-written folder becomes just one special case rather than the only path to remote.Scope
for sample in gen_func(): sample.save_to_dir(...)), so redirecting those writes through an fsspecAbstractFileSystemis a natural, low-cost change — consistent with @tmolcard's point that per-sample upload for cgns/zarr "isn't very complicated."Relation to #478
The
sample_callbackhook added in #478 is effectively a workaround for this limitation (upload-then-delete each sample by hand because the library writes locally only). An fsspec-awaresave_to_diskwould make the hook unnecessary for this use case (it may retain value for other per-sample side effects). #478 can land as the minimal immediate fix; this issue tracks the more direct solution.Open questions
num_proc > 1(independent handles per worker, process-safe).s3fs/gcsfs/…) gated behind a[remote]extra with a clear error when the protocol handler is missing.