Create cli.py
Browse files
cli.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
import sys
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
|
| 5 |
+
from scorer import score
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def main():
|
| 9 |
+
if len(sys.argv) != 3:
|
| 10 |
+
print("Usage: python cli.py <reference.csv> <predictions.csv>", file=sys.stderr)
|
| 11 |
+
sys.exit(1)
|
| 12 |
+
|
| 13 |
+
reference_path = Path(sys.argv[1])
|
| 14 |
+
prediction_path = Path(sys.argv[2])
|
| 15 |
+
|
| 16 |
+
if not reference_path.exists():
|
| 17 |
+
print(f"Reference file not found: {reference_path}", file=sys.stderr)
|
| 18 |
+
sys.exit(1)
|
| 19 |
+
|
| 20 |
+
if not prediction_path.exists():
|
| 21 |
+
print(f"Prediction file not found: {prediction_path}", file=sys.stderr)
|
| 22 |
+
sys.exit(1)
|
| 23 |
+
|
| 24 |
+
try:
|
| 25 |
+
results = score(reference_path, prediction_path)
|
| 26 |
+
except Exception as e:
|
| 27 |
+
print(f"Scoring error: {e}", file=sys.stderr)
|
| 28 |
+
sys.exit(1)
|
| 29 |
+
|
| 30 |
+
print(json.dumps(results, indent=2))
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
if __name__ == "__main__":
|
| 34 |
+
main()
|