fix(ui): redirect pre-refactor CoSTEER module path so old demo_traces deserialise#1413
Open
genisis0x wants to merge 1 commit into
Open
fix(ui): redirect pre-refactor CoSTEER module path so old demo_traces deserialise#1413genisis0x wants to merge 1 commit into
genisis0x wants to merge 1 commit into
Conversation
… deserialise Closes microsoft#1331. The `demo_traces` archive linked from the README was pickled when the CoSTEER package lived at `rdagent.components.coder.factor_coder.CoSTEER`. After the refactor that relocated CoSTEER to `rdagent.components.coder.CoSTEER`, opening the old traces in `rdagent ui` fails with: ModuleNotFoundError: No module named 'rdagent.components.coder.factor_coder.CoSTEER' because pickle records the module path of every serialised class and the old path no longer exists. Maintainer guidance on the issue was to roll back to a legacy commit just to view the demo, which is a steep ask for a demo link. Install a `sys.meta_path` finder in `rdagent/components/coder/factor_coder/_costeer_compat.py` that transparently redirects imports under `rdagent.components.coder.factor_coder.CoSTEER[.*]` to the matching submodule under `rdagent.components.coder.CoSTEER[.*]`. The redirector is registered as the first thing `rdagent.components.coder.factor_coder.__init__` does, so any pickle loaded after `rdagent` is imported (which `rdagent ui` does at startup) can resolve the old path. The finder only matches that specific old prefix and falls through for every other import, so it cannot mask unrelated import errors. Submodules already imported under the new name are reused from `sys.modules`; uncached submodules are imported lazily via `importlib.import_module`. Adds `test/utils/coder/test_costeer_path_compat.py` covering: - the old package path resolves to the same module object as the new one - each of the relocated submodules (evaluators, evolving_strategy, knowledge_management, task, config) resolves identically - a pickle whose recorded `__module__` points at the old path round trips successfully after the old-path entries are dropped from `sys.modules` to simulate a fresh load
Author
|
Read the CLA — all clear from my side. @microsoft-github-policy-service agree |
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
Why this approach
Tests
`test/utils/coder/test_costeer_path_compat.py` covers:
Checklist
📚 Documentation preview 📚: https://RDAgent--1413.org.readthedocs.build/en/1413/