Skip to content
Snippets Groups Projects
Commit f0d7e543 authored by Raphaël Gomès's avatar Raphaël Gomès
Browse files

bin: rewrite `result-compare` with `click`

This is much simpler and more powerful than rolling it by hand.
parent f014a23a
No related branches found
No related tags found
1 merge request!23Use click for argument parsing, etc.
#!/usr/bin/env python3
#
# compare many result together, use it with `result-search --content-as-json`
......@@ -4,4 +2,3 @@
import argparse
import collections
import json
......@@ -6,6 +3,7 @@
import collections
import json
import sys
import click
HEADERS_KEYS = [
('data-env-vars', 'name'),
......@@ -77,8 +75,8 @@
print(f"{key}: {median:6.6f} {display}")
def _parsers():
cmd_parser = argparse.ArgumentParser(prog='result-compare')
return cmd_parser
@click.command()
@click.argument("file", type=click.File(), default="-")
def result_compare(file):
"""Compare results together.
......@@ -84,7 +82,5 @@
def main(args):
parser = _parsers()
param = parser.parse_args(args)
all_results = json.load(sys.stdin)
`poulpe result-search --content-as-json | poulpe result-compare`"""
all_results = json.load(file)
results = dispatch_results(all_results)
display_results(results)
......@@ -89,6 +85,5 @@
results = dispatch_results(all_results)
display_results(results)
return 0
if __name__ == "__main__":
......@@ -92,6 +87,4 @@
if __name__ == "__main__":
ret = main(sys.argv[1:])
assert ret is not None
sys.exit(ret)
result_compare()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment