dlai-grader 1.14.0__tar.gz → 1.16.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of dlai-grader might be problematic. Click here for more details.
- {dlai-grader-1.14.0 → dlai-grader-1.16.0}/PKG-INFO +1 -1
- {dlai-grader-1.14.0 → dlai-grader-1.16.0}/dlai_grader/__init__.py +1 -1
- {dlai-grader-1.14.0 → dlai-grader-1.16.0}/dlai_grader/cli.py +9 -0
- {dlai-grader-1.14.0 → dlai-grader-1.16.0}/dlai_grader/grading.py +9 -3
- {dlai-grader-1.14.0 → dlai-grader-1.16.0}/dlai_grader/io.py +13 -3
- {dlai-grader-1.14.0 → dlai-grader-1.16.0}/dlai_grader/notebook.py +26 -0
- {dlai-grader-1.14.0 → dlai-grader-1.16.0}/dlai_grader/templates.py +4 -1
- {dlai-grader-1.14.0 → dlai-grader-1.16.0}/dlai_grader.egg-info/PKG-INFO +1 -1
- {dlai-grader-1.14.0 → dlai-grader-1.16.0}/setup.py +1 -1
- {dlai-grader-1.14.0 → dlai-grader-1.16.0}/LICENSE +0 -0
- {dlai-grader-1.14.0 → dlai-grader-1.16.0}/README.md +0 -0
- {dlai-grader-1.14.0 → dlai-grader-1.16.0}/dlai_grader/compiler.py +0 -0
- {dlai-grader-1.14.0 → dlai-grader-1.16.0}/dlai_grader/config.py +0 -0
- {dlai-grader-1.14.0 → dlai-grader-1.16.0}/dlai_grader/py.typed +0 -0
- {dlai-grader-1.14.0 → dlai-grader-1.16.0}/dlai_grader/types.py +0 -0
- {dlai-grader-1.14.0 → dlai-grader-1.16.0}/dlai_grader.egg-info/SOURCES.txt +0 -0
- {dlai-grader-1.14.0 → dlai-grader-1.16.0}/dlai_grader.egg-info/dependency_links.txt +0 -0
- {dlai-grader-1.14.0 → dlai-grader-1.16.0}/dlai_grader.egg-info/entry_points.txt +0 -0
- {dlai-grader-1.14.0 → dlai-grader-1.16.0}/dlai_grader.egg-info/requires.txt +0 -0
- {dlai-grader-1.14.0 → dlai-grader-1.16.0}/dlai_grader.egg-info/top_level.txt +0 -0
- {dlai-grader-1.14.0 → dlai-grader-1.16.0}/setup.cfg +0 -0
|
@@ -5,6 +5,7 @@ from .io import (
|
|
|
5
5
|
update_notebook_version,
|
|
6
6
|
tag_notebook,
|
|
7
7
|
undeletable_notebook,
|
|
8
|
+
uneditable_notebook,
|
|
8
9
|
init_grader,
|
|
9
10
|
generate_learner_version,
|
|
10
11
|
grade_parts,
|
|
@@ -47,6 +48,12 @@ def parse_dlai_grader_args() -> None:
|
|
|
47
48
|
action="store_true",
|
|
48
49
|
help="Make all code cells of notebook not deletable.",
|
|
49
50
|
)
|
|
51
|
+
parser.add_argument(
|
|
52
|
+
"-ue",
|
|
53
|
+
"--uneditable",
|
|
54
|
+
action="store_true",
|
|
55
|
+
help="Make all non-graded code cells of notebook not editable.",
|
|
56
|
+
)
|
|
50
57
|
parser.add_argument(
|
|
51
58
|
"-l",
|
|
52
59
|
"--learner",
|
|
@@ -109,6 +116,8 @@ def parse_dlai_grader_args() -> None:
|
|
|
109
116
|
tag_notebook("./mount/submission.ipynb")
|
|
110
117
|
if args.undeletable:
|
|
111
118
|
undeletable_notebook("./mount/submission.ipynb")
|
|
119
|
+
if args.uneditable:
|
|
120
|
+
uneditable_notebook("./mount/submission.ipynb")
|
|
112
121
|
|
|
113
122
|
if args.learner:
|
|
114
123
|
filename_source = "./mount/submission.ipynb"
|
|
@@ -40,7 +40,13 @@ def compute_grading_score(
|
|
|
40
40
|
"""
|
|
41
41
|
|
|
42
42
|
num_cases = len(test_cases)
|
|
43
|
-
|
|
43
|
+
if num_cases == 0:
|
|
44
|
+
return (
|
|
45
|
+
0.0,
|
|
46
|
+
"The grader was unable to generate test cases for your implementation. This suggests a bug with your code, please revise your solution and try again.",
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
failed_cases = [t for t in test_cases if t.failed]
|
|
44
50
|
score = 1.0 - len(failed_cases) / num_cases
|
|
45
51
|
feedback_msg = "All tests passed! Congratulations!"
|
|
46
52
|
|
|
@@ -68,7 +74,7 @@ def compute_aggregated_grading_score(
|
|
|
68
74
|
for test_cases in aggregated_test_cases:
|
|
69
75
|
feedback_msg = f"All tests passed for {test_cases.test_name}!\n"
|
|
70
76
|
num_cases = len(test_cases.tests)
|
|
71
|
-
failed_cases = [t for t in test_cases.tests if t.failed
|
|
77
|
+
failed_cases = [t for t in test_cases.tests if t.failed]
|
|
72
78
|
score = 1.0 - len(failed_cases) / num_cases
|
|
73
79
|
score = round(score, 2)
|
|
74
80
|
scores.append(score)
|
|
@@ -117,7 +123,7 @@ def print_feedback(test_cases: List[test_case]) -> None:
|
|
|
117
123
|
Args:
|
|
118
124
|
test_cases (List[test_case]): List of public test cases.
|
|
119
125
|
"""
|
|
120
|
-
failed_cases = [t for t in test_cases if t.failed
|
|
126
|
+
failed_cases = [t for t in test_cases if t.failed]
|
|
121
127
|
feedback_msg = "\033[92m All tests passed!"
|
|
122
128
|
|
|
123
129
|
if failed_cases:
|
|
@@ -12,7 +12,7 @@ from nbformat.notebooknode import NotebookNode
|
|
|
12
12
|
from contextlib import contextmanager, redirect_stderr, redirect_stdout
|
|
13
13
|
from .notebook import (
|
|
14
14
|
add_metadata_all_code_cells,
|
|
15
|
-
|
|
15
|
+
add_metadata_code_cells_without_pattern,
|
|
16
16
|
tag_code_cells,
|
|
17
17
|
solution_to_learner_format,
|
|
18
18
|
)
|
|
@@ -53,14 +53,24 @@ def tag_notebook(
|
|
|
53
53
|
|
|
54
54
|
|
|
55
55
|
def undeletable_notebook(path: str) -> None:
|
|
56
|
-
"""Makes all code cells of a notebook non-deletable
|
|
56
|
+
"""Makes all code cells of a notebook non-deletable.
|
|
57
57
|
|
|
58
58
|
Args:
|
|
59
59
|
path (str): Path to the notebook.
|
|
60
60
|
"""
|
|
61
61
|
nb = read_notebook(path)
|
|
62
62
|
nb = add_metadata_all_code_cells(nb, {"deletable": False})
|
|
63
|
-
|
|
63
|
+
jupytext.write(nb, path)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def uneditable_notebook(path: str) -> None:
|
|
67
|
+
"""Makes all non-graded code cells of a notebook non-editable.
|
|
68
|
+
|
|
69
|
+
Args:
|
|
70
|
+
path (str): Path to the notebook.
|
|
71
|
+
"""
|
|
72
|
+
nb = read_notebook(path)
|
|
73
|
+
nb = add_metadata_code_cells_without_pattern(nb, {"editable": False})
|
|
64
74
|
jupytext.write(nb, path)
|
|
65
75
|
|
|
66
76
|
|
|
@@ -237,6 +237,32 @@ def add_metadata_code_cells_with_pattern(
|
|
|
237
237
|
return notebook
|
|
238
238
|
|
|
239
239
|
|
|
240
|
+
def add_metadata_code_cells_without_pattern(
|
|
241
|
+
notebook: NotebookNode, metadata: dict, regex_pattern: str = "^# GRADED "
|
|
242
|
+
) -> NotebookNode:
|
|
243
|
+
"""Adds metadata to code cells of a notebook that don't match a regexp pattern.
|
|
244
|
+
Args:
|
|
245
|
+
notebook (NotebookNode): Notebook to filter.
|
|
246
|
+
metadata (dict): The metadata which should be a key-value pair.
|
|
247
|
+
regex_pattern (str, optional): Pattern to check. Defaults to "w[1-9]_unittest".
|
|
248
|
+
Returns:
|
|
249
|
+
NotebookNode: The notebook with the new metadata.
|
|
250
|
+
"""
|
|
251
|
+
filtered_cells = []
|
|
252
|
+
|
|
253
|
+
for cell in notebook["cells"]:
|
|
254
|
+
if cell["cell_type"] == "code" and not re.search(regex_pattern, cell["source"]):
|
|
255
|
+
current_metadata = cell["metadata"]
|
|
256
|
+
current_metadata.update(metadata)
|
|
257
|
+
cell["metadata"] = current_metadata
|
|
258
|
+
|
|
259
|
+
filtered_cells.append(cell)
|
|
260
|
+
|
|
261
|
+
notebook["cells"] = filtered_cells
|
|
262
|
+
|
|
263
|
+
return notebook
|
|
264
|
+
|
|
265
|
+
|
|
240
266
|
def notebook_version(
|
|
241
267
|
notebook: NotebookNode,
|
|
242
268
|
) -> str:
|
|
@@ -47,7 +47,7 @@ def load_templates() -> Dict[str, str]:
|
|
|
47
47
|
"""
|
|
48
48
|
|
|
49
49
|
makefile = """
|
|
50
|
-
.PHONY: learner build entry submit-solution upgrade test grade mem zip clean upload move-zip move-learner tag undeletable versioning upgrade sync
|
|
50
|
+
.PHONY: learner build entry submit-solution upgrade test grade mem zip clean upload move-zip move-learner tag undeletable uneditable versioning upgrade sync
|
|
51
51
|
|
|
52
52
|
include .conf
|
|
53
53
|
|
|
@@ -79,6 +79,9 @@ def load_templates() -> Dict[str, str]:
|
|
|
79
79
|
undeletable:
|
|
80
80
|
dlai_grader --undeletable
|
|
81
81
|
|
|
82
|
+
uneditable:
|
|
83
|
+
dlai_grader --uneditable
|
|
84
|
+
|
|
82
85
|
upgrade:
|
|
83
86
|
dlai_grader --upgrade
|
|
84
87
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|