Skip to content

Commit

Permalink
Merge pull request #377 from lsst-sqre/tickets/DM-46480
Browse files Browse the repository at this point in the history
Be more cautious about cell 'id'
  • Loading branch information
athornton authored Oct 29, 2024
2 parents dfde0c6 + cd42cf3 commit 5bf0700
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# - Runs a non-root user.
# - Sets up the entrypoint and port.

FROM python:3.12.7-slim-bookworm as base-image
FROM python:3.12.7-slim-bookworm AS base-image

# Update system packages
COPY scripts/install-base-packages.sh .
Expand Down
5 changes: 5 additions & 0 deletions changelog.d/20241029_105636_athornton_DM_46480.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!-- Delete the sections that don't apply -->

### Bug fixes

- cell["id"] is not always set: be more cautious
7 changes: 2 additions & 5 deletions src/mobu/services/business/notebookrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,14 +296,11 @@ 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"]
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 5bf0700

Please sign in to comment.