fix: Ensure orphaned sub-registries can resolve names after pickling#201
Merged
fix: Ensure orphaned sub-registries can resolve names after pickling#201
Conversation
…urn empty string so that resolving names for orphaned sub-registries works correctly after pickling Signed-off-by: Ryan Feuss <ryan.feuss@CubistSystematic.com>
Contributor
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #201 +/- ##
=======================================
Coverage 96.00% 96.00%
=======================================
Files 140 140
Lines 9827 9839 +12
Branches 569 568 -1
=======================================
+ Hits 9434 9446 +12
Misses 275 275
Partials 118 118 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ptomecek
approved these changes
Apr 25, 2026
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.
Summary
Fixes
get_registered_names()returning[]for models whose_registrationschain passes through a deserializedRootModelRegistry.get_registered_names()terminates the chain with[""]only whenself is ModelRegistry.root()— an identity check against the process-level singleton_REGISTRY_ROOT. When a model is pickled (e.g. sent to a Ray worker viaray.remote) and unpickled, theRootModelRegistrystored in the_registrationschain is deserialized as a new Python object. Theisidentity check fails, the chain falls through to[], and all model names are silently lost. Any evaluator logic keyed by model name is bypassed without error.What's included
RootModelRegistry.get_registered_names()[""]RootModelRegistryrather than patching the base-class identity check keeps the fix surgical: sub-registry resolution (_was_registered+ orphan branch) is untouchedWhy the existing
_was_registeredorphan branch does not cover this_was_registered=Trueand their chains survive pickling intact — the orphan branch short-circuits at the first orphaned node and never reaches the rootRootModelRegistryis created viamodel_construct(), so_was_registeredstaysFalseandnameis""(falsy); even with_was_registered=True, the orphan branch guardself._was_registered and self.namewould not fire for the root_was_registeredor the orphan branch is needed or madeWhat's NOT included
ModelRegistry.get_registered_names()— the base-class logic for live sub-registries and theinclude_orphanedpath is correct and unmodified_REGISTRY_ROOTconstruction or theModelRegistry.root()classmethod — the singleton pattern is preserved for all in-process usesTests
test_get_registered_names_survives_pickling(new,TestRegistry)/foo/bar/bazin a nested 3-level sub-registry chainpickle.dumps/pickle.loads, simulating Ray worker serialization of a standalone blobget_registered_names()still returns['/foo/bar/baz']on the deserialized instance