Skip to content

Cap bulk document upload batches by size; fail when nothing is ingested; resume lightsheet builds from cloud documents - #372

Merged
stevevanhooser merged 4 commits into
mainfrom
claude/clever-goldberg-45o38v
Nov 20, 2026
Merged

stevevanhooser merged 4 commits into
mainfrom
claude/clever-goldberg-45o38v

Conversation

@stevevanhooser

@stevevanhooser stevevanhooser commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Port of VH-Lab/NDI-matlab#1247 and VH-Lab/NDI-matlab#1296.

Bulk document uploads (NDI-matlab#1247)

A dataset uploaded no documents, yet the upload reported success. uploadDocumentCollection put up to 100000 documents into one JSON file in one zip (638 MB uncompressed). The server's ingestion Lambda ran out of /tmp (ENOSPC) and ingested nothing. The client's ingestion wait only warned that the server "may still be ingesting". The server fix is Waltham-Data-Science/ndi-cloud-node#175.

  • Size-capped batches. New preference Cloud.Upload.Max_Document_Batch_Size (50 MB, same key and default as MATLAB) and keyword-only max_bytes. A batch ends at that much JSON or at max_chunk documents. New helper documentBatchRanges, which uses 0-based indexes and produces the same batches as MATLAB. The byte preference is read only on the bulk path.
  • Encode once. zip_documents_for_upload(..., document_json=...) reuses the encoded JSON and writes the same top-level array.
  • Nothing ingested → failure. If the ingestion wait ends with the count still ≤ the count before the upload: status is 'partial', uploaded is 0, the ids move from manifest to not_ingested (sync's _upload_documents reads manifest), ingestion['state'] is 'failed', and the reason goes to errors and the log. A partial count still only warns, as before.

Resuming a lightsheet build from cloud documents (NDI-matlab#1296)

DID strips series ingest_locations before storing, so a document downloaded from NDI Cloud and adopted on resume showed no member uids. Two consequences:

  • missingMembers reported every chunk present, so nothing lost was rebuilt. A prod pyramid kept 327 lost chunks this way.
  • A level reduced from an adopted level could not open its chunks.

Changes:

  • SessionWriter._seriesWithUids. A series that has members but no uids gets them rebuilt from its manifest. The manifest is downloaded into the cache and read with filehandler.reconstructSeriesIngestLocations. It raises (noManifest / downloadFailed / manifestUnreadable) rather than guess. adopt, _registerSeries and missingMembers use it.
  • makePyramid. On resume, a level reduced from a stored level whose every chunk is already in the cloud is adopted and skipped before its source is resolved.

Bridge

Testing

  • black --check and ruff check are clean.
  • tests/test_cloud_upload_bulk_documents.py covers:
    • batching edge cases;
    • document_json equivalence and mismatch;
    • a byte cap that splits zips;
    • the default preference;
    • nothing ingested → failed;
    • an unknown final count → timeout only.
  • test_gui_preferences_editor.py was updated for the new preference row.
  • New resume tests in tests/test_cloud_session_writer.py:
    • adopting a stored document finds exactly its missing members;
    • a member of an adopted stored document can be opened;
    • a series whose manifest is gone is refused.
  • New resume test in tests/test_fun_doc_lightsheet_build.py: a finished build loses three level-0 chunks and the resume sends exactly those. It declares no level documents and opens no reduced level's source.
  • All four resume tests fail without the fix and pass with it.
  • Locally: the session writer, lightsheet build, bridge hash and name alias tests pass (136).

Generated by Claude Code

Port of VH-Lab/NDI-matlab#1247. uploadDocumentCollection put up to
100000 documents into one JSON file in one zip; a 638 MB file made the
server's ingestion Lambda run out of scratch disk, nothing was ingested,
and the upload still reported success.

- New preference Cloud.Upload.Max_Document_Batch_Size (50 MB) and
  keyword-only max_bytes: batches end at that much JSON or at max_chunk
  documents (new helper documentBatchRanges).
- Documents are encoded once; zip_documents_for_upload gains
  document_json.
- If the server lists none of the stored documents when the ingestion
  wait ends: status 'partial', uploaded 0, ids moved from manifest to
  not_ingested, ingestion['state'] 'failed', reason in errors.
- Bridge entries for uploadDocumentCollection, zip_documents_for_upload,
  documentBatchRanges (new) and preferences synced to NDI-matlab ec25d3c.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011v7R5rmThd1CWtGUX32qh7
The bridge drift check failed on readngrid: NDI-matlab e3744121e (now on
main) lets readngrid read a did.file.fileobj such as the one
database_openbinarydoc returns. Ported: file_path may also be a
did.file.Fileobj or an open binary file object; an open one is read from
its current position and left open, an unopened Fileobj is opened 'rb'
and closed after. Bridge hash bumped.

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

Copy link
Copy Markdown
Contributor Author

The "MATLAB/Python bridge completeness" failure was not caused by this PR. It flagged readngrid drift from NDI-matlab e3744121e, which has since merged to NDI-matlab main, so the same check would fail on this repo's main as well. I ported that change here in 623b1cc so the check can go green. readngrid now also accepts a did.file.Fileobj or an open binary file object: an open one is read from its current position and left open, and an unopened Fileobj is opened 'rb' and closed afterwards. The commit includes tests, and the bridge hash is bumped to e3744121e. Locally, all 202 bridge tests pass.


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

test (3.10) and test (3.12) each fail one test, test_did_integration.py::TestBundledDefinitions::test_definitions_validate_or_are_listed. The cause appears to be outside this PR:

vision/speed_tuning_bootstrap: DID:Database:ValidationFieldInteger
  • vision/speed_tuning_bootstrap is a definition shipped by ndicalc-vis-matlab, which pyproject.toml installs from its unpinned main (.../NDIcalc-vis-matlab/archive/refs/heads/main.zip). This PR changes no definitions, schemas or validation code.
  • NDI-python main was green on 2026-11-13 (run 43506393164). The likeliest explanation is that an upstream commit to NDIcalc-vis-matlab since then made this definition fail its own schema. I couldn't confirm that, because I can't read NDIcalc-vis-matlab from this session.
  • Possible fixes: fix the definition in NDIcalc-vis-matlab (preferred), or record it in KNOWN_UNVALIDATABLE_FROM_DEPENDENCIES in tests/test_did_integration.py. That list already holds two ndicalc definitions, and the test fails as soon as a listed entry starts validating, so the entry can't go stale. I haven't done either, since choosing between them is a maintainer decision.

Generated by Claude Code

…nc with NDI-matlab a469501c1)

Port of VH-Lab/NDI-matlab#1296. DID strips series ingest_locations before
storing, so an adopted document downloaded from NDI Cloud showed no
member uids: missingMembers reported every chunk present (nothing lost
was rebuilt) and a level reduced from an adopted level could not open
its chunks.

- SessionWriter._seriesWithUids: a series with members but no uids gets
  them rebuilt from its manifest (downloaded into the cache) via
  filehandler.reconstructSeriesIngestLocations; raises noManifest /
  downloadFailed / manifestUnreadable rather than guess. adopt,
  _registerSeries and missingMembers use it.
- makePyramid: on resume, a level reduced from a stored level whose every
  chunk is already in the cloud is adopted and skipped before its source
  is resolved.
- Tests: adopting a stored document finds exactly its missing members,
  opens a member, refuses a series whose manifest is gone; a finished
  build that loses three level-0 chunks resumes sending exactly those,
  declaring no level documents and opening no reduced level's source.
- Bridge: SessionWriter and makePyramid synced to a469501c1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011v7R5rmThd1CWtGUX32qh7
@stevevanhooser stevevanhooser changed the title Cap bulk document upload batches by size; fail when nothing is ingested Cap bulk document upload batches by size; fail when nothing is ingested; resume lightsheet builds from cloud documents Nov 20, 2026
@stevevanhooser
stevevanhooser merged commit 481c8d0 into main Nov 20, 2026
19 checks passed
@stevevanhooser
stevevanhooser deleted the claude/clever-goldberg-45o38v branch November 20, 2026 20:18
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.

2 participants