Skip to content

fix: correct error handling in setup_env.py and e2e_benchmark.py#504

Open
mvanhorn wants to merge 1 commit intomicrosoft:mainfrom
mvanhorn:fix/447-setup-env-error-handling
Open

fix: correct error handling in setup_env.py and e2e_benchmark.py#504
mvanhorn wants to merge 1 commit intomicrosoft:mainfrom
mvanhorn:fix/447-setup-env-error-handling

Conversation

@mvanhorn
Copy link

Summary

Fixes 5 error-handling bugs across setup_env.py and utils/e2e_benchmark.py:

  1. setup_env.py:107 - sys.exit(1) indentation bug: The sys.exit(1) call in run_command() is outside the except block, causing unconditional exit after any command run through the non-logging path. Fixed by indenting it into the except block.

  2. e2e_benchmark.py:23 - same indentation bug: Identical sys.exit(1) indentation issue. This one is actively triggered since run_benchmark() calls run_command(command) without log_step, so the benchmark always exits with code 1 after successful runs.

  3. setup_env.py:212 - exit(0) on error: When the architecture is unsupported, exit(0) reports success. Changed to sys.exit(1) to correctly signal failure.

  4. setup_env.py:85 - ARCH_ALIAS KeyError: ARCH_ALIAS[platform.machine()] crashes with KeyError on 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.

  5. setup_env.py:225 - SUPPORTED_QUANT_TYPES KeyError: SUPPORTED_QUANT_TYPES[arch] in parse_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 - passes
  • python3 -m py_compile utils/e2e_benchmark.py - passes
  • Verified on x86_64 and arm64 that existing behavior is unchanged

Fixes #447

- 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>
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.

sys.exit(1) runs unconditionally due to indentation bug in run_command()

1 participant