Install anywidget comm provider eagerly#10258
Merged
Merged
Conversation
Formatter hooks skip local modules to avoid mistaking user code for third-party packages. Editable installs look local too, so descriptor widgets could open a dummy comm before their formatter ran. These changes install the lightweight provider during formatter initialization while anywidget itself remains lazy. Refs MO-6824
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
No issues found across 4 files
Architecture diagram
sequenceDiagram
participant App as Marimo App
participant Formatters as Formatter Registry
participant AnywidgetForm as anywidget Formatter
participant CommProvider as Comm Provider
participant ImportHook as Import Hook
participant CommLib as comm Library
Note over App,CommLib: Formatter Initialization (register_formatters)
App->>Formatters: register_formatters()
Formatters->>CommProvider: install_anywidget_comm_provider()
alt anywidget/comm not installed
CommProvider-->>Formatters: return (no-op)
else modules available
CommProvider->>CommLib: Check if already patched
alt Not patched
CommProvider->>CommLib: Replace comm.create_comm with marimo wrapper
CommLib-->>CommProvider: Patched
else Already patched
CommProvider->>CommProvider: Skip (idempotent)
end
end
Note over Formatters,CommLib: Later: Import Hook Triggers
App->>ImportHook: Import anywidget module
ImportHook->>AnywidgetForm: Register formatter for AnyWidget class
Note over AnywidgetForm,CommLib: At this point, comm provider is already installed
Note over App,CommLib: Widget Instantiation (Descriptor-based anywidget)
App->>CommLib: Create comm (descriptor widget init)
alt anywidget comm (target="jupyter.widget", model_module="anywidget")
CommLib->>CommLib: Create marimo-backed comm
CommLib-->>App: MarimoComm instance
else non-anywidget comm
CommLib->>CommLib: Create DummyComm (no-op)
CommLib-->>App: DummyComm instance
end
Note over App,CommLib: Formatter Execution (for display)
App->>Formatters: Format widget for display
Formatters->>AnywidgetForm: Get HTML representation
AnywidgetForm-->>Formatters: MIME bundle
Formatters-->>App: Formatted output
mscolnick
approved these changes
Jul 21, 2026
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.
Formatter hooks skip local modules to avoid mistaking user code for third-party packages. Editable installs look local too, so descriptor widgets could open a dummy comm before their formatter ran.
These changes install the lightweight provider during formatter initialization while anywidget itself remains lazy.
Refs MO-6824