Skip to content

Make run_on_main and main_process_only return the result to all proce…#2943

Merged
pplantinga merged 1 commit intospeechbrain:developfrom
rogiervd:run_on_main
Jul 9, 2025
Merged

Make run_on_main and main_process_only return the result to all proce…#2943
pplantinga merged 1 commit intospeechbrain:developfrom
rogiervd:run_on_main

Conversation

@rogiervd
Copy link
Copy Markdown
Contributor

@rogiervd rogiervd commented Jul 9, 2025

What does this PR do?

This changes run_on_main and main_process_only to allow the function that is run on one process to return a value.
This value is returned on all processes. There is a new test to check this.

I am using this behaviour in internal code. (To be honest, initially I assumed this behaviour would be already there.)

In theory, this is a breaking change. But I believe that in the current codebase, run_on_main and main_process_only are only used on functions that return None. This would be a breaking change where both these conditions are met:

  • the function to be called returns something else than None;
  • and the caller relies on None being returned instead of whatever the function returns.

It seems unlikely that both of these are true in any current code.

Before submitting
  • Did you read the contributor guideline?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you list all the breaking changes introduced by this pull request?
  • Does your code adhere to project-specific code style and conventions?

PR review

Reviewer checklist
  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified
  • Confirm that the changes adhere to compatibility requirements (e.g., Python version, platform)
  • Review the self-review checklist to ensure the code is ready for review

@TParcollet TParcollet requested a review from pplantinga July 9, 2025 13:32
Copy link
Copy Markdown
Collaborator

@pplantinga pplantinga left a comment

Choose a reason for hiding this comment

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

LGTM - returning the result from these functions is a natural extension, just one we haven't needed until now.

@pplantinga pplantinga merged commit 2eb47df into speechbrain:develop Jul 9, 2025
5 checks passed
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.

2 participants