-
Notifications
You must be signed in to change notification settings - Fork 860
refactor: pull out variable logic from notification schemas #7596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| return_value: JSONType | ||
| status: HumanReadableStatus | ||
|
|
||
| def serialize(self) -> KernelMessage: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dead code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @manzt - i think we removed the class level serialize on the base Op class (now notification) so this may have been regressed. i havent seen issues of unable to deserialize function requests, but in case there is, its likely missing this catch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors variable-related logic by extracting it from the notification schema module into a dedicated variables module, improving separation of concerns and maintainability.
Key changes:
- Extracted
VariableValue.create()static method and helper methods to standalone functions inmarimo/_messaging/variables.py - Removed unused
serialize()method fromFunctionCallResultNotificationclass - Added comprehensive test coverage for the newly extracted functions
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
marimo/_messaging/notification.py |
Removed VariableValue.create() static method and helpers (_stringify_static, _format_value_static), removed FunctionCallResultNotification.serialize() method, cleaned up unnecessary imports |
marimo/_messaging/variables.py |
Added new functions create_variable_value(), _stringify_variable_value(), and _format_variable_value() with equivalent logic to the removed static methods |
marimo/_runtime/runtime.py |
Updated to use create_variable_value() instead of VariableValue.create() |
marimo/_runtime/runner/hooks_post_execution.py |
Updated to use create_variable_value() instead of VariableValue.create(), updated imports |
tests/_server/session/test_session_view.py |
Updated test to use create_variable_value() instead of VariableValue.create(), added import for serialize_kernel_message and create_variable_value |
tests/_messaging/test_notifications.py |
Updated tests to use create_variable_value() instead of VariableValue.create() |
tests/_messaging/test_variables.py |
Added comprehensive test coverage for the new functions with 31 new test cases covering various edge cases and data types |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| except BaseException: | ||
| # Catch-all: some libraries like Polars have bugs and raise | ||
| # BaseExceptions, which shouldn't crash the kernel |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except block directly handles BaseException.
| except BaseException: | |
| # Catch-all: some libraries like Polars have bugs and raise | |
| # BaseExceptions, which shouldn't crash the kernel | |
| except BaseException as exc: | |
| # Catch-all: some libraries like Polars have bugs and raise | |
| # BaseExceptions, which shouldn't crash the kernel. However, | |
| # we must not swallow critical control-flow exceptions. | |
| if isinstance(exc, (KeyboardInterrupt, SystemExit, GeneratorExit)): | |
| raise |
Pull out more logic from the notifications schemas.