Skip to content

Read stored Zarr result pages, load 2D/3D results when shown - #2555

Merged
grzanka merged 5 commits into
masterfrom
szuk/yap-94-p-u2-ui-reads-stored-pages
Nov 19, 2026
Merged

grzanka merged 5 commits into
masterfrom
szuk/yap-94-p-u2-ui-reads-stored-pages

Conversation

@lythx

@lythx lythx commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Closes #2527

The UI side of storing result pages in object storage. It has no dependencies. It must be deployed before the backend's bucket is turned on. With today's backend, which sends every page inline, it changes only how 2D/3D pages load.

Docs: yaptide/for_developers#114 (results loading)

Changes

  • Stored pages (3e96f34):
    • A page the backend keeps in object storage comes as signed links (format: "zarr-v3", zarr.json and the shard c/0) instead of inline JSON.
    • storedPages.ts decodes the float32 values (zstd through fzstd, gzip through DecompressionStream, or raw; left-out chunks and a missing shard read as zeros) and rebuilds the page as the JSON pages had it.
    • Inline JSON pages work as before, also mixed with stored pages in one estimator. A stored page in any other format is rejected with a clear error.
  • 2D and 3D pages load when shown (6da41c2):
    • 0D and 1D pages load with their estimator. 2D maps and 3D volumes load when their place scrolls into view (LazyPageGroup), with one request per group.
    • An estimator of maps only still gets its tab.
    • CacheMap now rejects a failed fetch and drops the entry, so a retry fetches again.
  • Fixes found while testing on yap-dev:
    • e00342d: a group that failed to load while in view was requested again and again (59 requests in 15 s). Now it shows "Could not load the …" with a Load button.
    • fa198fb: opening a simulation again appended pages to the cached ones, so a tab showed the same plot several times and "Save to file" wrote a page up to 19 times. This also happens on master today.
    • e2848ce: no client timeout on /results. ky's 10 s default stopped a 1.6 MB 3D group on a slow link.

Tests

  • New unit tests: storedPages.test.ts (with the zarrPages.json fixture, written by the backend's result_format.py), lazyPages.test.ts, LazyPageGroup.test.tsx, CacheMap.test.ts, __tests__/RemoteWorkerSimulationService.test.ts. All 45 tests in src/services, src/util and Results pass.
  • The full suite has 10 Selenium failures in 5 suites. They fail the same way on master, because ChromeDriver doesn't match the installed Chrome.

Browser tests on yap-dev

Playwright (Chromium) against this branch, deployed on yap-dev with the current backend. 9 simulations: direct and batch, SHIELD-HIT12A and FLUKA, Jan–Nov 2026, one of them with 0D–3D pages.

Check Result
Before scrolling, only 0D/1D pages are requested; one request per 2D/3D group; none when revisiting a tab pass
Every page the UI got equals the backend's own /results (165 pages) pass
Estimator of maps only gets a tab and its maps pass
A failed 2D group shows "Could not load …" and the Load button, and loads after a click pass
Switching simulation while a 3D group loads: the other simulation never shows its pages pass
At 400 kbit/s the 1.6 MB 3D group loads (42 s, one request) pass
"Save to file": every page once, 2D/3D values included pass
Stored Zarr pages (written by the backend's writer, served by request mocks): zstd, gzip and raw equal the inline JSON within float32 (max. rel. error 6e-8); a shard 404 shows zeros; a zarr.json 403 shows the error and the Load button; inline and stored pages mixed in one estimator pass

The app already needs IntersectionObserver: the JSROOT canvas (react-hook-visible) creates one without checking, so without it a results page goes blank. That isn't changed here.

A performance pilot (5 runs each) showed no measurable difference against master, because none of the test simulations has an estimator that mixes lines with maps. The gain is for such estimators, whose maps below the lines load only when scrolled to.


Generated by Claude Code

lythx and others added 5 commits November 17, 2026 16:47
A result page may now come as a signed link to a Zarr array in object
storage instead of inline JSON. storedPages.ts fetches the array's
zarr.json and its shard c/0 (without credentials), decodes the float32
values (zstd through fzstd, gzip through DecompressionStream, or raw;
chunks left out of the shard read as zeros) and rebuilds the page as the
JSON pages had it. A page without a shard (404) reads as zeros.

Pages sent inline are used as before, so this works with backends that
do not store pages yet. A stored page in any other format is rejected
with a clear error: the backend stores pages only as Zarr.

Both /results requests (all pages, and pages of one estimator) go
through the reader.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SJ9KD58o1ZKVo3JhWp9UzY
An estimator now loads its 0D and 1D pages at once. Its 2D and 3D pages
load only when their place in the results scrolls into view
(LazyPageGroup, IntersectionObserver), with a Load button where the
browser cannot tell. Opening a depth-dose line no longer downloads the
maps and volumes next to it.

- lazyPages.ts splits an estimator's pages by dimension into eager and
  lazy groups; getFullSimulationData and EstimatorsSelect fetch only the
  eager ones.
- An estimator of 2D maps only still gets its tab, with no pages until
  shown.
- A group that fails to load gets its Load button back. CacheMap now
  rejects a failed fetch and drops the entry instead of leaving every
  caller waiting forever, so the retry fetches again.
- Pages loaded for one simulation are never written into another one
  shown meanwhile.
- Geant4 results computed in the browser are shown whole, as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SJ9KD58o1ZKVo3JhWp9UzY
…2527)

A group whose request failed while its place was in view was asked for
again and again (about 4 requests a second): the group objects are built
anew on every render, so LazyPageGroup observed its place again each
time, and a new observer reports a place in view at once.

- LazyPageGroup is observed again only when its pages change, and not
  while it loads or after a failed load.
- A failed group says so and shows the Load button; only the button
  tries again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SJ9KD58o1ZKVo3JhWp9UzY
…d again (#2527)

getFullSimulationData merged the pages of each dimension group into the
first group's estimator object, which is also the cached result of that
request. Each time a simulation was opened again its cached pages grew,
so its tab showed the same plots several times and "Save to file" wrote
a page up to 16 times. The merge now works on a copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SJ9KD58o1ZKVo3JhWp9UzY
…link (#2527)

ky gives up on a request after 10 s by default. A group of 2D or 3D pages
can take megabytes (1.6 MB for two 40x40x100 volumes), so on a slow link
(about 400 kbit/s) it never loaded and only failed with the Load button.
The result requests now wait as long as the server answers, as the
stored pages' links already do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lythx lythx self-assigned this Nov 18, 2026

@grzanka grzanka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@grzanka
grzanka added this pull request to the merge queue Nov 19, 2026
Merged via the queue into master with commit 47552e5 Nov 19, 2026
10 checks passed
@grzanka
grzanka deleted the szuk/yap-94-p-u2-ui-reads-stored-pages branch November 19, 2026 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P-U2] UI reads stored pages

2 participants