fix: correct error handling in setup_env.py and e2e_benchmark.py#504
Open
mvanhorn wants to merge 1 commit intomicrosoft:mainfrom
Open
fix: correct error handling in setup_env.py and e2e_benchmark.py#504mvanhorn wants to merge 1 commit intomicrosoft:mainfrom
mvanhorn wants to merge 1 commit intomicrosoft:mainfrom
Conversation
- Fix sys.exit(1) indentation in run_command() so it only runs on error (setup_env.py:107 and e2e_benchmark.py:23) - Change exit(0) to sys.exit(1) for unsupported arch in compile() - Use ARCH_ALIAS.get() to avoid KeyError on unrecognized architectures - Guard SUPPORTED_QUANT_TYPES lookup against unknown arch in parse_args() Fixes microsoft#447 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
Fixes 5 error-handling bugs across
setup_env.pyandutils/e2e_benchmark.py:setup_env.py:107-sys.exit(1)indentation bug: Thesys.exit(1)call inrun_command()is outside theexceptblock, causing unconditional exit after any command run through the non-logging path. Fixed by indenting it into theexceptblock.e2e_benchmark.py:23- same indentation bug: Identicalsys.exit(1)indentation issue. This one is actively triggered sincerun_benchmark()callsrun_command(command)withoutlog_step, so the benchmark always exits with code 1 after successful runs.setup_env.py:212-exit(0)on error: When the architecture is unsupported,exit(0)reports success. Changed tosys.exit(1)to correctly signal failure.setup_env.py:85-ARCH_ALIASKeyError:ARCH_ALIAS[platform.machine()]crashes withKeyErroron unrecognized architectures (e.g.,i686,riscv64,ppc64le). Changed to.get()with fallback to the raw machine string, so the architecture check downstream can provide a proper error message.setup_env.py:225-SUPPORTED_QUANT_TYPESKeyError:SUPPORTED_QUANT_TYPES[arch]inparse_args()crashes for unknown architectures before argparse can run. Added a guard that logs an error and exits cleanly.Testing
python3 -m py_compile setup_env.py- passespython3 -m py_compile utils/e2e_benchmark.py- passesx86_64andarm64that existing behavior is unchangedFixes #447