File size: 892 Bytes
44084af
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python3
"""Entry point: the grader package lives next to this file (python3 -I drops the script dir)."""
import argparse
import json
import os
import sys

sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from afgrader.xgrade import ExpertGrader  # noqa: E402


def main():
    ap = argparse.ArgumentParser()
    for k in ("--workspace", "--spec", "--hidden", "--out"):
        ap.add_argument(k, required=True)
    ap.add_argument("--details")
    a = ap.parse_args()
    with open(a.spec) as fh:
        spec = json.load(fh)
    keys, details = ExpertGrader(spec, a.hidden).grade(a.workspace)
    with open(a.out, "w") as fh:
        json.dump(keys, fh)
    if a.details:
        with open(a.details, "w") as fh:
            json.dump(details, fh, indent=1, default=str)
    print(json.dumps(keys))
    return 0


if __name__ == "__main__":
    sys.exit(main())