jupyter-ai icon indicating copy to clipboard operation
jupyter-ai copied to clipboard

Investigate and optimize persona class loading storage strategy

Open dlqqq opened this issue 4 months ago • 0 comments
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

  1. 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
  2. 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

  1. Create test scenarios for dynamic entry point changes
  2. Research importlib_metadata behavior with runtime package changes
  3. Based on findings, implement the optimal storage strategy

dlqqq avatar Jun 27 '25 18:06 dlqqq