-
Notifications
You must be signed in to change notification settings - Fork 314
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
Saving tournament report [Closes #249] #250
Conversation
Thanks for the PR @keyur9. I had a quick look. It's a good start but you also need to use these parameters, i.e. |
Thank you for the feedback @danielmitterdorfer. As suggested, have updated the |
Thanks for the follow-up. Could you please refactor it in a way that both reporters call just one implementation? I'd just implement |
Thank you for the quick response. Sure, I'll work on refactoring and complete it before end of the week. |
Hello @danielmitterdorfer, as suggested I've implemented |
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.
Thanks for iterating @keyur9. I left a couple of comments. Can you please also run your changes so it once shows a summary report and once a comparison report so you can see that both implementations still work?
esrally/reporter.py
Outdated
@@ -34,6 +34,26 @@ def print_internal(message): | |||
def print_header(message): | |||
print_internal(console.format.bold(message)) | |||
|
|||
def write_single_report(self, report_file, headers, data, write_header=True, show_also_in_console=True): |
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.
self
is an (implicit) reference to the current object. As you refactored it to be a function you need to remove self
here and also move all related helper functions (like format_as_markdown
, format_as_csv
).
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.
Nit: There should be 2 blank lines.
esrally/reporter.py
Outdated
@@ -34,6 +34,26 @@ def print_internal(message): | |||
def print_header(message): | |||
print_internal(console.format.bold(message)) | |||
|
|||
def write_single_report(self, report_file, headers, data, write_header=True, show_also_in_console=True): | |||
report_format = self._config.opts("reporting", "format") |
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 need to pass the report format as a parameter instead of using the config here.
esrally/reporter.py
Outdated
# ensure that the parent folder already exists when we try to write the file... | ||
rio.ensure_dir(rio.dirname(normalized_report_file)) | ||
with open(normalized_report_file, mode="a+", encoding="UTF-8") as f: | ||
f.writelines(formatter(headers, data, write_header)) | ||
|
||
class Stats: |
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.
Nit: There should be 2 blank lines.
Hello @danielmitterdorfer , Thank you for all the feedback. I've fixed all those issue and both implementations are working as expected. However, I faced one issue while generating Tournament report file. The output of difference between baseline and contender is shown in color in console and the diff method returns the difference in color. But when writing the color output in file it is getting converted to something like this |
@keyur9 Thanks for the update. I'd really love to keep the colors in the command line output. How about you generate the report twice, once for console consumption (with the ANSI escape sequence) and once for file output (without the ANSI escape sequences)? Generating the report is quite fast and I wouldn't bother doing it twice. Something like this: class ComparisonReporter:
def report(self, r1, r2):
# ...
metric_table_plain = self.metrics_table(baseline_stats, contender_stats, plain=True)
metric_table_rich = self.metrics_table(baseline_stats, contender_stats, plain=False)
# writes metric_table_rich to console, writes metric_table_plain to file
self.write_report(metric_table_plain, metric_table_rich)
def metrics_table(self, baseline_stats, contender_stats, plain):
self.plain=plain
metrics_table = []
# ...
return metrics_table
def diff(self, baseline, contender, treat_increase_as_improvement, formatter=lambda x: x):
diff = formatter(contender - baseline)
if self.plain:
color_greater = lambda x: x
color_smaller = lambda x: x
color_neutral = lambda x: x
elif treat_increase_as_improvement:
color_greater = console.format.green
color_smaller = console.format.red
color_neutral = console.format.neutral
else:
color_greater = console.format.red
color_smaller = console.format.green
color_neutral = console.format.neutral
if diff > 0:
return color_greater("+%.5f" % diff)
elif diff < 0:
return color_smaller("%.5f" % diff)
else:
# tabulate needs this to align all values correctly
return color_neutral("%.5f" % diff) You just need to add a new parameter to the function that actually writes the report data and write |
Hello @danielmitterdorfer, Thanks for the feedback. Generating the report twice didn't took long and have made the changes. Now we would be able to see the console output in color and save the tournament report in md and csv file. |
Thanks for following-up @keyur9! I'll try to review it later today. |
I did a few tests and unfortunately, a few of them failed. Can you please have a look @keyur9? Command:
Trace:
Command (obviously you need to choose two different timestamp depending on the output of
Command:
|
Hello @danielmitterdorfer. Thank you for the feedback. I have fixed the issues and now report is printed once in console and written once to file without ANSI escape sequence. Now the output for the command -
Please let me know if you're fine with changes. |
@keyur9 We're almost there. The only test case that failed for me was:
Rally writes not only the actual report but also a second file containing the git commit hash of the Elasticsearch version that it has benchmarked. When Rally attempts to write it with your modified version, we get (trace is shortened):
The keyword argument is now write_single_report("%s.meta" % report_file, report_format, cwd, headers=["Name", "Value"], data_plain=meta_info_table, data_rich=meta_info_table, show_also_in_console=False) everything works fine. I think this is the last change to get this PR in. |
Hello @danielmitterdorfer, Thank you for the feedback. I added both the missing parameters and changed the keyword to Please let me know if you're fine with those changes. |
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.
Thanks for following up @keyur9! The changes look good to me. I'll merge them soon. The feature will be released with the next release 0.5.3.
Added parameters in compare parsers to enable saving tournament report in csv or md format.