Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix huggingface.rst documentation #2746

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions docs/source/user_guide/integrations/huggingface.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Huggingface Datasets
====================

Daft is able to read datasets directly from Huggingface via the ``hf://`` protocol.
Daft is able to read datasets directly from Huggingface via the ``hf://datasets/`` protocol.

Since huggingface will `automatically convert <https://huggingface.co/docs/dataset-viewer/en/parquet>`_ all public datasets to parquet format,
we can read these datasets using the ``read_parquet`` method.
Expand All @@ -19,7 +19,7 @@ Reading Public Datasets

import daft

df = daft.read_parquet("hf://username/dataset_name")
df = daft.read_parquet("hf://datasets/username/dataset_name")

This will read the entire dataset into a daft DataFrame.

Expand All @@ -29,12 +29,12 @@ Not only can you read entire datasets, but you can also read individual files fr

import daft

df = daft.read_parquet("hf://username/dataset_name/file_name.parquet")
df = daft.read_parquet("hf://datasets/username/dataset_name/file_name.parquet")
# or a csv file
df = daft.read_csv("hf://username/dataset_name/file_name.csv")
df = daft.read_csv("hf://datasets/username/dataset_name/file_name.csv")

# or a glob pattern
df = daft.read_parquet("hf://username/dataset_name/**/*.parquet")
df = daft.read_parquet("hf://datasets/username/dataset_name/**/*.parquet")


Authorization
Expand All @@ -47,18 +47,18 @@ For authenticated datasets:
from daft.io import IOConfig, HTTPConfig

io_config = IoConfig(http=HTTPConfig(bearer_token="your_token"))
df = daft.read_parquet("hf://username/dataset_name", io_config=io_config)
df = daft.read_parquet("hf://datasets/username/dataset_name", io_config=io_config)


It's important to note that this will not work with standard tier private datasets.
Huggingface does not auto convert private datasets to parquet format, so you will need to specify the path to the files you want to read.

.. code:: python

df = daft.read_parquet("hf://username/my_private_dataset", io_config=io_config) # Errors
df = daft.read_parquet("hf://datasets/username/my_private_dataset", io_config=io_config) # Errors

to get around this, you can read all files using a glob pattern *(assuming they are in parquet format)*

.. code:: python

df = daft.read_parquet("hf://username/my_private_dataset/**/*.parquet", io_config=io_config) # Works
df = daft.read_parquet("hf://datasets/username/my_private_dataset/**/*.parquet", io_config=io_config) # Works
Loading