-
Notifications
You must be signed in to change notification settings - Fork 14
Improve script failure messages with error-code guidance and CI coverage #237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Copilot
wants to merge
12
commits into
dev
Choose a base branch
from
copilot/better-error-code-usage
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
df4f117
Merge pull request #219 from mlcommons/dev
arjunsuresh 1e09e60
Initial plan
Copilot b728a21
feat: add actionable script error-code guidance
Copilot 46c315d
chore: drop accidental log artifact
Copilot 31517a0
chore: ignore generated mlc log file
Copilot 6ff79f5
chore: refine error guidance helpers
Copilot 65f4997
fix: tighten error code detection rules
Copilot 7917409
chore: precompile error code patterns
Copilot 61ac17e
[Automated Commit] Format Codebase
bumper97birch 8fde1eb
Merge branch 'dev' into copilot/better-error-code-usage
arjunsuresh 11733b8
[Automated Commit] Format Codebase
bumper97birch bfd555a
ci: run error guidance test in core actions workflow
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import io | ||
| import logging | ||
| import os | ||
| import sys | ||
| import unittest | ||
|
|
||
| sys.path.insert(0, os.path.abspath(os.path.join( | ||
| os.path.dirname(__file__), "..", ".."))) | ||
|
|
||
| from mlc.error_codes import get_error_guidance | ||
| from mlc.main import _report_error, logger | ||
| from mlc.script_action import ScriptExecutionError | ||
|
|
||
|
|
||
| class ErrorGuidanceTest(unittest.TestCase): | ||
|
|
||
| def test_detects_disk_space_errors_from_message(self): | ||
| guidance = get_error_guidance( | ||
| 1, "Command execution failed with error code 28. No space left on device.") | ||
|
|
||
| self.assertIsNotNone(guidance) | ||
| self.assertEqual(guidance["error_code"], 28) | ||
| self.assertIn("disk space", guidance["error_message"].lower()) | ||
| self.assertTrue(any("Free disk space" in s for s in guidance["suggestions"])) | ||
|
|
||
| def test_detects_segmentation_fault_errors(self): | ||
| guidance = get_error_guidance(139, "Segmentation fault (core dumped)") | ||
|
|
||
| self.assertIsNotNone(guidance) | ||
| self.assertEqual(guidance["error_code"], 139) | ||
| self.assertIn("segmentation fault", guidance["error_message"].lower()) | ||
|
|
||
| def test_report_error_logs_actionable_guidance(self): | ||
| stream = io.StringIO() | ||
| handler = logging.StreamHandler(stream) | ||
| handler.setLevel(logging.ERROR) | ||
| logger.addHandler(handler) | ||
|
|
||
| try: | ||
| error = ScriptExecutionError( | ||
| "Script run execution failed.", | ||
| script_name="detect,cpu", | ||
| run_args={"target": "script", "action": "run"}, | ||
| error_code=139, | ||
| error_guidance=get_error_guidance( | ||
| 139, "Segmentation fault (core dumped)") | ||
| ) | ||
|
|
||
| _report_error(error) | ||
| finally: | ||
| logger.removeHandler(handler) | ||
|
|
||
| output = stream.getvalue() | ||
| self.assertIn("Detected error code: 139", output) | ||
| self.assertIn("Likely cause:", output) | ||
| self.assertIn("Suggestion:", output) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,5 +2,4 @@ build | |
| dist | ||
| *egg-info | ||
| __pycache__ | ||
|
|
||
| .mlc-log.txt | ||
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot where's this test used in github actions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wasn’t wired into GitHub Actions before. I’ve added it to
.github/workflows/test-mlc-core-actions.yaml, so it now runs asTest 3c - error guidance handlingin CI. Commit:bfd555a. No UI change.