From ef61a1515f9652785a3717bcc62d3c2c5ad8b4f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tito=20Grin=C3=A9?= Date: Sat, 19 Aug 2023 18:07:42 +0100 Subject: [PATCH] Update nb-check to not clear SQL cell metadata. --- resources/nb-check.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/resources/nb-check.py b/resources/nb-check.py index 6a1f7e6..71df60d 100755 --- a/resources/nb-check.py +++ b/resources/nb-check.py @@ -123,7 +123,13 @@ def new_markdown_cell(cell_id: str, content: str) -> dict[str, Any]: # Clear out execution metadata and cell output for cell in cells: if 'metadata' in cell: - cell['metadata'] = {} + clean_metadata = {} + if 'language' in cell['metadata']: + clean_metadata['language'] = cell['metadata']['language'] + if 'output_variable' in cell['metadata']: + clean_metadata['output_variable'] = cell['metadata']['output_variable'] + + cell['metadata'] = clean_metadata if 'outputs' in cell: cell['outputs'] = [] if 'execution_count' in cell: