What does Hugging Face Datasets' push_to_hub() write to a dataset repo, and how do teammates load exactly that upload later?
answer
- a commit, not a git push
- Parquet shards under data/
- 500MB max shard by default
- card YAML lists the splits
- returned commit sha as revision
basics
~10 spush_to_hub() commits Parquet shards (data/train-00000-of-0000N.parquet, at most 500MB each by default) plus dataset-card YAML naming the splits. It returns a CommitInfo; loading with revision= set to that commit sha reproduces exactly that upload.
solid answer
~40 s`Dataset.push_to_hub("your-org/tickets-tokenized")` converts the table to **Parquet** shards and uploads them over HTTP as one commit, with no git or git-lfs needed. Files land under `data/` as `{split}-00000-of-0000N.parquet`, sized by `max_shard_size` (default `"500MB"`) or `num_shards`; `split=` names the split (default: the dataset's own split, else `train`), and `config_name` adds a named subset. The `README.md` card's YAML is updated so `load_dataset` finds the splits, and re-pushing a split replaces that split's old shards. `private=`, `revision=` (a branch) and `create_pr=` control visibility and target. It returns a `CommitInfo` whose `oid` is the commit sha; `load_dataset(repo, revision=oid)` reproduces that upload exactly, streaming or not. `save_to_disk` is the local Arrow alternative, reloaded with `load_from_disk`.
code
python · 15 linesfrom datasets import load_dataset
tokenized = load_dataset("your-org/support-tickets", split="train")
# ... map(), filter() ...
info = tokenized.push_to_hub(
"your-org/tickets-tokenized",
split="train",
private=True, # applies only when the repo is created
max_shard_size="500MB", # the default, shown for clarity
)
print(info.oid) # commit sha to record with the run
# Later, anywhere: exactly that upload
same = load_dataset("your-org/tickets-tokenized", split="train", revision=info.oid)go deeper
Recall that push_to_hub uploads a dataset to a Hub dataset repo as Parquet and that load_dataset with the repo id reads it back.
Explain the layout: Parquet shards under data/ sized by max_shard_size, card YAML naming splits, split and config_name, and that re-pushing a split replaces it.
Make uploads reproducible and safe: record the returned commit sha, load with revision, push to a branch or PR, and set private before the first push.
Decide which datasets a team publishes as versioned Hub repos and which stay local Arrow caches, weighing reuse, access control and storage against upload time.
## What push_to_hub produces In the Hugging Face **Datasets** library, `Dataset.push_to_hub(repo_id)` publishes a processed dataset as a **dataset repository** on the Hub. It is not a `git push`: it uses HTTP upload calls, so neither git nor git-lfs has to be installed, and every call ends in one **commit** on the repo. What that commit contains: - **Parquet shards**, written under `data/` by default with names like `train-00000-of-00004.parquet`. Parquet is a compressed, columnar file format that most data tools read directly. - **Shard sizing** from `max_shard_size` (default `"500MB"`) or an explicit `num_shards`; passing both raises an error. - An updated **`README.md` dataset card**, whose YAML header lists configurations, the data files for each split and dataset info, so a later `load_dataset(repo_id)` knows which files form which split. - **Embedded media**: with `embed_external_files=True` (the default), `Image` and `Audio` values are stored as bytes inside the Parquet files, so the repo is self-contained. If the repo does not exist it is created; `private=True` makes a new repo private, and the setting is ignored for a repo that already exists. ## Splits, subsets and re-pushing | Argument | Effect | |---|---| | `split="validation"` | name of the split being uploaded; defaults to the dataset's own split, else `train` | | `config_name="en"` | uploads a named subset into its own directory, loaded later with `load_dataset(repo, "en")` | | `revision="preprocessing-v2"` | commits to that branch, creating it if needed, instead of `main` | | `create_pr=True` | opens a pull request on the repo rather than committing directly | | `num_proc=8` | prepares and uploads shards in parallel processes | Pushing a split a second time **replaces** it: the same commit deletes that split's previous shards and updates the card. Other splits are untouched, which is how you build a repo split by split. A `DatasetDict` has its own `push_to_hub` that uploads every split in one call. ## Loading exactly that upload later `push_to_hub` returns a `CommitInfo` from the huggingface_hub library. Its `oid` field is the **commit sha**. Recording it, and having consumers load with it, is what makes the upload reproducible: 1. Push and keep `info = ds.push_to_hub(...)`. 2. Write `info.oid` into the training configuration or run metadata. 3. Load with `load_dataset("your-org/tickets-tokenized", revision=info.oid)`, or with `streaming=True` to read the same Parquet shards lazily. Without `revision=`, consumers follow `main`, which moves on the next push. Tags and branches work as `revision` values too, but only a commit sha cannot move. How those pins are recorded across a whole training pipeline is a lineage question beyond this library call. ## push_to_hub versus save_to_disk - **`save_to_disk(path)`** writes **Arrow** files plus state files to a local or remote file system. Arrow is uncompressed, so it reloads fastest, which suits local, short-lived caching. Reload it with **`load_from_disk(path)`**; calling `load_dataset` on that directory raises an error telling you to use `load_from_disk`. - **`push_to_hub`** writes **compressed Parquet** to a versioned repo: slower to write, smaller to move, readable by other tools, shareable with access control and streamable by anyone with access. ## Converting a dataset that still uses a loading script Older dataset repos shipped a Python **loading script** that generated rows. Current Datasets releases (checked at 5.0.1) no longer run them: passing `trust_remote_code=True` only logs that the option is not supported anymore, and a repo that still contains its script fails with a runtime error saying dataset scripts are no longer supported. The fix the error message suggests is to convert the data to a standard format such as Parquet; `push_to_hub` from a `Dataset` built any other way, for example with `Dataset.from_generator`, is the straightforward route. ## Practical checklist - Authenticate first: a token from `hf auth login` or the `HF_TOKEN` environment variable. - Choose `private=True` before the first push; the flag does not change an existing repo. - Keep shards moderately sized and numerous so streaming shuffles and parallel readers work well. - Record the returned commit sha with every training run. - Push to a branch with `revision=` or open a pull request with `create_pr=True` when others already train from `main`, so a half-finished preprocessing change never lands under their feet. - Remember that each push is a new commit in the repo's history: replacing a split does not rewrite earlier commits, so a recorded sha keeps pointing at the files it named.
- A teammate's Hugging Face Datasets code passes trust_remote_code=True to load an old script-based dataset. What happens now?Current Datasets (5.0) logs that `trust_remote_code` is not supported anymore and does not run the script; if the repo still holds its loading script, loading fails with a runtime error that dataset scripts are no longer supported. The data must be converted to Parquet or another standard format, for example by rebuilding it and calling `push_to_hub`.
- When would you choose save_to_disk over push_to_hub in Hugging Face Datasets?For a local, short-lived checkpoint of a processed dataset on the same machine or shared file system: `save_to_disk` writes uncompressed Arrow that `load_from_disk` reloads almost instantly. Choose `push_to_hub` when others need it, when you want versioned history and access control, or when consumers should stream it.
- push_to_hub needs git and git-lfs installed on the machine
- push_to_hub uploads the same Arrow files that save_to_disk writes
- Loading the repo by name always returns the version you pushed
- private=True makes an existing public dataset repo private
- load_dataset can reload a directory written by save_to_disk
Assumes Datasets 5.0 (checked at 5.0.1): loading scripts are no longer run, so trust_remote_code is not supported and script-based repos must be converted to files such as Parquet.