jupyter-ai
jupyter-ai copied to clipboard
Investigate and optimize persona class loading storage strategy
trafficstars
Summary
Currently, persona classes loaded from entry points are stored as an instance attribute (_persona_classes) in PersonaManager. We need to investigate whether entry points can change at runtime and optimize the storage strategy accordingly.
Background
In PR #1380, _persona_classes was converted from a class attribute to an instance attribute to support loading local personas from the .jupyter directory. The original assumption was that entry points are immutable at runtime, but @ellisonbg noted that entry points may change at runtime.
Investigation Needed
-
Verify entry point behavior: Determine if entry points can actually change during server runtime
- Test dynamic installation/uninstallation of packages with entry points
- Check if
importlib_metadata.entry_points()reflects runtime changes - Document the expected behavior
-
Optimize storage strategy based on findings:
- If entry points are truly immutable at runtime: Store them in a class attribute for better performance
- If entry points can change: Keep current approach or implement a hybrid solution with cache invalidation
Proposed Investigation
- Create test scenarios for dynamic entry point changes
- Research importlib_metadata behavior with runtime package changes
- Based on findings, implement the optimal storage strategy