-
Notifications
You must be signed in to change notification settings - Fork 59
fix: tools: faulty mtrace lines do not fail script #1343
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
fix: tools: faulty mtrace lines do not fail script #1343
Conversation
85f5396 to
8f5f5a3
Compare
e24b25e to
0fcba1f
Compare
| ctx, func = rest[0:2] | ||
| msg = ': '.join(rest[2:]).strip() | ||
| yield TraceItem(timestamp, trace_lvl, ctx, func, msg) | ||
| except Exception as e: # pylint: disable=W0718 |
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.
Ironic how W0718 warns about precisely the type of "green failure" issues that this PR is trying to fix... Why not simply catch the specific parsing exception?
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.
This script is a additional tool for getting stats from mtrace file, not a main test. That's why we decided to "ignore" lines that couldn't be parsed for whatever reason - hence the broad exception.
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.
You are missing the point. There is a limited number of parsing exception types this small piece of code can raise and that can be expected here. It would be easy to list them here. Catching any exception instead, including unexpected exceptions unrelated to parsing means hiding bugs in this code. This is what W0718 means.
Amusingly, this is a similar sort of issue that this PR is fixing.
tools/sof_perf_analyzer.py
Outdated
| hours=int(h), | ||
| minutes=int(m), | ||
| seconds=float(s) | ||
| ).total_seconds() |
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.
I think the timestamp parsing has become long enough to deserve its own, separate function. The nesting of try blocks and the significant indentation make the code less readable.
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.
done
In case of a faulty line in mtrace, the sof_perf_analyzer.py script will log a warning and move on, instead of failing. Signed-off-by: Emilia Kurdybelska <emiliax.kurdybelska@intel.com>
0fcba1f to
e06f756
Compare
In case of a faulty mtrace line the sof_perf_analyzer.py script will log warning and move on, instead of failing the script (and the test).