Skip to content

Commit

Permalink
Be more cautious about cell 'id'
Browse files Browse the repository at this point in the history
  • Loading branch information
athornton committed Oct 29, 2024
1 parent 3581f69 commit 37ced55
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/mobu/services/business/notebookrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<unknown cell ID>"
)
ctx = CodeContext(
notebook=self._notebook.name,
path=str(self._notebook),
cell=cell["id"],
cell=cell_id,
cell_number=f"#{cell['_index']}",
cell_source=code,
)
Expand Down

0 comments on commit 37ced55

Please sign in to comment.