Skip to content

Commit

Permalink
fix: wait until server ready before enabling auto rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
annehaley authored and johnkit committed Apr 30, 2024
1 parent 954969f commit e02d159
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 1 addition & 3 deletions examples/jupyter/pangeo_forge.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "b0844d55",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -33,8 +33,6 @@
"builder = DatasetBuilder()\n",
"builder.import_config(config)\n",
"\n",
"# TODO: awaiting viewer should not await auto render\n",
"\n",
"# Show viewer in cell output\n",
"await builder.viewer.ready\n",
"builder.viewer.ui"
Expand Down
7 changes: 6 additions & 1 deletion pan3d/dataset_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def __init__(
self.plot_view = None
self.actor = None
self.ctrl.get_plotter = lambda: self.plotter
self.ctrl.on_client_connected.add(self.on_ready)

self.state.update(initial_state)
self.state.ready()
Expand All @@ -80,6 +81,10 @@ def __init__(
def start(self, **kwargs):
self.ui.server.start(**kwargs)

def on_ready(self, **kwargs):
self.state.render_auto = True
self._mesh_changed()

@property
async def ready(self) -> None:
await self.ui.ready
Expand Down Expand Up @@ -235,7 +240,7 @@ async def plot_mesh(self) -> None:
self.state.ui_loading = True
self.state.ui_unapplied_changes = False

await asyncio.sleep(0)
await asyncio.sleep(1)

with self.state:
self.plotter.clear()
Expand Down
2 changes: 1 addition & 1 deletion pan3d/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def has_gpu_rendering():
"ui_action_message": None,
"ui_action_config_file": None,
"ui_current_time_string": "",
"render_auto": True,
"render_auto": False,
"render_x_scale": 1,
"render_y_scale": 1,
"render_z_scale": 1,
Expand Down

0 comments on commit e02d159

Please sign in to comment.