From 37ced55a294d80b480398f7ca64bf0601d696d17 Mon Sep 17 00:00:00 2001 From: Adam Thornton Date: Tue, 29 Oct 2024 10:04:40 -0700 Subject: [PATCH] Be more cautious about cell 'id' --- src/mobu/services/business/notebookrunner.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/mobu/services/business/notebookrunner.py b/src/mobu/services/business/notebookrunner.py index 335c2425..7b9aabb8 100644 --- a/src/mobu/services/business/notebookrunner.py +++ b/src/mobu/services/business/notebookrunner.py @@ -296,14 +296,13 @@ async def execute_code(self, session: JupyterLabSession) -> None: for cell in self.read_notebook(self._notebook): code = "".join(cell["source"]) - if "id" in cell: - cell_id = f'`{cell["id"]}` (#{cell["_index"]})' - else: - cell_id = f'#{cell["_index"]}' + cell_id = ( + cell.get("id") or cell["_index"] or "" + ) ctx = CodeContext( notebook=self._notebook.name, path=str(self._notebook), - cell=cell["id"], + cell=cell_id, cell_number=f"#{cell['_index']}", cell_source=code, )