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

Add user_expressions echo #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
8 changes: 7 additions & 1 deletion echo_kernel/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ def do_execute(self, code, silent, store_history=True,
stream_content = {'name': 'stdout', 'text': code}
self.send_response(self.iopub_socket, 'stream', stream_content)

# Quarto executes inline code via user_expressions
user_expr_results = {}
if user_expressions:
for key, expression in user_expressions.items():
user_expr_results[key] = dict(status='ok', data={'text/plain': expression}, metadata={})

# in this example, we are using a very simple way to
# detect if a cell is a setup cell. In a real kernel, you
# would want to use a more robust method to detect setup cells
Expand All @@ -53,5 +59,5 @@ def do_execute(self, code, silent, store_history=True,
# The base class increments the execution count
'execution_count': self.execution_count,
'payload': [],
'user_expressions': {},
'user_expressions': user_expr_results,
}