Skip to content

Conversation

@simeetnayan81
Copy link
Contributor

@simeetnayan81 simeetnayan81 commented Nov 22, 2025

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 #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

…n_finished() to has_execution_finished(). Make has_execution_finished() and complete() pure functions to remove side effects.

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

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?

@simeetnayan81 simeetnayan81 marked this pull request as ready for review November 23, 2025 16:18
@simeetnayan81 simeetnayan81 requested a review from a team as a code owner November 23, 2025 16:18
@simeetnayan81
Copy link
Contributor Author

Sure thing @bveeramani. Will do the changes.

@ray-gardener ray-gardener bot added data Ray Data-related issues community-contribution Contributed by the community labels Nov 23, 2025
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.

Overall LGTM

@simeetnayan81
Copy link
Contributor Author

simeetnayan81 commented Nov 24, 2025

@bveeramani

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?

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 task_submission_backpressure_time coming as N while expected is Z.
This seems to be related to performance, although we have just refactored some functions.

@bveeramani
Copy link
Member

Can I take this in a follow-up pr?

Yeah, ofc.

@bveeramani bveeramani added the go add ONLY when ready to merge, run all tests label Nov 24, 2025
@bveeramani bveeramani self-assigned this Nov 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Contributed by the community data Ray Data-related issues go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Data] Refactor PhysicalOperator.completed to avoid hidden side effect

2 participants