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

Support Parquet files in ShardedDataSource #764

Merged
merged 5 commits into from
Oct 14, 2024
Merged

Support Parquet files in ShardedDataSource #764

merged 5 commits into from
Oct 14, 2024

Conversation

nikil-ravi
Copy link
Contributor

@nikil-ravi nikil-ravi commented Oct 13, 2024

This PR creates a ParquetDataSource class to support loading .parquet files.
Closes #763

Copy link
Contributor

@abhinavg4 abhinavg4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, Thaks

@nikil-ravi nikil-ravi requested a review from dlwh October 13, 2024 23:30
table = pa.Table.from_pydict(data)
pq.write_table(table, f.name)

try:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not put this within the context manager and set delete to True?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@nikil-ravi nikil-ravi merged commit fc26c74 into main Oct 14, 2024
8 checks passed
@nikil-ravi nikil-ravi deleted the nikil/parquet branch October 14, 2024 02:19
Copy link
Member

@dlwh dlwh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for doing this!

@@ -238,6 +243,11 @@ def open_shard_at_row(self, shard_name: str, row: int) -> Iterator[str]:
data = json.load(f)
for doc in data[row:]:
yield doc[self.text_key]
case ".parquet":
table = pq.read_table(f)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

read_table is expensive in the general case and it would be better to look at the metadata to figure out which row group to start on and then use read_row_group I think

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for suggesting this, incorporated this in #766

@@ -417,6 +427,24 @@ def open_shard_at_row(self, shard_name: str, row: int) -> Iterator[dict]:
return iter(data[row:])


class ParquetDataSource(ShardedDataSource[dict]):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally the TextUrlDataSource would also work with parquet files. That is what we use for training configs typically

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, I added a new test for this in #766

dlwh pushed a commit that referenced this pull request Oct 15, 2024
Closes #763 and addresses David's comments in #764
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support loading parquet files in addition to jsonl.gz
4 participants