Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| self.port: int = port | ||
| self.context_modules: list[str] = context_modules | ||
| self.context_modules: set[str] = context_modules | ||
| self.registered_modules: set[str] = set() |
There was a problem hiding this comment.
we cache registered_modules in D3SessionBase so we can register module on demand in lazy manner.
There was a problem hiding this comment.
What's the difference between context_modules and registered_modules?
There was a problem hiding this comment.
context_modules is modules that will get registered when entering context.
register_module is modules that is actually registered by the session.
Summary
D3SessionandD3AsyncSession: modules decorated with@d3functionare now registered on first use insideexecute()/rpc(), rather than requiring upfront declaration incontext_modules.registered_modulesset on the session base class, preventing duplicate registration calls.context_modulesparameter type fromlist[str]toset[str]for correct deduplication semantics.Before
After
Motivation
Previously, callers had to know and list every module they intended to use when constructing a session. With lazy registration, modules are registered transparently on demand, reducing boilerplate and avoiding unnecessary network calls for modules that may not be used in a given session.
Changes
session.pyD3SessionBase: addedregistered_modules: set[str];execute()on both sync and async sessions now lazily registers unknown modules;register_module()records successfully registered modulesCHANGELOG.mdregistered_modulesentries to[1.3.0]README.mdcontext_modulesfrom Functional API examples; updated prose to describe lazy registration behaviour