Skip to content

Commit 34d04bc

Browse files
committed
clean up docstrings
1 parent bd3b79c commit 34d04bc

3 files changed

Lines changed: 13 additions & 33 deletions

File tree

‎src/ansys/visor/viewer/models/persist/scene/persisted_scene_state.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ def _derive_missing_identity_fields_for_entry(key: Any, entry: Any) -> Any:
105105
if isinstance(entry, VisorVariableState) or not isinstance(entry, Mapping):
106106
return entry
107107

108-
# ``populate_by_name`` is set, so either spelling counts as present, and an
109-
# explicit null counts as present and is left to fail validation.
108+
# A value that is present but null counts as present and is left
109+
# to fail validation.
110110
missing = [
111111
field
112112
for field, alias in (

‎src/ansys/visor/viewer/vtk/scene/base.py‎

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -150,26 +150,13 @@ async def get_state(self, timeout: float) -> PersistedViewerStateV1:
150150
Capture the current viewer state and return it as a
151151
:class:`PersistedViewerStateV1`.
152152
153-
The frontend round trip (:meth:`_get_runtime_state_async`) remains the
154-
only source for everything the browser owns — UI panels, unit, the
155-
display toggles, camera, cross-section and the per-variable ranges.
156-
**Per-part state is not taken from it.** The dataset registry is the
157-
server-side authority for that, so ``scene.dataset_states`` is replaced
158-
wholesale with the registry's own runtime state before the persisted
159-
mapping runs. The browser is no longer consulted for per-part state.
160-
161-
The registry is read under ``_vtk_lock`` and each dataset state is
162-
deep-copied out of it. The registry hands out its live
163-
``RuntimeDatasetState`` objects by reference, and the per-part setters
164-
mutate the records they contain in place from the trame daemon thread;
165-
without the snapshot the persist mapper would be an unlocked reader of
166-
records that are being written concurrently. The lock is taken *after*
167-
the ``await`` has completed and released before the mapping, so it is
168-
never held across an ``await``. Named cost: this is the only place a
169-
coroutine acquires ``_vtk_lock``, so a save issued while a long
170-
main-thread VTK call holds the lock waits for that call. It cannot
171-
deadlock: the outbound bridge call made under the lock reaches
172-
``loop.call_later`` and returns without waiting on the event loop.
153+
The frontend round trip remains the only source for everything the browser owns.
154+
Per-part state is not: ``scene.dataset_states`` is replaced with the registry's
155+
own runtime state before the persisted mapping runs.
156+
157+
The registry hands out live ``RuntimeDatasetState`` objects that the per-part
158+
setters mutate from teh trame daemon thread, so each one is deep-copied under
159+
``_vtk_lock``. The lock is taken after the ``await`` and never held across one.
173160
"""
174161
runtime_state = await self._get_runtime_state_async(timeout)
175162

@@ -203,13 +190,8 @@ def apply_state(self, state: PersistedViewerStateV1):
203190
# Transform the frontend PersistedViewerStateV1 -> RuntimeAppState
204191
runtime_app_state = self._state_mapper.persisted_to_runtime(state)
205192

206-
# Restore per-part state server-side: write the registry, then apply
207-
# every part to this process's VTK pipeline. The browser is not
208-
# asked to do this, and is not trusted to have done it.
209193
self._restore_part_states_from_runtime(runtime_app_state)
210194

211-
# Renderer-specific: flush VTK window and notify frontend (wasm), or
212-
# push camera to vtkCamera (RCA), or no-op (headless).
213195
self._apply_runtime_state_to_render(runtime_app_state)
214196

215197
# Note: There is intentionally no wasm flush here: the bridge call is fire-and-forget, so a flush

‎src/ansys/visor/viewer/vtk/scene/visor_state_mapper.py‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,10 @@ def persisted_to_runtime(self, state: PersistedViewerStateV1) -> RuntimeAppState
7474
7575
Logic parity with ``VisorScene._persisted_to_runtime``.
7676
77-
This is **not**, and never has been, the registry-population path. It
78-
builds runtime dataset states and returns them on the RuntimeAppState;
79-
it never assigns its result back onto ``VisorDataset.state``, so no
80-
registry record is written by calling it.
81-
:meth:`VisorSceneBase._restore_part_states_from_runtime` now populates
82-
the registry explicitly, from the state this method returns.
77+
Returns the runtime dataset states on the ``RuntimeAppState``; it does not
78+
assign them to ``VisorDataset.state``. The registry is populated by
79+
:meth:`VisorSceneBase._restore_part_states_from_runtime`.
80+
8381
"""
8482
# UI settings
8583
ui_state = state.ui

0 commit comments

Comments
 (0)