Allow Distributed.get_instance() without context for single-rank#1070
Merged
Conversation
Previously, get_instance() raised RuntimeError when called outside Distributed.context() regardless of the number of ranks. This made it impossible to use in single-rank environments like Jupyter notebooks where there is no need for the distributed context manager. Now the error is only raised when world_size > 1, where the context manager is actually needed to ensure proper initialization and shutdown. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
oliverwm1
approved these changes
Apr 21, 2026
Collaborator
oliverwm1
left a comment
There was a problem hiding this comment.
Update the PR description to link the existing open issue before merging. Otherwise looks good.
2 tasks
2 tasks
jpdunc23
added a commit
that referenced
this pull request
Apr 30, 2026
Removes `scripts/test_distributed_context.py` since this check is no longer necessary given changes in #1070. - [ ] Tests added - [ ] If dependencies changed, "deps only" image rebuilt and "latest_deps_only_image.txt" file updated
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Single-rank environments like Jupyter notebooks previously could not call
Distributed.get_instance()without wrapping code inDistributed.context(), even though the context manager is only needed for multi-rank distributed shutdown coordination.Changes:
fme.core.distributed.Distributed.get_instance: moved the_enteredcheck to after singleton creation and only raises whenworld_size > 1Tests added
Fixes #1049