Fix/error code hints 215#243
Conversation
|
MLCommons CLA bot: |
| } | ||
|
|
||
|
|
||
| def _get_exit_code_hint(return_code: int) -> str: |
There was a problem hiding this comment.
Looks good. Thank you for the contribution!
Can you please remove any formatting for the existing code? - there's an autoformatter running in github action which will otherwise reformat the code again.
There was a problem hiding this comment.
Done applied autopep8 formatting to script_action.py.
| "\nError : " + f"{type(exc).__name__}: {exc}", | ||
| script_name=_script_name, repo_alias=_repo_alias, module_path=module_path, | ||
| run_args=run_args) from exc | ||
| f"Script {function_name} execution failed in { |
There was a problem hiding this comment.
Currently tests are failing due to a syntax error in this line, either bring the fstring onto a single line or else use triple quotes to have multiple line message.
| _version_info_file = None | ||
| raise ScriptExecutionError( | ||
| f"Script {function_name} execution failed in {module_path}. \nError : {error}", | ||
| f"Script {function_name} execution failed in { |
There was a problem hiding this comment.
Here as well, multiple line message not allowed while using single quote fstring.
Summary
Fixes #215
When a script exits with a non-zero return code, MLCFlow now displays a
human-readable hint alongside the exit code to help users diagnose failures
faster — without needing to look up exit codes manually.
Changes
_SCRIPT_EXIT_CODE_HINTSdict mapping common exit codes to advice_get_exit_code_hint()helper function (handles POSIX codes + curl network codes 6/7)ScriptExecutionErrorto accept and storereturn_code, appending the hint to the exception messagecall_script_module_functionto passresult["return"]asreturn_codewhen raisingTesting
Tested locally on Windows. CI workflow included.
All existing tests pass.