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

Change runner logic to not create pool for sequential runner #4502

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

merelcht
Copy link
Member

@merelcht merelcht commented Feb 19, 2025

Description

Address #4486

Development notes

Verified that this fixes the issues mentioned in Galileo-Galilei/kedro-mlflow#624 and kedro-org/kedro-plugins#1012

Developer Certificate of Origin

We need all contributions to comply with the Developer Certificate of Origin (DCO). All commits must be signed off by including a Signed-off-by line in the commit message. See our wiki for guidance.

If your PR is blocked due to unsigned commits, then you must follow the instructions under "Rebase the branch" on the GitHub Checks page for your PR. This will retroactively add the sign-off to all unsigned commits and allow the DCO check to pass.

Checklist

  • Read the contributing guidelines
  • Signed off each commit with a Developer Certificate of Origin (DCO)
  • Opened this PR as a 'Draft Pull Request' if it is work-in-progress
  • Updated the documentation to reflect the code changes
  • Added a description of this change in the RELEASE.md file
  • Added tests to cover my changes
  • Checked if this change will affect Kedro-Viz, and if so, communicated that with the Viz team

@merelcht merelcht requested a review from Copilot February 19, 2025 13:53

Choose a reason for hiding this comment

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

@merelcht merelcht linked an issue Feb 19, 2025 that may be closed by this pull request
@merelcht merelcht self-assigned this Feb 19, 2025
Signed-off-by: Merel Theisen <[email protected]>
Copy link
Member

@DimedS DimedS left a comment

Choose a reason for hiding this comment

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

Thanks, @merelcht! That’s a more robust approach. One small question from my side

@merelcht merelcht requested a review from astrojuanlu February 20, 2025 13:05
@@ -226,7 +226,30 @@ def _run(
done = None
max_workers = self._get_required_workers_count(pipeline)

with self._get_executor(max_workers) as pool:
pool = self._get_executor(max_workers)
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks good to me from a logical point of view.

But I would suggest moving this into SequentialRunner._run. Otherwise, we modify the behaviour of the base class based on what is inherited from it, which is not entirely correct from the implementation point of view and AbstractRunner._run becomes too long. I understand that it will require some duplication, but in the SequentialRunner._run method, we can add a note explaining why we keep the implementation like that. But adding it to AbstractRunner._run will overload it even more.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't have a very strong opinion on this, but my counter argument is then wouldn't it be confusing that the thread and parallel logic is in the AbstractRunner._run method but sequential isn't?

Copy link
Member

Choose a reason for hiding this comment

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

I agree with Elena that, from a Pythonic perspective, common logic should be placed in _run() within the Abstract class. If there are exceptions, we should override the common logic with specific behavior, which is how runners worked previously. However, I thought the goal of the previous PR, which Merel is currently modifying, was to centralise the runner's logic within the Abstract class.

We had already decided that the _run() function in the abstract class would rely on _get_executor(), which would be implemented specifically in different subclasses. I don't see any issues with this approach. For me, the main question is how large and readable AbstractRunner._run() will be. As Merel pointed out, consolidating all the running logic in one place will be beneficial, which was also the intention of the previous PR.

@merelcht
Copy link
Member Author

I addressed @ElenaKhaustova 's comment about moving the sequential logic to the SequentialRunner in d6a247c . I personally don't have a huge preference for doing it that way or keeping it inside the abstract runner. They both have pros and cons. My main con for having sequential runner override the run method is only that it might be confusing that abstract runner has the logic for thread an parallel execution but not sequential, but arguably it's a bit cleaner.

@DimedS any thoughts?

Signed-off-by: Merel Theisen <[email protected]>
)
self._release_datasets(node, catalog, load_counts, pipeline)
pool = self._get_executor(max_workers)
if pool is not None:
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if it's related to what @merelcht is saying, but for the record I was skimming this code and thought "what if pool is None?" (there's no else branch here). Just a comment from the peanut gallery.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah exactly! I think it might not be immediately obvious that that logic is now inside SequentialRunner.

@DimedS
Copy link
Member

DimedS commented Feb 25, 2025

I addressed @ElenaKhaustova 's comment about moving the sequential logic to the SequentialRunner in d6a247c . I personally don't have a huge preference for doing it that way or keeping it inside the abstract runner. They both have pros and cons. My main con for having sequential runner override the run method is only that it might be confusing that abstract runner has the logic for thread an parallel execution but not sequential, but arguably it's a bit cleaner.

@DimedS any thoughts?

I agree, I also think that, given the current state, it would be beneficial to keep all the running logic in the Abstract class. I have provided a full comment in the thread: #4502 (comment).

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.

SequentialRunner might fail with non thread-safe code
4 participants