Skip to content

fix(ui): redirect pre-refactor CoSTEER module path so old demo_traces deserialise#1413

Open
genisis0x wants to merge 1 commit into
microsoft:mainfrom
genisis0x:fix/1331-demo-traces-module-path
Open

fix(ui): redirect pre-refactor CoSTEER module path so old demo_traces deserialise#1413
genisis0x wants to merge 1 commit into
microsoft:mainfrom
genisis0x:fix/1331-demo-traces-module-path

Conversation

@genisis0x
Copy link
Copy Markdown

@genisis0x genisis0x commented May 13, 2026

Summary

  • Closes ModuleNotFoundError : No module named 'rdagent.components.coder.factor_coder.CoSTEER'' #1331. The `demo_traces` archive linked from the README was pickled when CoSTEER lived at `rdagent.components.coder.factor_coder.CoSTEER`. After the refactor relocated it to `rdagent.components.coder.CoSTEER`, opening those traces in `rdagent ui` fails with `ModuleNotFoundError: No module named 'rdagent.components.coder.factor_coder.CoSTEER'`. Current maintainer guidance is to roll back to a legacy commit just to view the demo, which is a steep ask for a feature the README advertises front and center.
  • 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.

Why this approach

  • A meta-path finder is the smallest possible change that handles every submodule the old pickles might reference, including ones we haven't touched yet, without needing stub `.py` files mirroring the entire pre-refactor tree.
  • The finder only matches the specific old prefix and falls through for every other import, so it cannot mask unrelated `ModuleNotFoundError`s.
  • Already-imported submodules are reused from `sys.modules`; uncached submodules are imported lazily via `importlib.import_module`.

Tests

`test/utils/coder/test_costeer_path_compat.py` covers:

  • 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 process

Checklist

  • Issue linked
  • Tests added
  • No behavioural change for users who already imported via the new path
  • CLA will be confirmed in a follow-up comment

📚 Documentation preview 📚: https://RDAgent--1413.org.readthedocs.build/en/1413/

… 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
@genisis0x
Copy link
Copy Markdown
Author

Read the CLA — all clear from my side.

@microsoft-github-policy-service agree

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.

ModuleNotFoundError : No module named 'rdagent.components.coder.factor_coder.CoSTEER''

1 participant