-
Notifications
You must be signed in to change notification settings - Fork 353
Add Daft to list of integrated libraries for datasets #1892
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
Open
kevinzwang
wants to merge
7
commits into
huggingface:main
Choose a base branch
from
kevinzwang:daft-datasets-docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1f0e69d
Add Daft to list of integrated libraries for datasets
kevinzwang a16a995
Update Inference Providers documentation (automated) (#1891)
HuggingFaceInfra eec2edb
[inference providers] reorder menu (#1876)
burtenshaw 9d241ae
Update Inference Providers documentation (automated) (#1893)
HuggingFaceInfra 5168d78
More requirement from #1853 more visible (#1894)
julien-c f62c50a
Update Inference Providers documentation (automated) (#1897)
HuggingFaceInfra 2d43a51
update wording
kevinzwang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Daft | ||
|
||
[Daft](https://daft.ai/) is a high-performance data engine providing simple and reliable data processing for any modality and scale. Daft has native support for reading from and writing to Hugging Face datasets. | ||
|
||
<div class="flex justify-center"> | ||
<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/daft_hf.png"/> | ||
</div> | ||
|
||
|
||
## Getting Started | ||
|
||
To get started, pip install `daft` with the `huggingface` feature: | ||
|
||
```bash | ||
pip install 'daft[hugggingface]' | ||
``` | ||
|
||
## Read | ||
|
||
Daft is able to read datasets directly from Hugging Face using the [`daft.read_huggingface()`](https://docs.daft.ai/en/stable/api/io/#daft.read_huggingface) function or via the `hf://datasets/` protocol. | ||
|
||
### Reading an Entire Dataset | ||
|
||
Using [`daft.read_huggingface()`](https://docs.daft.ai/en/stable/api/io/#daft.read_huggingface), you can easily read a Hugging Face dataset. | ||
|
||
|
||
```python | ||
import daft | ||
|
||
df = daft.read_huggingface("username/dataset_name") | ||
``` | ||
|
||
This will read the entire dataset into a DataFrame. | ||
|
||
### Reading Specific Files | ||
|
||
Not only can you read entire datasets, but you can also read individual files from a dataset. Using a read function that takes in a path (such as [`daft.read_parquet()`](https://docs.daft.ai/en/stable/api/io/#daft.read_parquet), [`daft.read_csv()`](https://docs.daft.ai/en/stable/api/io/#daft.read_csv), or [`daft.read_json()`](https://docs.daft.ai/en/stable/api/io/#daft.read_json)), specify a Hugging Face dataset path via the `hf://datasets/` prefix: | ||
|
||
```python | ||
import daft | ||
|
||
# read a specific Parquet file | ||
df = daft.read_parquet("hf://datasets/username/dataset_name/file_name.parquet") | ||
|
||
# or a csv file | ||
df = daft.read_csv("hf://datasets/username/dataset_name/file_name.csv") | ||
|
||
# or a set of Parquet files using a glob pattern | ||
df = daft.read_parquet("hf://datasets/username/dataset_name/**/*.parquet") | ||
``` | ||
|
||
## Write | ||
|
||
Daft is able to write Parquet files to Hugging Face datasets using [`daft.DataFrame.write_huggingface`](https://docs.daft.ai/en/stable/api/dataframe/#daft.DataFrame.write_deltalake). Daft supports [Content-Defined Chunking](https://huggingface.co/blog/parquet-cdc) and [Xet](https://huggingface.co/blog/xet-on-the-hub) for faster, deduplicated writes. | ||
davanstrien marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Basic usage: | ||
|
||
```python | ||
import daft | ||
|
||
df: daft.DataFrame = ... | ||
|
||
df.write_huggingface("username/dataset_name") | ||
``` | ||
|
||
See the [`DataFrame.write_huggingface`](https://docs.daft.ai/en/stable/api/dataframe/#daft.DataFrame.write_deltalake) API page for more info. | ||
|
||
## Authentication | ||
|
||
The `token` parameter in [`daft.io.HuggingFaceConfig`](https://docs.daft.ai/en/stable/api/config/#daft.io.HuggingFaceConfig) can be used to specify a Hugging Face access token for requests that require authentication (e.g. reading private datasets or writing to a dataset). | ||
|
||
Example of reading a dataset with a specified token: | ||
|
||
```python | ||
from daft.io import IOConfig, HuggingFaceConfig | ||
|
||
io_config = IOConfig(hf=HuggingFaceConfig(token="your_token")) | ||
df = daft.read_parquet("hf://datasets/username/dataset_name", io_config=io_config) | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.