tvalentyn commented on code in PR #27288:
URL: https://github.com/apache/beam/pull/27288#discussion_r1261649920
##########
sdks/python/apache_beam/testing/analyzers/github_issues_utils.py:
##########
@@ -162,28 +164,32 @@ def get_issue_description(
"""
# TODO: Add mean and median before and after the changepoint index.
- max_timestamp_index = min(
- change_point_index + max_results_to_display, len(metric_values) - 1)
- min_timestamp_index = max(0, change_point_index - max_results_to_display)
- description = _ISSUE_DESCRIPTION_TEMPLATE.format(
- test_name, metric_name) + 2 * '\n'
+ description = []
+
+ description.append(_ISSUE_DESCRIPTION_TEMPLATE.format(test_name,
metric_name))
- description += (
- "`Test description:` " + f'{test_description}' +
- 2 * '\n') if test_description else ''
+ description.append(("`Test description:` " +
+ f'{test_description}') if test_description else '')
- description += '```' + '\n'
- runs_to_display = [
- _METRIC_INFO_TEMPLATE.format(
- timestamps[i].ctime(), format(metric_values[i], '.2f'))
- for i in reversed(range(min_timestamp_index, max_timestamp_index + 1))
- ]
+ description.append('```')
+
+ runs_to_display = []
+ max_timestamp_index = min(
+ change_point_index + max_results_to_display, len(metric_values) - 1)
+ min_timestamp_index = max(0, change_point_index - max_results_to_display)
- runs_to_display[change_point_index - min_timestamp_index] += " <---- Anomaly"
- description += '\n'.join(runs_to_display) + '\n'
- description += '```' + '\n'
- return description
+ # run in reverse to display the most recent runs first.
+ for i in reversed(range(min_timestamp_index, max_timestamp_index + 1)):
+ row_template = _METRIC_INFO_TEMPLATE.format(
+ timestamps[i].ctime(), format(metric_values[i], '.2f'))
+ if i == change_point_index:
+ row_template += constants._ANOMALY_MARKER
+ runs_to_display.append(row_template)
+
+ description.append('\n'.join(runs_to_display))
+ description.append('```')
+ return constants._NEW_LINES_JOINER.join(description)
Review Comment:
`constants._NEW_LINES_JOINER` looks somewhat strange, i'd remove it if you
don't need it in the test (see another comment)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]