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

[Datasets] Support None partition field name #28417

Merged
merged 2 commits into from
Sep 13, 2022

Conversation

bveeramani
Copy link
Member

@bveeramani bveeramani commented Sep 9, 2022

Signed-off-by: Balaji Veeramani [email protected]

Why are these changes needed?

Some datasets are stored like

root/cat/images/cat1.png
root/cat/images/cat2.png
...
root/dog/images/dog.png
...

To read these datasets, we want to parse the label (e.g., "cat" or "dog") but not "images":

read_images(..., partitioning=Partitioning("dir", labels=["label", None], base_dir=root]))

This PR makes it possible to exclude certain directory partitions (e.g., "images").

Related issue number

See #28413 and #28256

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

@bveeramani bveeramani changed the title [Datasets] Support None partitioning field name [Datasets] Support None partition field name Sep 9, 2022
Copy link
Contributor

@ericl ericl left a comment

Choose a reason for hiding this comment

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

Seems reasonable. What happens if you specify not enough labels for directory partitioning? E.g., there are 4 dir labels, but you only specify ["one", "two", "three"]? Do we currently crash or ignore the 4th field?

I'm wondering if we should just require a prefix to be specified, ignoring all dirs after that. Then, DirPartitioning([]) is equivalent to no partitioning.

@bveeramani
Copy link
Member Author

What happens if you specify not enough labels for directory partitioning?

The program raises an AssertionError.

I'm wondering if we should just require a prefix to be specified, ignoring all dirs after that. Then, DirPartitioning([]) is equivalent to no partitioning.

We could do that. It'd satisfy the ImageNet scenario (/root/cat/images/cat.png).

That being said, the prefix approach won't support paths like /1970/countries/fr/products.csv.

@ericl
Copy link
Contributor

ericl commented Sep 9, 2022

Hmm, it seems bad to raise assertion error due to directory structure. The prefix strategy seems better to me, but I'd defer to @clarkzinzow @c21

Copy link
Contributor

@clarkzinzow clarkzinzow left a comment

Choose a reason for hiding this comment

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

LGTM, I think that allowing None to indicate a non-partition directory is a good way to go; it's more flexible than the prefix which wouldn't support intermixed partitions and non-partitions.

Agreed with @ericl that we should raise a proper error rather than an AssertionError, any chance we could fix that in this PR?

@bveeramani
Copy link
Member Author

Agreed with @ericl that we should raise a proper error rather than an AssertionError, any chance we could fix that in this PR?

I changed it in the "Add partitionining parameter" PR.

@clarkzinzow
Copy link
Contributor

clarkzinzow commented Sep 13, 2022

@bveeramani Perfect, thank you! This PR looks good to merge, then.

@ericl ericl merged commit 901dc3e into ray-project:master Sep 13, 2022
PaulFenton pushed a commit to PaulFenton/ray that referenced this pull request Sep 19, 2022
Some datasets are stored like

```
root/cat/images/cat1.png
root/cat/images/cat2.png
...
root/dog/images/dog.png
...
```

To read these datasets, we want to parse the label (e.g., `"cat"` or `"dog"`) but not `"images"`:

```
read_images(..., partitioning=Partitioning("dir", labels=["label", None], base_dir=root]))
```

This PR makes it possible to exclude certain directory partitions (e.g., `"images"`).

Signed-off-by: PaulFenton <[email protected]>
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.

3 participants