Skip to content

Conversation

@mscolnick
Copy link
Contributor

@mscolnick mscolnick commented Dec 23, 2025

Pull out more logic from the notifications schemas.

@vercel
Copy link

vercel bot commented Dec 23, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
marimo-docs Ready Ready Preview, Comment Dec 23, 2025 3:50pm

return_value: JSONType
status: HumanReadableStatus

def serialize(self) -> KernelMessage:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dead code

Copy link
Contributor Author

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

Copy link
Contributor

Copilot AI left a 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 in marimo/_messaging/variables.py
  • Removed unused serialize() method from FunctionCallResultNotification class
  • 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.

Comment on lines +189 to +191
except BaseException:
# Catch-all: some libraries like Polars have bugs and raise
# BaseExceptions, which shouldn't crash the kernel
Copy link

Copilot AI Dec 23, 2025

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
@mscolnick mscolnick merged commit c2aa7d4 into main Dec 23, 2025
47 of 65 checks passed
@mscolnick mscolnick deleted the ms/pull-out-variable-utils branch December 23, 2025 20:37
@Light2Dark Light2Dark added the internal A refactor or improvement that is not user facing label Jan 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal A refactor or improvement that is not user facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants