pygrade package¶
Submodules¶
pygrade.cheat module¶
Check for cheating. Output file in format: distance file1 file2
- usage:
- pygrade cheat –test <file> [–students <file>] [–output <file>] [–workdir <file>]
- Options
- -h, –help -o, –output <file> Output file [default: cheats.tsv] -s, –students <file> Students TSV file [default: students.tsv] -t, –test <file> File containing python tests for grading -w, –workdir <file> Temporary directory for storing assignments [default: students]
pygrade.clone module¶
Clone student GitHub repositories.
- usage:
- pygrade clone [–students <file>] [–workdir <file>]
- Options
- -h, –help -s, –students <file> Students TSV file [default: students.tsv] -w, –workdir <file> Temporary directory for storing assignments [default: students]
pygrade.grade module¶
Grade a Python assignment, writing results to a .json file.
- usage:
- pygrade grade –test <file> [–students <file>] [–output <file>] [–workdir <file>] [–pull] [–extra <file>]
- Options
- -h, –help -e, –extra <file> File containing extra deductions, in tab-separated format: github_id points_off reason -o, –output <file> Output file [default: grades.json] -p, –pull Pull latest code from student repository. -s, –students <file> Students TSV file [default: students.tsv] -t, –test <file> File containing python tests for grading -w, –workdir <file> Temporary directory for storing assignments [default: students]
-
pygrade.grade.
deduct_failures
(test_results)[source]¶ Accumulate each failed tests and the points lost.
-
pygrade.grade.
load_assignment_modules
(repo, assignment_subpaths, metadata, result, results)[source]¶
-
pygrade.grade.
read_extra_deductions
(args)[source]¶ Read a file containing additional deductions for a student. E.g. for late points; or if there is a small compiler error that the grader fixes in order to run the rest of the tests.
-
pygrade.grade.
run_tests
(students, test_path, path, do_pull, student2extra)[source]¶ Run unit tests and deduct points for each failed test. Return a dictionary of results for each student. FIXME: check for errors?
pygrade.init module¶
Initialize student repositories. Create one repo per student. Also create one team per student consisting of that student. Each repo is made private to that team.
- usage:
- pygrade init –org <name> –user <username> –pass <passwd> –remote <uri> [–students <file>] [–workdir <file>]
- Options
- -h, –help -o, –org <string> Name of the GitHub Organization for the course. -p, –pass <file> GitHub password -r, –remote <uri> URL of remote github repo used for starter code. -s, –students <file> Students TSV file [default: students.tsv] -u, –user <file> GitHub username -w, –workdir <file> Temporary directory for storing assignments [default: students]
pygrade.push module¶
Push grades to student repositories.
- usage:
- pygrade push [–grades <file>] [–workdir <file>]
- Options
- -h, –help -g, –grades <file> JSON grades output by the grade command [default: grades.json] -w, –workdir <file> Temporary directory for storing assignments [default: students]
pygrade.pygrade module¶
A command-line tool to auto-grade python assignments.
- usage:
- pygrade [–help] <command> [<args>…]
- The most commonly used pygrade commands are:
- cheat Detect plagiarism. clone Clone all student GitHub repositories. delete Delete student accounts. grade Grade assignments. init Initialize repositories. push Push grades to student repositories.
See ‘pygrade help <command>’ for more information on a specific command.
Module contents¶
-
pygrade.
extract_metadata
(text, result)[source]¶ >>> extract_metadata('@name=a0/foo.py', {})['files_to_test'] ['a0/foo.py'] >>> extract_metadata('@name=a0/foo.py,a0/bar.py', {})['files_to_test'] ['a0/foo.py', 'a0/bar.py'] >>> extract_metadata('@possible_points=12.4', {})['possible_points'] 12.4
-
pygrade.
get_local_repo
(s, path)[source]¶ Return the path to the local copy of this student’s repository.
-
pygrade.
path2name
(path)[source]¶ Get the basename of a file, minus any extensions. >>> path2name(‘foo/bar/baz.py’) ‘baz’