-
Notifications
You must be signed in to change notification settings - Fork 7k
[Data] Refactor PhysicalOperator.completed to fix side effects
#58915
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] Refactor PhysicalOperator.completed to fix side effects
#58915
Conversation
…n_finished() to has_execution_finished(). Make has_execution_finished() and complete() pure functions to remove side effects. Signed-off-by: Simeet Nayan <simeetnayan.8100@gmail.com>
bveeramani
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
High-level change LGTM.
I think you'll need update references to execution_finished with has_execution_finished.
Would you mind renaming completed to has_completed to make it clear that the method doesn't modify state, and also ensure that this PR passes the microcheck status check?
…nished in limit_operator Signed-off-by: Simeet Nayan <simeetnayan.8100@gmail.com>
…nished in test_operators.py Signed-off-by: Simeet Nayan <simeetnayan.8100@gmail.com>
Signed-off-by: Simeet Nayan <simeetnayan.8100@gmail.com>
|
Sure thing @bveeramani. Will do the changes. |
python/ray/data/_internal/execution/operators/limit_operator.py
Outdated
Show resolved
Hide resolved
bveeramani
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM
python/ray/data/_internal/execution/operators/limit_operator.py
Outdated
Show resolved
Hide resolved
… has_execution_finished() Signed-off-by: Simeet Nayan <simeetnayan.8100@gmail.com>
…refactor-PhysicalOperator Signed-off-by: Simeet Nayan <simeetnayan.8100@gmail.com>
Can I take this in a follow-up pr? Regarding the test failing, it's related to test_stats::test_large_args_scheduling_strategy, particularly at |
Yeah, ofc. |
PhysicalOperator.completed to fix side effects
…-project#58915) # Description This PR refactors the `PhysicalOperator` class to eliminate hidden side effects in the `completed()` method. Previously, calling `completed()` could inadvertently modify the internal state of the operator, which could lead to unexpected behavior. This change separates the logic for checking if the operator is marked as finished from the logic that computes whether it is actually finished. Key changes include: - Renaming `_execution_finished` to `_is_execution_marked_finished` to clarify its purpose. - Renaming `execution_finished()` to `has_execution_finished()` and making it a pure computed property without side effects. - Updating the `completed()` method to call `has_execution_finished()` instead of modifying internal state. - Ensuring that `mark_execution_finished()` correctly sets the renamed field. ## Related issues Fixes ray-project#58884 ## Additional information This refactor ensures that both `has_execution_finished()` and `completed()` are pure query methods, allowing them to be called multiple times without altering the state of the operator. T --------- Signed-off-by: Simeet Nayan <simeetnayan.8100@gmail.com> Co-authored-by: Balaji Veeramani <balaji@anyscale.com>
Description
This PR refactors the
PhysicalOperatorclass to eliminate hidden side effects in thecompleted()method. Previously, callingcompleted()could inadvertently modify the internal state of the operator, which could lead to unexpected behavior. This change separates the logic for checking if the operator is marked as finished from the logic that computes whether it is actually finished.Key changes include:
_execution_finishedto_is_execution_marked_finishedto clarify its purpose.execution_finished()tohas_execution_finished()and making it a pure computed property without side effects.completed()method to callhas_execution_finished()instead of modifying internal state.mark_execution_finished()correctly sets the renamed field.Related issues
Fixes #58884
Additional information
This refactor ensures that both
has_execution_finished()andcompleted()are pure query methods, allowing them to be called multiple times without altering the state of the operator. T