dlai-grader 1.21.3__py3-none-any.whl → 1.22.2__py3-none-any.whl

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.
dlai_grader/__init__.py CHANGED
@@ -6,6 +6,6 @@ from . import grading
6
6
  from . import types
7
7
 
8
8
 
9
- __version__ = "1.21.3"
9
+ __version__ = "1.22.2"
10
10
  __author__ = "Andres Zarta"
11
11
  __credits__ = "DeepLearning.AI"
dlai_grader/compiler.py CHANGED
@@ -48,6 +48,8 @@ def compile_partial_module(
48
48
  notebook (NotebookNode): Notebook from learner.
49
49
  module_name (str): Name of the module.
50
50
  verbose (bool): Whether to print out streams as a result of compilation. Defaults to True.
51
+ exit_on_error (bool): Whether to stop compilation if an exception is found. Defaults to False.
52
+ debug_mode (bool): Whether to print out cells where exceptions occurred. Defaults to False.
51
53
  Returns:
52
54
  ModuleType: The actual module that can be used to call functions/variables/etc.
53
55
  """
dlai_grader/grading.py CHANGED
@@ -146,8 +146,7 @@ def graded_obj_missing(test_cases: List[test_case]) -> bool:
146
146
  Returns:
147
147
  bool: True if object is missing. False otherwise.
148
148
  """
149
- if len(test_cases) == 1:
150
- if test_cases[0].got == type(None) or test_cases[0].got == None:
151
- return True
149
+ if len(test_cases) == 1 and test_cases[0].got == type(None):
150
+ return True
152
151
 
153
152
  return False
dlai_grader/io.py CHANGED
@@ -70,7 +70,7 @@ def uneditable_notebook(path: str) -> None:
70
70
  path (str): Path to the notebook.
71
71
  """
72
72
  nb = read_notebook(path)
73
- nb = add_metadata_code_cells_without_pattern(nb, {"editable": False})
73
+ nb = add_metadata_code_cells_without_pattern(nb, {"editable": False}, ignore_pattern="^# EDITABLE")
74
74
  jupytext.write(nb, path)
75
75
 
76
76
 
dlai_grader/notebook.py CHANGED
@@ -238,27 +238,31 @@ def add_metadata_code_cells_with_pattern(
238
238
 
239
239
 
240
240
  def add_metadata_code_cells_without_pattern(
241
- notebook: NotebookNode, metadata: dict, regex_pattern: str = "^# GRADED "
241
+ notebook: NotebookNode,
242
+ metadata: dict,
243
+ match_pattern: str = "^# GRADED ",
244
+ ignore_pattern: str = None
242
245
  ) -> NotebookNode:
243
- """Adds metadata to code cells of a notebook that don't match a regexp pattern.
246
+ """Adds metadata to code cells of a notebook that don't match a regexp pattern and aren't ignored by another pattern.
247
+
244
248
  Args:
245
249
  notebook (NotebookNode): Notebook to filter.
246
250
  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".
251
+ match_pattern (str, optional): Pattern to check which cells to add metadata to. Defaults to "^# GRADED ".
252
+ ignore_pattern (str, optional): Pattern to check which cells to ignore. If a cell matches this pattern, it will be skipped.
253
+
248
254
  Returns:
249
255
  NotebookNode: The notebook with the new metadata.
250
256
  """
251
- filtered_cells = []
252
-
253
257
  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
258
+ if cell["cell_type"] == "code":
259
+ if ignore_pattern and re.search(ignore_pattern, cell["source"]):
260
+ continue
261
+
262
+ if not re.search(match_pattern, cell["source"]):
263
+ current_metadata = cell.get("metadata", {})
264
+ current_metadata.update(metadata)
265
+ cell["metadata"] = current_metadata
262
266
 
263
267
  return notebook
264
268
 
dlai_grader/templates.py CHANGED
@@ -136,7 +136,7 @@ def load_templates() -> Dict[str, str]:
136
136
 
137
137
 
138
138
  def part_1(
139
- learner_mod: learner_submission, solution_mod: Optional[ModuleType]
139
+ learner_mod: learner_submission, solution_mod: Optional[ModuleType] = None
140
140
  ) -> grading_function:
141
141
  @object_to_grade(learner_mod, "learner_func")
142
142
  def g(learner_func: FunctionType) -> List[test_case]:
@@ -220,7 +220,7 @@ def load_templates() -> Dict[str, str]:
220
220
 
221
221
  solution_mod = compile_partial_module(solution_nb, "solution_mod", verbose=False)
222
222
 
223
- g_func = handle_part_id(c.part_id)(learner_mod, solution_mod)
223
+ g_func = handle_part_id(c.part_id)(learner_mod)
224
224
 
225
225
  try:
226
226
  cases = g_func()
@@ -1,27 +1,18 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.1
2
2
  Name: dlai-grader
3
- Version: 1.21.3
3
+ Version: 1.22.2
4
4
  Summary: Grading utilities for DLAI courses
5
5
  Home-page: https://github.com/https-deeplearning-ai/grader
6
6
  Author: Andres Zarta
7
7
  Author-email: andrezb5@gmail.com
8
- License: MIT License
8
+ License: MIT
9
9
  Classifier: Programming Language :: Python :: 3
10
10
  Classifier: License :: OSI Approved :: MIT License
11
11
  Classifier: Operating System :: OS Independent
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
- Requires-Dist: nbformat>=5.1.3
15
- Requires-Dist: jupytext>=1.13.0
16
- Dynamic: author
17
- Dynamic: author-email
18
- Dynamic: classifier
19
- Dynamic: description
20
- Dynamic: description-content-type
21
- Dynamic: home-page
22
- Dynamic: license
23
- Dynamic: requires-dist
24
- Dynamic: summary
14
+ Requires-Dist: nbformat >=5.1.3
15
+ Requires-Dist: jupytext >=1.13.0
25
16
 
26
17
  # grader
27
18
  Automatic grading for DLAI courses. Designed to be compatible with Coursera's grading requirements.
@@ -0,0 +1,16 @@
1
+ dlai_grader/__init__.py,sha256=NJssrhk1f1ZuaTeZOoOhn2cgxdwJV9v6bXD-7WdoS7M,211
2
+ dlai_grader/cli.py,sha256=NIwboE-AFn1LXOFmF4O70Ow0fkRxgclG_eMwmWiua38,4917
3
+ dlai_grader/compiler.py,sha256=elbHNUCqBCoOOoNmMRXbgeNL0nt0RM57eZi0-6AqycA,3036
4
+ dlai_grader/config.py,sha256=HQ3dzaFpRswIA_7EC8XdP8DdJH-XePsbMQMHG8Esblc,1638
5
+ dlai_grader/grading.py,sha256=Gmft9b7M8At_y_WZDatYdW6tinZMfqQoT7bDXp6uz2I,4606
6
+ dlai_grader/io.py,sha256=HybOy-0aPbJfxzQDjYOE2qo1myXKt0rlX90fzV1PXJo,8264
7
+ dlai_grader/notebook.py,sha256=66-08JUF5l5AS3UETYyTOn0mDjSPJtEetP7guiz4cYQ,12125
8
+ dlai_grader/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ dlai_grader/templates.py,sha256=u4BrPuDKefiyjKovxHPF0MbG73FvUIkLhgGpEWRYpL8,7843
10
+ dlai_grader/types.py,sha256=_IIVbYL9cMmwA6in0aI5fEWCIaAMNcQbxG64X1P1CkE,335
11
+ dlai_grader-1.22.2.dist-info/LICENSE,sha256=a_kch_UqdJPtyxk35QJr9O84K_koPixqWPYW9On4-io,1072
12
+ dlai_grader-1.22.2.dist-info/METADATA,sha256=oQls7F3kEzBalJF1ao-tP5cvRaLOk_lD0VXA6lXyalc,8612
13
+ dlai_grader-1.22.2.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
14
+ dlai_grader-1.22.2.dist-info/entry_points.txt,sha256=4OcSAUIluONXa3ymViQ7CBQ2Lk52nb6xZnfph1rlMnk,71
15
+ dlai_grader-1.22.2.dist-info/top_level.txt,sha256=4YKtA3ztisFtx_g4hsGivy3J2NHnXxFziIMqawC8HWg,12
16
+ dlai_grader-1.22.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.0)
2
+ Generator: setuptools (72.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,16 +0,0 @@
1
- dlai_grader/__init__.py,sha256=RmVoe5wZGbKwTovWgC1CeHmOu3lEF4KykNED6gcJais,211
2
- dlai_grader/cli.py,sha256=NIwboE-AFn1LXOFmF4O70Ow0fkRxgclG_eMwmWiua38,4917
3
- dlai_grader/compiler.py,sha256=ob-gIzTcqVVwER55H-gNdZogNxW50ETCguiuy3oNPps,2833
4
- dlai_grader/config.py,sha256=HQ3dzaFpRswIA_7EC8XdP8DdJH-XePsbMQMHG8Esblc,1638
5
- dlai_grader/grading.py,sha256=VnPH8JEU1j_IoJS6FiuumhmdxtekB5SKUC_5OU6ptu0,4647
6
- dlai_grader/io.py,sha256=TB9d01AK5FIbFUQwM8AqOOfuMWzjzrit98i3MhK5AqU,8234
7
- dlai_grader/notebook.py,sha256=noMU6DzPVylSjkHmSBUcmquVvAz4JigbRtbQrVYJdic,11830
8
- dlai_grader/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- dlai_grader/templates.py,sha256=JDDPoFm13pqRIOwSpt5kXXtMUM7jOv2Uyz1ap8KWu4I,7850
10
- dlai_grader/types.py,sha256=_IIVbYL9cMmwA6in0aI5fEWCIaAMNcQbxG64X1P1CkE,335
11
- dlai_grader-1.21.3.dist-info/LICENSE,sha256=a_kch_UqdJPtyxk35QJr9O84K_koPixqWPYW9On4-io,1072
12
- dlai_grader-1.21.3.dist-info/METADATA,sha256=3L8ag_gJJP0_9mwExpOoNDxl3MhNvJ_mDc4__twN_5Q,8807
13
- dlai_grader-1.21.3.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
14
- dlai_grader-1.21.3.dist-info/entry_points.txt,sha256=4OcSAUIluONXa3ymViQ7CBQ2Lk52nb6xZnfph1rlMnk,71
15
- dlai_grader-1.21.3.dist-info/top_level.txt,sha256=4YKtA3ztisFtx_g4hsGivy3J2NHnXxFziIMqawC8HWg,12
16
- dlai_grader-1.21.3.dist-info/RECORD,,