Skip to content

Conversation

@echarles
Copy link
Member

@echarles echarles commented Feb 8, 2026

No description provided.

Copilot AI review requested due to automatic review settings February 8, 2026 08:20
@echarles echarles changed the title Fix: insert variables Fix: insert variables error + default protocol Feb 8, 2026
Copy link
Member Author

@echarles echarles left a comment

Choose a reason for hiding this comment

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

LGTM

@echarles echarles merged commit acd334f into main Feb 8, 2026
11 of 13 checks passed
@echarles echarles deleted the feat/insert-variables branch February 8, 2026 08:21
Copy link

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 adjusts the WebSocket client defaults to use Jupyter Server’s default websocket protocol by default, and improves error handling when setting variables by surfacing a clearer serialization failure message.

Changes:

  • Switch default subprotocol from JupyterSubprotocol.V1 to JupyterSubprotocol.DEFAULT in WebSocket session/client constructors.
  • Wrap serialize_object(value) in KernelClient.set_variable() with a ValueError that includes additional context about non-serializable objects.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
jupyter_kernel_client/wsclient.py Changes default websocket subprotocol selection to DEFAULT.
jupyter_kernel_client/client.py Improves error reporting when variable serialization fails during set_variable().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

ping_interval: float = 60,
reconnect_interval: int = 0,
subprotocol: JupyterSubprotocol | None = JupyterSubprotocol.V1,
subprotocol: JupyterSubprotocol | None = JupyterSubprotocol.DEFAULT,
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

The subprotocol parameter is typed as optional (JupyterSubprotocol | None), but KernelWebSocketClient._on_message only handles DEFAULT and V1 and will raise ValueError("unsupported protocol.") for None. Consider normalizing None to JupyterSubprotocol.DEFAULT in __init__ (and/or removing | None from the type) so passing None doesn’t break message handling.

Copilot uses AI. Check for mistakes.
def __init__(self,
log: logging.Logger | None = None,
subprotocol: JupyterSubprotocol | None = JupyterSubprotocol.V1,
subprotocol: JupyterSubprotocol | None = JupyterSubprotocol.DEFAULT,
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

subprotocol is declared as JupyterSubprotocol | None, but downstream code (e.g., KernelWebSocketClient._on_message) doesn’t accept None. Either remove | None here or coerce None to JupyterSubprotocol.DEFAULT to keep the type contract consistent.

Copilot uses AI. Check for mistakes.
Comment on lines +475 to +479
try:
data, metadata = serialize_object(value)
except ValueError as e:
raise ValueError(
f"Cannot serialize variable '{name}': {e}. "
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

New behavior: set_variable now wraps serialization failures and raises a ValueError. Since the repo has pytest coverage for successful set_variable, please add a negative test that passes a clearly non-serializable value (e.g., an asyncio.Future() or a threading.Lock()) and asserts a ValueError mentioning the variable name, so this error path stays stable.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant