Skip to content

fix: return nonzero for failed inference batches - #111

Open
huong8373tt-beep wants to merge 1 commit into
baidu:mainfrom
huong8373tt-beep:fix/infer-failure-exit-status
Open

huong8373tt-beep wants to merge 1 commit into
baidu:mainfrom
huong8373tt-beep:fix/infer-failure-exit-status

Conversation

@huong8373tt-beep

Copy link
Copy Markdown

Summary

  • validate the selected PDF/image input before starting SGLang, so missing files, missing directories, empty image directories, and zero-page PDFs fail without a model launch
  • keep the preflight job list and return exit code 2 for invalid/no-work input
  • tag each request result with explicit success/failure and return exit code 1 when any request exhausts retries; return 0 only when all requested jobs succeed
  • keep server cleanup in finally even when the batch returns a failure status

Validation

python -m unittest -v tests/test_infer_exit_status.py
# 6 passed

python -m py_compile infer.py tests/test_infer_exit_status.py
# passed

python infer.py --image_dir does-not-exist --output_dir ./test-output
# Input error: Image directory not found: does-not-exist
# exit code: 2

git diff --check
# passed

The regression tests are CPU-only and mock inference; no SGLang server, GPU, or model download was required.

Closes #103


Slai Agent Runtime assisted with investigation, implementation, and testing. The account owner reviewed and authorized this contribution.

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.

infer.py always exits 0 — even when every request fails or no inputs are found

1 participant