Skip to content

fiber_trace: don't require the monorepo lasagna package just to decod… - #2090

Merged
hendrikschilling merged 2 commits into
ScrollPrize:mainfrom
sfc0324:fix/fiber-trace-decode-normals-fallback
Oct 22, 2026
Merged

hendrikschilling merged 2 commits into
ScrollPrize:mainfrom
sfc0324:fix/fiber-trace-decode-normals-fallback

Conversation

@sfc0324

@sfc0324 sfc0324 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

In one sentence: vesuvius.neural_tracing.fiber_trace can be imported from a normal vesuvius install without the monorepo lasagna package on PYTHONPATH.

One real example: Starting with a fresh uv sync --extra models of vesuvius at a4979b9, I ran tests/neural_tracing/test_fiber_trace.py, and it produced 52 passing tests instead of a collection-time ModuleNotFoundError: No module named 'lasagna'.

Before: fiber_trace/geometry.py imports _decode_normals from lasagna.omezarr_pyramid, falling back to a bare omezarr_pyramid module. lasagna is not a declared dependency of vesuvius, so importing vesuvius.neural_tracing.fiber_trace (and collecting its test file) fails unless the user manually puts villa/lasagna on PYTHONPATH. Only this 4-line decoder is used from lasagna here.

After this PR: lasagna's implementation is still preferred when importable; otherwise an identical local _decode_normals_u8 is used. Behaviour with lasagna installed is unchanged.

Proof: Same environment, base a4979b9 vs this branch.

Before (a4979b9):

src/vesuvius/neural_tracing/fiber_trace/geometry.py:9: in <module>
E   ModuleNotFoundError: No module named 'omezarr_pyramid'
ERROR tests/neural_tracing/test_fiber_trace.py
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
1 error in 1.62s

After (this PR; test_fiber_trace.py + new test_fiber_trace_decode_normals.py):

55 passed in 5.61s

The 3 new tests: known values (128→0, 255→1, 1→−1, float32), byte-for-byte parity with lasagna/omezarr_pyramid.py::_decode_normals on random uint8 input (loaded from the monorepo file; skips if absent), and import with lasagna/omezarr_pyramid blocked in sys.modules.

Why / where this is useful: People who pip/uv install vesuvius to train or run the fiber tracer, and CI/test runs of the vesuvius package on its own, no longer need the undocumented PYTHONPATH=lasagna step for this module.

  • I personally verified that the example and proof above were produced by this PR on the stated data.

Details

  • Tested commit: base a4979b9; this branch = one commit on top.
  • Environment: Linux x86_64, CPU only (no GPU), no C++ compiler on PATH (which g++ c++ finds nothing), Python 3.14.8, torch 2.12.1+cu130, uv 0.13.0. Install: cd vesuvius && uv sync --extra models --no-install-package volume-cartographer (volume-cartographer skipped because it needs a C++ toolchain to build).
  • Command (from vesuvius/): uv run --with pytest python -m pytest -q -p no:cacheprovider tests/neural_tracing/test_fiber_trace.py tests/neural_tracing/test_fiber_trace_decode_normals.py
  • Changes: src/vesuvius/neural_tracing/fiber_trace/geometry.py (local decoder + third import fallback); new tests/neural_tracing/test_fiber_trace_decode_normals.py.
  • Limitations / not changed: fiber_trace_2d and fiber_trace_3d use much more of lasagna (tiled_predict3d, live_omezarr_cache, ...) and still require it; their test files still error at collection without lasagna. Keeping a copy of the decoder means the two must stay in sync — the parity test guards that.

…e normals

vesuvius.neural_tracing.fiber_trace.geometry imported _decode_normals from
lasagna.omezarr_pyramid (or a bare omezarr_pyramid on PYTHONPATH). lasagna is
not a declared dependency of vesuvius, so with a normal 'uv sync --extra models'
importing vesuvius.neural_tracing.fiber_trace (and collecting
tests/neural_tracing/test_fiber_trace.py) failed with ModuleNotFoundError.

Keep preferring lasagna's implementation, but fall back to an identical local
4-line decoder. Adds a byte-for-byte parity test against
lasagna/omezarr_pyramid.py and a test that the module imports with lasagna
blocked.
@vercel

vercel Bot commented Oct 14, 2026

Copy link
Copy Markdown

@sfc0324 is attempting to deploy a commit to the scroll Team on Vercel.

A member of the Team first needs to authorize it.

@hendrikschilling

Copy link
Copy Markdown
Contributor

Looks mostly fine, but this PR duplicates the lasagna normal decoder in vesuvius. To avoid duplication please move it into vesuvius instead and make lasagna code use this shared decoder instead.

Move Lasagna's uint8 (nx, ny) hemisphere decoder into
vesuvius.neural_tracing.normals.decode_normals and call it from fiber_trace,
so decoding normals no longer imports lasagna. lasagna.omezarr_pyramid
re-exports that function as _decode_normals, keeping the existing name for
callers such as the pyramid moment pool and fiber_trace_2d.

Co-authored-by: sfc0324 <sfc0324@users.noreply.github.com>
@cursor
cursor Bot requested a review from hendrikschilling as a code owner October 22, 2026 13:17
@sfc0324

sfc0324 commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review! I moved the normal decoder into vesuvius (vesuvius.neural_tracing.normals.decode_normals). fiber_trace now uses it directly, and lasagna.omezarr_pyramid re-exports it in place of its local copy, so existing imports keep working. Added tests for the shared decoder, and the vesuvius and lasagna tests pass.

@hendrikschilling
hendrikschilling enabled auto-merge (squash) October 22, 2026 15:36
@hendrikschilling
hendrikschilling merged commit 6aec908 into ScrollPrize:main Oct 22, 2026
18 of 19 checks passed
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.

3 participants