onnxruntime
181b7dff - Fix pip invocation and error handling for ninja install in whisper_jump_times.py (#27685)

Commit
10 days ago
Fix pip invocation and error handling for ninja install in whisper_jump_times.py (#27685) ### Description - Changed ninja pip install command from `["pip", "install", "ninja"]` to `[sys.executable, "-m", "pip", "install", "ninja"]` to ensure installation targets the active Python environment (venv/conda) rather than an arbitrary `pip` on PATH. - Wrapped `subprocess.run` in a `try/except subprocess.CalledProcessError` block that logs a clear error via `logger.error` before re-raising, replacing a silent unhandled exception. - Added `import sys`. **Before:** ```python install_cmd = ["pip", "install", "ninja"] logger.warning(f"Could not import `ninja`. Attempting to install `ninja` via `{' '.join(install_cmd)}`.") subprocess.run(install_cmd, check=True) ``` **After:** ```python install_cmd = [sys.executable, "-m", "pip", "install", "ninja"] logger.warning(f"Could not import `ninja`. Attempting to install `ninja` via `{' '.join(install_cmd)}`.") try: subprocess.run(install_cmd, check=True) except subprocess.CalledProcessError as install_err: logger.error(f"Failed to install `ninja`: {install_err}", exc_info=True) raise ``` ### Motivation and Context Using bare `pip` can silently install into the wrong environment and fails if `pip` is not on PATH. The unhandled `CalledProcessError` on install failure produced no actionable log output. Addresses feedback from [#27684](https://github.com/microsoft/onnxruntime/pull/27684). <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: apsonawane <111780983+apsonawane@users.noreply.github.com>
Author
Parents
Loading