Skip to content

Commit

Permalink
fix: remove unexpected completed-run messages (#122)
Browse files Browse the repository at this point in the history
Kernel was sending completed-run when frontend hadn't registered a new
run. This sent runningCount < 0 in the frontend, causing UI updates to be
sent when they should have been buffered.

This is just a fix to hold us over to when we merge UI updates
in the kernel ...
  • Loading branch information
akshayka authored Sep 18, 2023
1 parent 636a2e4 commit 4d0b35a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion frontend/src/core/RuntimeState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ export class RuntimeState {
}

registerRunEnd(): void {
this.runningCount -= 1;
// Threshold runningCount to 0 for resiliency. Won't be needed once
// we merge UI component updates in Python
this.runningCount = Math.max(this.runningCount - 1, 0);
}

running(): boolean {
Expand Down
5 changes: 3 additions & 2 deletions marimo/_runtime/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,6 @@ def _run_cells(self, cell_ids: set[CellId_t]) -> None:
self.graph, cells_with_stale_state
)
LOGGER.debug("Finished run.")
write_completed_run()

def _run_cells_internal(self, cell_ids: set[CellId_t]) -> set[CellId_t]:
"""Run cells, send outputs to frontends
Expand Down Expand Up @@ -870,7 +869,6 @@ def instantiate(self, request: CreationRequest) -> None:
if self.graph.cells:
del request
LOGGER.debug("App already instantiated.")
write_completed_run()
else:
self.reset_ui_initializers()
for (
Expand Down Expand Up @@ -957,12 +955,15 @@ def interrupt_handler(signum: int, frame: Any) -> None:
LOGGER.debug("received request %s", request)
if isinstance(request, CreationRequest):
kernel.instantiate(request)
write_completed_run()
elif isinstance(request, ExecuteMultipleRequest):
kernel.run(request.execution_requests)
write_completed_run()
elif isinstance(request, SetCellConfigRequest):
kernel.set_cell_config(request)
elif isinstance(request, SetUIElementValueRequest):
kernel.set_ui_element_value(request)
write_completed_run()
elif isinstance(request, DeleteRequest):
kernel.delete(request)
elif isinstance(request, CompletionRequest):
Expand Down
1 change: 1 addition & 0 deletions marimo/_tutorials/intro.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Copyright 2023 Marimo. All rights reserved.
import marimo

__generated_with = "0.1.8"
Expand Down

1 comment on commit 4d0b35a

@vercel
Copy link

@vercel vercel bot commented on 4d0b35a Sep 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

marimo-storybook – ./frontend

marimo-storybook-git-main-marimo.vercel.app
marimo-storybook.vercel.app
marimo-storybook-marimo.vercel.app

Please sign in to comment.