autograder.cli.testing.setup-grading-dir

Setup a directory as if it is being graded. This is useful for seeing what the autograder will see right before grading begins.

usage: python3 -m autograder.cli.testing.setup-grading-dir [-h] [--version]
                                                           [--testing-mode] -a
                                                           ASSIGNMENT -s
                                                           SUBMISSION
                                                           [-o OUT_DIR] [-ss]

Setup a directory as if it is being graded.
This is useful for seeing what the autograder will see right before grading begins.

options:
    -h, --help          show this help message and exit
    --version           show program's version number and exit
    -a ASSIGNMENT, --assignment ASSIGNMENT
                        The path to an assignment JSON file.
    -s SUBMISSION, --submission SUBMISSION
                        The path to an input submission.
    -o OUT_DIR, --out-dir OUT_DIR
                        The base output directory. Will be a temp directory if
                        not specified.
    -ss, --skip-static  Skip the static portion of the setup (copy and ops)
                        (default: False)

testing options:
    --testing-mode      Run as if a test is being run (default: False).
 1# pylint: disable=invalid-name
 2
 3"""
 4Setup a directory as if it is being graded.
 5This is useful for seeing what the autograder will see right before grading begins.
 6"""
 7
 8import argparse
 9import os
10import sys
11
12import autograder.cli.parser
13import autograder.submission
14
15def run_cli(args: argparse.Namespace) -> int:
16    """ Run the CLI. """
17
18    assignment_config_path = os.path.abspath(args.assignment)
19    submission_path = os.path.abspath(args.submission)
20
21    grading_dir = autograder.submission.prep_grading_dir(
22        assignment_config_path, submission_path,
23        grading_dir = args.out_dir,
24        skip_static = args.skip_static,
25    )
26
27    print(f"Prepared grading directory: '{grading_dir}'.")
28
29    return 0
30
31def main() -> int:
32    """ Get a parser, parse the args, and call run. """
33    return run_cli(_get_parser().parse_args())
34
35def _get_parser() -> argparse.ArgumentParser:
36    parser = autograder.cli.parser.get_parser(__doc__.strip())
37
38    parser.add_argument('-a', '--assignment',
39        action = 'store', type = str, required = True,
40        help = 'The path to an assignment JSON file.')
41
42    parser.add_argument('-s', '--submission',
43        action = 'store', type = str, required = True,
44        help = 'The path to an input submission.')
45
46    parser.add_argument('-o', '--out-dir', dest = 'out_dir',
47        action = 'store', type = str, default = None,
48        help = 'The base output directory. Will be a temp directory if not specified.')
49
50    parser.add_argument('-ss', '--skip-static', dest = 'skip_static',
51        action = 'store_true', default = False,
52        help = 'Skip the static portion of the setup (copy and ops) (default: %(default)s)')
53
54    return parser
55
56if (__name__ == '__main__'):
57    sys.exit(main())
def run_cli(args: argparse.Namespace) -> int:
16def run_cli(args: argparse.Namespace) -> int:
17    """ Run the CLI. """
18
19    assignment_config_path = os.path.abspath(args.assignment)
20    submission_path = os.path.abspath(args.submission)
21
22    grading_dir = autograder.submission.prep_grading_dir(
23        assignment_config_path, submission_path,
24        grading_dir = args.out_dir,
25        skip_static = args.skip_static,
26    )
27
28    print(f"Prepared grading directory: '{grading_dir}'.")
29
30    return 0

Run the CLI.

def main() -> int:
32def main() -> int:
33    """ Get a parser, parse the args, and call run. """
34    return run_cli(_get_parser().parse_args())

Get a parser, parse the args, and call run.