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

[AIR] Deal with nested Chain in BatchPredictor #31407

Merged
merged 5 commits into from
Jan 4, 2023

Conversation

Yard1
Copy link
Member

@Yard1 Yard1 commented Jan 3, 2023

Why are these changes needed?

BatchPredictor._determine_preprocessor_batch_format has a special case for Chain, where it obtains the first preprocessor contained within Chain in order to determine which transformation function to use for the dataset (as Chain doesn't implement any). However, with #29706 allowing for nested Chains, this check fails if the first preprocessor within a Chain is also a Chain.

This PR removes this special case from BatchPredictor and instead subclasses _determine_transform_to_use inside Chain itself, which allows us to both deal with the nested Chain case and improve code structure.

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 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: Antoni Baum <[email protected]>
@Yard1 Yard1 requested a review from amogkam January 3, 2023 19:07
python/ray/data/preprocessors/chain.py Outdated Show resolved Hide resolved
python/ray/data/preprocessors/chain.py Outdated Show resolved Hide resolved
@amogkam
Copy link
Contributor

amogkam commented Jan 3, 2023

Thanks @Yard1! Lgtm, just couple minor comments about the type hints and keeping the signature exactly the same as the base class.

@Yard1 Yard1 requested a review from amogkam January 3, 2023 20:41
Copy link
Member

@bveeramani bveeramani left a comment

Choose a reason for hiding this comment

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

LGTM!

@amogkam amogkam merged commit c4ba744 into ray-project:master Jan 4, 2023
@Yard1 Yard1 deleted the nested_chain_batch_predictor branch January 4, 2023 13:22
AmeerHajAli pushed a commit that referenced this pull request Jan 12, 2023
BatchPredictor._determine_preprocessor_batch_format has a special case for Chain, where it obtains the first preprocessor contained within Chain in order to determine which transformation function to use for the dataset (as Chain doesn't implement any). However, with #29706 allowing for nested Chains, this check fails if the first preprocessor within a Chain is also a Chain.

This PR removes this special case from BatchPredictor and instead subclasses _determine_transform_to_use inside Chain itself, which allows us to both deal with the nested Chain case and improve code structure.

Signed-off-by: Antoni Baum <[email protected]>
tamohannes pushed a commit to ju2ez/ray that referenced this pull request Jan 25, 2023
BatchPredictor._determine_preprocessor_batch_format has a special case for Chain, where it obtains the first preprocessor contained within Chain in order to determine which transformation function to use for the dataset (as Chain doesn't implement any). However, with ray-project#29706 allowing for nested Chains, this check fails if the first preprocessor within a Chain is also a Chain.

This PR removes this special case from BatchPredictor and instead subclasses _determine_transform_to_use inside Chain itself, which allows us to both deal with the nested Chain case and improve code structure.

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

4 participants