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

[Data] Try get size_bytes from metadata and consolidate metadata methods #46862

Merged
merged 13 commits into from
Jul 31, 2024

Conversation

bveeramani
Copy link
Member

@bveeramani bveeramani commented Jul 30, 2024

Why are these changes needed?

LogicalOperator and Datasource expose methods like schema() to make metadata efficiently available to Dataset APIs like Dataset.schema(). Currently, LogicalOperator exposes three such methds: num_rows(), schema(), and input_files().

This PR adds size_bytes() because it was missing. To simplify the interface, it also consolidates the metadata methods into a single aggregate_output_metadata() method.

Related issue number

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 added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • 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 :(

Signed-off-by: Balaji Veeramani <[email protected]>
Signed-off-by: Balaji Veeramani <[email protected]>
Signed-off-by: Balaji Veeramani <[email protected]>
Signed-off-by: Balaji Veeramani <[email protected]>
Signed-off-by: Balaji Veeramani <[email protected]>
Signed-off-by: Balaji Veeramani <[email protected]>
Signed-off-by: Balaji Veeramani <[email protected]>
Signed-off-by: Balaji Veeramani <[email protected]>
@bveeramani bveeramani changed the title [Data] [Data] Try get size_bytes from metadata and consolidate metadata methods Jul 30, 2024
Signed-off-by: Balaji Veeramani <[email protected]>
@bveeramani bveeramani marked this pull request as ready for review July 30, 2024 17:01
Signed-off-by: Balaji Veeramani <[email protected]>
Comment on lines +49 to 50
if all(bundle.num_rows() is not None for bundle in self.input_data):
return sum(bundle.num_rows() for bundle in self.input_data)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: not a big deal especially since it elongates the code. technically this is a double for loop, which could be optimized into one loop and early exit if we run into a Non num_rows. something like:

sum_num_rows = 0
for bundle in self.input_data:
    if not bundle.num_rows():
        return None
    sum_num_rows += bundle.num_rows()
return sum_num_rows

and the same could be applied in other similar places, e.g. _size_bytes method and methods in AbstractFrom. it may be worthwhile to put this logic in a shared utility function, for example as a static method in BlockMetadata.

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense, although I prefer keeping as-is since we don't know if this is a performance issue and I want to avoid premature optimization

Signed-off-by: Balaji Veeramani <[email protected]>
Signed-off-by: Balaji Veeramani <[email protected]>
Signed-off-by: Balaji Veeramani <[email protected]>
@bveeramani bveeramani enabled auto-merge (squash) July 31, 2024 01:56
@github-actions github-actions bot added the go add ONLY when ready to merge, run all tests label Jul 31, 2024
@bveeramani bveeramani merged commit a13fc9a into ray-project:master Jul 31, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go add ONLY when ready to merge, run all tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants