From 3d4e111ae9c3773d48a6748ae7ceb295d065daf4 Mon Sep 17 00:00:00 2001 From: Tim Huegerich Date: Tue, 8 Oct 2024 16:59:52 -0500 Subject: [PATCH 1/2] Add user_expressions echo --- echo_kernel/kernel.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/echo_kernel/kernel.py b/echo_kernel/kernel.py index eebb51d..130656f 100644 --- a/echo_kernel/kernel.py +++ b/echo_kernel/kernel.py @@ -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(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 @@ -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, } From b43eca00d4b9192cf60f5702ff22790091a31300 Mon Sep 17 00:00:00 2001 From: Tim Huegerich Date: Fri, 11 Oct 2024 21:33:20 -0500 Subject: [PATCH 2/2] Update kernel.py Add 'status' field to user_expressions result display_data --- echo_kernel/kernel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/echo_kernel/kernel.py b/echo_kernel/kernel.py index 130656f..c7b07e8 100644 --- a/echo_kernel/kernel.py +++ b/echo_kernel/kernel.py @@ -37,7 +37,7 @@ def do_execute(self, code, silent, store_history=True, user_expr_results = {} if user_expressions: for key, expression in user_expressions.items(): - user_expr_results[key] = dict(data={'text/plain': expression}, metadata={}) + 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