fix(render): record the remote source so --remote-url can be omitted - #1797
Open
CVasilopoulos wants to merge 1 commit into
Open
CVasilopoulos wants to merge 1 commit into
CVasilopoulos wants to merge 1 commit into
Conversation
The --remote-url help said the flag is optional once the --volume directory records the remote source. vc_render_tifxyz reads that record from <volume>/.remote_source.json in loadCachedRemoteUrl(), but nothing wrote the file. So --remote-url could never be omitted, and -v could not stand in for it on the remote path. ScrollPrize#781 added the reader, a writer and the help wording. ScrollPrize#844 removed the writer together with the staged cache in volume-cartographer/core/src/cache/HttpMetadataFetcher.cpp and left the reader behind. ScrollPrize#1657 moved remote renders onto Volume::NewFromUrl and the shared persistent remote cache, and kept the wording. Reported by Matteo Bulloni (@Bullo27) in ScrollPrize#1555, who also proposed writing the marker in the ScrollPrize#1656 review. saveRemoteSourceMarker() writes {"url": ...} right after the remote volume opens and the requested level is found. Chunks stay in the shared remote cache, so the marker adds no cache location. Auth is not stored and still comes from the environment on every run. It returns without writing when: - --volume contains "://". VC3D passes the remote locator as both --volume and --remote-url, and the URL would otherwise be created as a relative directory tree in the working directory. - the URL contains '?'. The remote file cache removes query strings before persisting a source because they may carry signed credentials (volume-cartographer/docs/remote_file_cache.md), and the marker is plain text. - the marker already holds the same URL, so repeat renders do not rewrite it. - --volume already holds a local zarr (.zgroup, .zarray, zarr.json or 0). The marker is read before the local path is chosen, so a marker there would make a later run without --remote-url stream the remote volume instead of reading the local one. This case logs a warning. Failing to create the directory or write the file is a warning, not an error, because the render does not depend on the marker. The stream is checked after close so a failed flush is not logged as recorded. The --remote-url help now says fetched chunks persist under the shared remote cache root, not under --volume, and that the URL is recorded once the remote volume opens (not when --volume is a URL or a local zarr). A render can still fail after that point, and the URL stays recorded. The -v help says the directory can still supply the voxel size (meta.json/metadata.json) and records the remote source so later runs can omit --remote-url. Fixes ScrollPrize#1555
|
@CVasilopoulos is attempting to deploy a commit to the scroll Team on Vercel. A member of the Team first needs to authorize it. |
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In one sentence: After one remote render, you can rerun
vc_render_tifxyzwith the same-vdirectory and leave out--remote-url, as its help text already said.One real example: I took a 30 x 30 cell window of PHercParis4 segment
20231007101619and the published PHercParis4 45.532um volume on S3. I rendered once with-v <dir> --remote-url <url>, then again with only-v <dir>. The second run read the shared remote cache and wrote a byte-identical00.tif.Before: The first render works but never creates
<dir>. The second render exits 1 withError opening local zarr, because nothing writes<dir>/.remote_source.json.--remote-urlcan never be omitted, and-vcannot stand in for it on the remote path.After this PR: The first render writes
<dir>/.remote_source.jsonwith the URL. The second render picks it up, exits 0 and produces the same image from the persisted chunks.Proof: Upstream main
d9d70bef1against this branch on the same base, with the same segment window, volume and flags. The two renders of each build share one freshHOME. The shared remote cache starts empty for render 1, and render 2 can use what render 1 fetched.The attached images show the terminal output of these runs, rendered from the evidence script's log. Look at step 2 first: main exits 1 with
Error opening local zarr, and this branch exits 0 afterDetected cached remote source. In the blocks below, output is trimmed to the relevant lines. Lines starting with#are my notes on exit codes and files, not program output.<flags>is-s <segment> --scale 1 -g 0 -n 1 --cache-gb 2 --voxel-size 45.532 --tif-output <out>.--remote-urlBefore (main):
After (this PR):
-v, no--remote-urlBefore (main):
After (this PR):
In the attached run, render 2 took 15 s and render 1 took 45 s cold. Cold times depend on S3, so this is not a speed-up from this patch. Main already persists chunks when
--remote-urlis given. The point is that the run without--remote-urlnow works and reads that cache.--volumeand--remote-url-valready holds a local zarrBefore (main):
After (this PR):
Why / where this is useful:
I picked this up because the
--remote-urlhelp says the flag can be left out after the first render, and that never worked. I ran both renders on the published PHercParis4 volume from S3 and checked that the second run without--remote-urlnow works and writes the same image as the first.After one render with
--remote-url, reruns on the same volume only need-v. The--remote-urlhelp is accurate again for URLs without a query string, which is what #1555 reported. VC3D renders behave the same as before.Details
History
e81cf1420, 2026-03-06) addedloadCachedRemoteUrl(), a writer and the "(optional if --volume cache already records it)" wording.557766a1b, 2026-05-03) removed the writer together with the staged cache (volume-cartographer/core/src/cache/HttpMetadataFetcher.cpp). The reader stayed.38c2b4278, merged 2026-09-14) carried the commits of fix(render): persist remote chunks in the -v cache #1656. Remote renders now open throughVolume::NewFromUrland use the shared persistent remote cache (default$HOME/.VC3D/remote_cache, orremote_cache_dirunder[viewer]inVC3D.ini). It kept the wording. fix(render): persist remote chunks in the -v cache #1656 itself merged as an empty commit (bfef6abe0)..remote_source.jsonwas only ever read, never written, and proposed writing it. @hendrikschilling asked to use the existing remote-volume cache infrastructure instead of another cache location.This PR takes the writer option on top of that infrastructure, following @Bullo27's proposal. The marker holds only the URL. Chunks stay in the shared remote cache, and nothing is cached under
-v. Auth is not stored. It still comes from the environment (vc::HttpAuth::from_env()) on every run.What changed
One file:
volume-cartographer/apps/src/vc_render_tifxyz.cpp.saveRemoteSourceMarker(vol_path, remoteUrl)runs right after the remote volume opens and the requested level is found. It creates the directory, writes{"url": ...}withutils::Json, checks the stream after close and logsRecorded remote source in <path>.--remote-urlhelp now says fetched chunks persist under the shared remote cache root, not under--volume. It says the URL is recorded in<volume>/.remote_source.jsononce the remote volume opens (not when--volumeis a URL or a local zarr), and that the flag can be omitted after that.-vhelp now says that with--remote-urlthe directory can still supply the voxel size (meta.json/metadata.json), and that it records the remote source so later runs can omit--remote-url.When it does not write
--volumecontains://--volumeand--remote-url(volume-cartographer/apps/VC3D/SegmentationCommandHandler.cpp,volume-cartographer/apps/VC3D/CommandLineToolRunner.cpp). Without this, the URL would be created as a relative directory tree in the working directory.?volume-cartographer/docs/remote_file_cache.mdsays the remote file cache removes query strings and fragments before persistence, because they may contain signed credentials. The marker is plain text, so it skips any URL with a query string.--volumeholds.zgroup,.zarray,zarr.jsonor0--remote-urlstream the remote volume instead of reading the local zarr. Logs a warning.Any failure to create the directory or write the file is logged as a warning. The render continues, because it does not depend on the marker.
The zarr check runs only when writing. If a local zarr is later copied into a directory that already has the marker, a run without
--remote-urlstill streams the remote volume and logsDetected cached remote source: <url>. Removing.remote_source.jsonrestores the local read.Tested
d9d70bef1. The branch was then rebased onto4b3c72882, wherevc_render_tifxyz.cppis byte-identical. Cmake presetci-release-gcc, inghcr.io/scrollprize/villa/volume-cartographer:builder-ubuntu-26.04.PHercParis4/segments/20231007101619/mesh/20231007101619-on-20260310170716-45.532um.tifxyz, cut to a 30 x 30 cell window. The window is the 30 x 30 block of the grid with the most valid points. It was copied out ofx.tif,y.tifandz.tifinto a new tifxyz folder, withmeta.jsoncopied and itsbboxrecomputed.https://vesuvius-challenge-open-data.s3.us-east-1.amazonaws.com/PHercParis4/volumes/20260310170716-45.532um-11.0m-74keV-masked.zarrvc_render_tifxyz -v <dir> [--remote-url <url>] -s <segment> --scale 1 -g 0 -n 1 --cache-gb 2 --voxel-size 45.532 --tif-output <out>Open PRs that touch this
-vas a directory that "stays empty" and chunks as "cached in RAM only". Since fix(render): avoid prefetching unused chunks #1657, chunks persist in the shared remote cache. With this PR,-valso gets.remote_source.json. That bullet may want an update. I can leave a note there.EXIT_FAILUREfor surfaces outside the volume. A render that fails that check will still have recorded the URL, because the volume did open. That is why the help says "once the remote volume opens".git applyof their old help-string context fails. A 3-way merge with this PR is clean in either order.Alternative
If you would rather not have the marker at all, the other option from #1555 is to delete the reader. That means removing
loadCachedRemoteUrl(), its fallback inmain(), the "or a cached remote source marker under --volume" part of the--prefetch-remoteerror and the parenthetical in the help.--remote-urlwould then be the only way to stream. That change is smaller and also fixes the misleading help. It also avoids a hidden file under-vthat changes what a later run does. Happy to switch this PR to it.AI-assisted (Claude Code), human-directed. All runs above were executed on real data, not inferred.
Fixes #1555