Add support for partitioned datasets#4610
Open
copybara-service[bot] wants to merge 1 commit intomasterfrom
Open
Add support for partitioned datasets#4610copybara-service[bot] wants to merge 1 commit intomasterfrom
copybara-service[bot] wants to merge 1 commit intomasterfrom
Conversation
daf1d38 to
77c8a6f
Compare
For some datasets it makes sense to partition the data. For example, the wikipedia dataset has a language and a snapshot date dimension. Another example would be a production pipeline that creates a new dataset periodically (e.g. using TFX). Currently, there is no native support for this in TFDS, which makes adding new partitions unhandy.
This change adds native support to TFDS.
Notes:
* although the wikipedia config names are backwards compatible, loading them would fail because it expects the data to be stored in a nested way, e.g. `DATA_DIR/wikipedia/20220620/nl/...`. I'm including it here to get comments, but this is something that needs to be fixed before submitting.
* not ideal is that loading a partition with tfds.load can be done in two ways: `tfds.load("wikipedia/20220620.nl")` and `tfds.load("wikipedia<snapshot=20220620,language=nl>")`. I personally think that the <> syntax is nice because it's more explicit, the ordering doesn't matter, and it is extensible to more powerful syntax like wildcards or lists to load multiple partitions at once.
In future work, we can add a richer load API, e.g. `tfds.load("wikipedia<snapshot=20221122,language=*>")`.
PiperOrigin-RevId: 465993640
77c8a6f to
0032104
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add support for partitioned datasets
For some datasets it makes sense to partition the data. For example, the wikipedia dataset has a language and a snapshot date dimension. Another example would be a production pipeline that creates a new dataset periodically (e.g. using TFX). Currently, there is no native support for this in TFDS, which makes adding new partitions unhandy.
This change adds native support to TFDS.
Notes:
although the wikipedia config names are backwards compatible, loading them would fail because it expects the data to be stored in a nested way, e.g.
DATA_DIR/wikipedia/20220620/nl/.... I'm including it here to get comments, but this is something that needs to be fixed before submitting.not ideal is that loading a partition with tfds.load can be done in two ways:
tfds.load("wikipedia/20220620.nl")andtfds.load("wikipedia<snapshot=20220620,language=nl>"). I personally think that the <> syntax is nice because it's more explicit, the ordering doesn't matter, and it is extensible to more powerful syntax like wildcards or lists to load multiple partitions at once.In future work, we can add a richer load API, e.g.
tfds.load("wikipedia<snapshot=20221122,language=*>").