Skip to content
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

DM-39360: Also ignore execute_result messages #266

Merged
merged 1 commit into from
May 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/mobu/storage/jupyter.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,21 @@ class JupyterLabSession:
Logger to use.
"""

_IGNORED_MESSAGE_TYPES = (
"display_data",
"execute_input",
"execute_result",
"status",
)
"""WebSocket messge types ignored by the parser.

Jupyter labs send a lot of types of WebSocket messages to provide status
or display formatted results. For our purposes, we only care about output
and errors, but we want to warn about unrecognized messages so that we
notice places where we may be missing part of the protocol. These are
message types that we know we don't care about and should ignore.
"""

def __init__(
self,
*,
Expand Down Expand Up @@ -402,7 +417,7 @@ def _parse_message(

# Analyse the message type to figure out what to do with the response.
msg_type = data["msg_type"]
if msg_type in ("display_data", "execute_input", "status"):
if msg_type in self._IGNORED_MESSAGE_TYPES:
return None
elif msg_type == "stream":
return JupyterOutput(content=data["content"]["text"])
Expand Down