batch_glb: exit 2 for a bad input or output folder, 1 only for a failed model (BATCH-GLB-USAGE-EXIT-STATUS) #920
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!920
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/batch-glb-usage-exit"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request successfully merged and closed
Claimed in the coordination issue as: BATCH-GLB-USAGE-EXIT-STATUS (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135524946)
What was wrong
tools/batch_glb.pydocuments "Exit status is 1 only when a model failed" (docstring, lines 8-9). Butmain()(line 265-267) catches(ValueError, OSError)frombatch_convertand returns 1. Those errors are input and output setup errors, not failed models:batch_convertraisesValueErrorfor a missing input folder.os.makedirsraisesOSErrorwhen the output path is a file or cannot be created.Reproduction on origin/main:
The input check in
batch_convertruns beforeos.makedirs, so the file-as-output case writes nothing.Why one
returnis enoughPer-model errors never reach that
except.convert_singlecatches everyExceptionand returns it as a failure, so a corrupt model or a bad texture is counted and returns 1 through the existing linereturn 0 if stats["failed"] == 0 else 1. I checked that no otherValueErrororOSErrorcan escape thetryfor a single model.What changed
main(): the setup-error branch returns 2 instead of 1.tests/test_batch_glb.py:test_cli_reports_directory_setup_errorsexpected 1 for both cases; it now expects 2. Newtest_cli_exit_status_follows_the_docstringpins the other exit codes: an empty input folder returns 0, a folder with one corrupt model returns 1, and an argparse usage error returns 2.No caller, script or doc in the repository depends on exit 1 for these errors (
git grep batch_glbfinds only the tool and its test).Tested
The new exit-status test passes on both versions by design: it pins the cases that were already correct, so a fix that over-corrects would fail it.
Edge cases run by hand on the fixed code:
Other checks:
Inputs are hand-made: a two-line OBJ and empty folders. No game files, no GPU.
Not tested
os.makedirserrors differ there). Only Linux was run.AI-assisted (Claude Code).
Independent test of #920 (BATCH-GLB-USAGE-EXIT-STATUS)
Head tested: 540e522b364b884abc19d7d13ee4e687307de02f (merge base a2892784). Environment: Windows 11, native Python 3.13.13, no GPU. This covers the Windows run that the PR lists as not tested.
Commands and results:
python -I -B tests/test_batch_glb.py: Ran 16 tests, OK.tools/batch_glb.pyfrom the merge base:test_cli_reports_directory_setup_errorsFAILS in both subtests (1 != 2). As the PR says,test_cli_exit_status_follows_the_docstringpasses on both versions by design.--jobs 1):ERROR: Input directory does not exist: ..., exit 2.ERROR: [WinError 183] ..., exit 2.git merge-tree --write-tree origin/main <head>(origin/main 0af7753c): clean.python -I scripts/check_no_game_data.pyon the changed files: exit 0.git diff --check: clean.Findings:
convert_singleand counted, so only setup errors reach thisexcept. No other script or doc callsbatch_glb.py.Input directory does not exist, which is misleading. "is not a directory" would be clearer. Not blocking.Verdict: looks good.
AI-assisted.
Thanks for the Windows run.
Pushed dda55b6f6: the docstring sentence at line 9 now wraps like the rest of the paragraph (comment change only;
tests/test_batch_glb.pystill passes, 16 tests).Not changed: the "Input directory does not exist" message for an input path that is a file. It was already like that and is outside this claim; I will post it as a
finding:in the coordination issue if nobody has.LGTM. Measured on Windows 11, Python 3.14, against main cf4c00cba:
python -I tests/test_batch_glb.py: mainRan 15, OK; this PR and a local merge into mainRan 16, OK.tools/batch_glb.py,test_cli_reports_directory_setup_errorsfails in both subtests. Note thattest_cli_exit_status_follows_the_docstringalso passes with main'stools/batch_glb.py, so it guards the 0/1/2 contract rather than this fix.AI-assisted: yes (Claude Code ran the checks; I read them).
Merging.
Why merged: BATCH-GLB-USAGE-EXIT-STATUS: batch_glb exits 2 for a bad input or output folder, and 1 only when a model actually failed, so callers can tell usage errors from conversion failures. kawaii-shakal tested 540e522b on Windows (the later push was comment-only), and MoonEyes approved after that push.
Why it's good: test_batch_glb: 16 passed.
Tested on Windows 11 / RTX 4070 SUPER: merged alone onto main 6293c1c4f. With it in, the repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests) gives 571 passed / 5 skipped / 0 failed, and check_no_game_data on the changed files is clean. Security read of the three-dot diff: no binaries, game data, downloads, network calls, new env vars or build/CI changes.
AI-assisted (Claude Code, Claude Opus 5.5).