Deal with errors better#7
Conversation
|
/kind cleanup |
There was a problem hiding this comment.
Pull request overview
This PR improves how evaluator execution failures are surfaced to API callers by refining run_command error reporting and avoiding accidental double-wrapping of execution errors.
Changes:
- Add
last_output_lines(and a max-tail constant) to include a focused tail of evaluator output in non-zero-exit errors. - Update
run_commandto distinguish signal termination vs non-zero exit, handle “no output” cleanly, and improve the timeout message. - Update
execute_python_functionto re-raise the originalFunctionExecutionErrorinstead of wrapping it, and add a newcommon_toolstest suite.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| main.py | Stops wrapping FunctionExecutionError again when checkpoint retrieval fails. |
| common_tools.py | Adds output-tail helper and improves run_command error handling/messages. |
| common_tools_test.py | Introduces tests covering success, non-zero exit, signal termination, timeout, and output-tail behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| source = stderr if stderr.strip() else stdout | ||
| return "\n".join(source.strip().splitlines()[-max_lines:]) |
| lines = stdout.strip().splitlines() | ||
| if not lines: | ||
| # Exited cleanly but printed nothing, so there is no result to parse. | ||
| raise FunctionExecutionError("Evaluator Format Error: No output was written.") |
| except subprocess.TimeoutExpired as exc: | ||
| process.kill() | ||
| raise FunctionExecutionError("Timeout") from exc | ||
| raise FunctionExecutionError(f"Evaluation timed-out after {timeout} seconds.") from exc |
| """ | ||
| A command killed by a signal reports the signal with an execution-failed | ||
| prefix. | ||
| """ |
|
/hold |
kerry-hiverge
left a comment
There was a problem hiding this comment.
lgtm! one small comment
| the evaluator produced no output at all. | ||
| """ | ||
| source = stderr if stderr.strip() else stdout | ||
| return "\n".join(source.strip().splitlines()[-max_lines:]) |
There was a problem hiding this comment.
i think it could be useful to show both the stderr and stdout if both are present, e.g., the stdout could give useful context about where the program was up to before it crashed. we could present the last few lines of both if both are nonempty perhaps
|
Clean test run now: |
This PR improves the error handling in the daemon server.
See also this PR: https://github.com/hiverge/hiverge/pull/553