pola-rs/polars · error · ValueError

`use_pyarrow=True` is not supported for Hugging Face

Error message

`use_pyarrow=True` is not supported for Hugging Face

What it means

Polars' read_ipc supports a fast-path via pyarrow, but only when reading from ordinary file paths. Sources on the Hugging Face Hub (hf:// URLs) are streamed through Polars' own cloud storage layer, which the pyarrow-based IPC reader cannot consume, so this combination is rejected up front with a ValueError.

Solutions

  1. Remove use_pyarrow=True (let Polars use its native IPC reader, which supports hf:// sources)
  2. Read the file with use_pyarrow=False or the default
  3. Download the hf:// file locally first, then read_ipc the local path with use_pyarrow=True
  4. Use pl.scan_ipc(...).collect() instead of the pyarrow path

Example fix

// before
pl.read_ipc('hf://datasets/my-org/my-dset/data.feather', use_pyarrow=True)
// after
pl.read_ipc('hf://datasets/my-org/my-dset/data.feather')
Defensive patterns

Strategy: validation

Validate before calling

if use_pyarrow and isinstance(source, (str, Path)) and str(source).startswith('hf://'):
    raise ValueError('use_pyarrow=True is unsupported for hf:// sources')

Type guard

def is_hf_source(source) -> bool:
    return isinstance(source, (str, Path)) and str(source).startswith('hf://')

Prevention

When it happens

Trigger: Calling pl.read_ipc (or read_ipc_schema variants routed through it) with use_pyarrow=True and a source string/Path that starts with 'hf://'.

Common situations: Migrating code from local/s3 IPC reads to Hugging Face datasets; copy-pasting use_pyarrow=True from older code while switching source to hf:// URIs.

Understand the failure class

Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.

Related errors


AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18). Data as JSON: /api/errors/67d02cad25c38074. Report an issue: GitHub.

Appendix: source

Thrown at py-polars/src/polars/io/ipc/functions.py:141

          E.g. `pl.read_ipc("my_file.arrow").write_ipc("my_file.arrow")`
          will fail.
    """
    projection, column_names = parse_columns_arg(columns)
    del columns
    row_index = parse_row_index_args(row_index_name, row_index_offset)
    del row_index_name
    del row_index_offset

    if use_pyarrow:
        if n_rows:
            msg = (
                "`n_rows` cannot be used with `use_pyarrow=True` and `memory_map=False`"
            )
            raise ValueError(msg)

        if (isinstance(v := source, (str, Path))) and str(v).startswith("hf://"):
            msg = "`use_pyarrow=True` is not supported for Hugging Face"
            raise ValueError(msg)

        with prepare_file_arg(
            source, use_pyarrow=use_pyarrow, storage_options=storage_options
        ) as data:
            pyarrow_ipc = import_optional(
                "pyarrow.ipc",
                err_prefix="",
                err_suffix="is required when using 'read_ipc(..., use_pyarrow=True)'",
            )

            if column_names is not None:
                initial_pos: Any = None

                if hasattr(data, "tell") and callable(data.tell):
                    initial_pos = data.tell()

                with pyarrow_ipc.open_file(data) as ipc_f:
                    schema = ipc_f.schema

View on GitHub (pinned to fe841f959e)