dlai-grader 2.0b3__py3-none-any.whl → 2.1.0__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.

Potentially problematic release.


This version of dlai-grader might be problematic. Click here for more details.

dlai_grader/__init__.py CHANGED
@@ -6,6 +6,6 @@ from . import grading
6
6
  from . import types
7
7
 
8
8
 
9
- __version__ = "2.0b3"
9
+ __version__ = "2.1.0"
10
10
  __author__ = "Andres Zarta"
11
11
  __credits__ = "DeepLearning.AI"
dlai_grader/io.py CHANGED
@@ -257,6 +257,15 @@ def init_grader() -> None:
257
257
  os.makedirs("mount")
258
258
  os.makedirs("submission")
259
259
 
260
+ extra_file_name = template_dict["extra_file_name"]
261
+ if extra_file_name:
262
+ write_file_from_template(f"./learner/{extra_file_name}", "")
263
+ write_file_from_template(f"./mount/{extra_file_name}", "")
264
+
265
+ write_file_from_template(
266
+ "./mount/submission.ipynb", template_dict["submission_ipynb"]
267
+ )
268
+
260
269
  if "COPY data/ /grader/data/" in template_dict["dockerfile"]:
261
270
  os.makedirs("data")
262
271
 
@@ -3,6 +3,8 @@
3
3
  include .conf
4
4
 
5
5
  PARTIDS = 123 456
6
+ COURSERA_PARTIDS = "123 456"
7
+
6
8
  OS := $(shell uname)
7
9
 
8
10
  sync:
@@ -12,7 +14,8 @@ sync:
12
14
 
13
15
  learner:
14
16
  dlai_grader --learner --output_notebook=./learner/$(ASSIGNMENT_NAME).ipynb
15
- rsync -a --exclude="submission.ipynb" --exclude="__pycache__" --exclude=".mypy_cache" ./mount/ ./learner/
17
+ jupyter nbconvert --clear-output --inplace ./learner/$(ASSIGNMENT_NAME).ipynb
18
+ # rsync -a --exclude="submission.ipynb" --exclude="__pycache__" --exclude=".*" ./mount/ ./learner/
16
19
 
17
20
  build:
18
21
  docker build -t $(IMAGE_NAME):$(TAG_ID) .
@@ -48,7 +51,7 @@ upgrade:
48
51
  dlai_grader --upgrade
49
52
 
50
53
  coursera:
51
- dlai_grader --grade --partids="$(PARTIDS)" --docker=$(IMAGE_NAME):$(TAG_ID) --memory=$(MEMORY_LIMIT) --submission=$(SUB_DIR)
54
+ dlai_grader --grade --partids=$(COURSERA_PARTIDS) --docker=$(IMAGE_NAME):$(TAG_ID) --memory=$(MEMORY_LIMIT) --submission=$(SUB_DIR)
52
55
 
53
56
  zip:
54
57
  zip -r $(IMAGE_NAME)$(TAG_ID).zip .
@@ -1,10 +1,12 @@
1
1
  import traceback
2
- from dlai_grader.config import Config, get_part_id
2
+
3
+ from grader import handle_part_id
4
+
3
5
  from dlai_grader.compiler import compile_partial_module
4
- from dlai_grader.io import read_notebook, copy_submission_to_workdir, send_feedback
5
- from dlai_grader.notebook import keep_tagged_cells
6
+ from dlai_grader.config import Config, get_part_id
6
7
  from dlai_grader.grading import compute_grading_score, graded_obj_missing
7
- from grader import handle_part_id
8
+ from dlai_grader.io import copy_submission_to_workdir, read_notebook, send_feedback
9
+ from dlai_grader.notebook import keep_tagged_cells
8
10
 
9
11
 
10
12
  def notebook_grading(config, compile_solution=False):
@@ -15,6 +17,7 @@ def notebook_grading(config, compile_solution=False):
15
17
  send_feedback(0.0, msg, err=True)
16
18
 
17
19
  transformations = [keep_tagged_cells()]
20
+
18
21
  for t in transformations:
19
22
  nb = t(nb)
20
23
 
@@ -27,8 +30,10 @@ def notebook_grading(config, compile_solution=False):
27
30
  solution_mod = None
28
31
  if compile_solution:
29
32
  solution_nb = read_notebook(config.solution_file_path)
33
+
30
34
  for t in transformations:
31
35
  solution_nb = t(solution_nb)
36
+
32
37
  solution_mod = compile_partial_module(
33
38
  solution_nb,
34
39
  "solution_mod",
@@ -1,14 +1,17 @@
1
1
  import traceback
2
- from dlai_grader.config import Config, get_part_id
2
+ from pathlib import Path
3
+
4
+ from grader import handle_part_id
5
+
3
6
  from dlai_grader.compiler import compile_partial_module
4
- from dlai_grader.io import read_notebook, copy_submission_to_workdir, send_feedback
5
- from dlai_grader.notebook import keep_tagged_cells
7
+ from dlai_grader.config import Config, get_part_id
6
8
  from dlai_grader.grading import (
9
+ LearnerSubmission,
7
10
  compute_grading_score,
8
11
  graded_obj_missing,
9
- LearnerSubmission,
10
12
  )
11
- from grader import handle_part_id
13
+ from dlai_grader.io import copy_submission_to_workdir, read_notebook, send_feedback
14
+ from dlai_grader.notebook import keep_tagged_cells
12
15
 
13
16
 
14
17
  def notebook_grading(config, compile_solution=False):
@@ -19,6 +22,7 @@ def notebook_grading(config, compile_solution=False):
19
22
  send_feedback(0.0, msg, err=True)
20
23
 
21
24
  transformations = [keep_tagged_cells()]
25
+
22
26
  for t in transformations:
23
27
  nb = t(nb)
24
28
 
@@ -31,8 +35,10 @@ def notebook_grading(config, compile_solution=False):
31
35
  solution_mod = None
32
36
  if compile_solution:
33
37
  solution_nb = read_notebook(config.solution_file_path)
38
+
34
39
  for t in transformations:
35
40
  solution_nb = t(solution_nb)
41
+
36
42
  solution_mod = compile_partial_module(
37
43
  solution_nb,
38
44
  "solution_mod",
@@ -43,6 +49,10 @@ def notebook_grading(config, compile_solution=False):
43
49
 
44
50
 
45
51
  def non_notebook_grading(config):
52
+ if Path(config.submission_file_path).stat().st_size == 0:
53
+ msg = "Dummy file detected. Make sure you saved the correct file before submitting."
54
+ send_feedback(0.0, msg, err=True)
55
+
46
56
  try:
47
57
  with open(config.submission_file_path, "r") as file:
48
58
  contents = file.read()
@@ -57,7 +67,7 @@ def main() -> None:
57
67
  part_id = get_part_id()
58
68
 
59
69
  match part_id:
60
- case "123":
70
+ case "456":
61
71
  copy_submission_to_workdir(file_name="{{EXTRA_FILE_NAME}}")
62
72
  c = Config(submission_file="{{EXTRA_FILE_NAME}}")
63
73
  learner_mod = non_notebook_grading(c)
@@ -1,10 +1,12 @@
1
1
  import traceback
2
- from dlai_grader.config import Config, get_part_id
2
+
3
+ from grader import handle_part_id
4
+
3
5
  from dlai_grader.compiler import compile_partial_module
4
- from dlai_grader.io import read_notebook, copy_submission_to_workdir, send_feedback
5
- from dlai_grader.notebook import keep_tagged_cells
6
+ from dlai_grader.config import Config, get_part_id
6
7
  from dlai_grader.grading import compute_grading_score, graded_obj_missing
7
- from grader import handle_part_id
8
+ from dlai_grader.io import copy_submission_to_workdir, read_notebook, send_feedback
9
+ from dlai_grader.notebook import keep_tagged_cells
8
10
 
9
11
 
10
12
  def notebook_grading(config, compile_solution=False):
@@ -15,6 +17,7 @@ def notebook_grading(config, compile_solution=False):
15
17
  send_feedback(0.0, msg, err=True)
16
18
 
17
19
  transformations = [keep_tagged_cells()]
20
+
18
21
  for t in transformations:
19
22
  nb = t(nb)
20
23
 
@@ -27,8 +30,10 @@ def notebook_grading(config, compile_solution=False):
27
30
  solution_mod = None
28
31
  if compile_solution:
29
32
  solution_nb = read_notebook(config.solution_file_path)
33
+
30
34
  for t in transformations:
31
35
  solution_nb = t(solution_nb)
36
+
32
37
  solution_mod = compile_partial_module(
33
38
  solution_nb,
34
39
  "solution_mod",
@@ -1,4 +1,5 @@
1
1
  import traceback
2
+ from pathlib import Path
2
3
 
3
4
  from grader import handle_part_id
4
5
 
@@ -21,6 +22,7 @@ def notebook_grading(config, compile_solution=False):
21
22
  send_feedback(0.0, msg, err=True)
22
23
 
23
24
  transformations = [keep_tagged_cells()]
25
+
24
26
  for t in transformations:
25
27
  nb = t(nb)
26
28
 
@@ -33,8 +35,10 @@ def notebook_grading(config, compile_solution=False):
33
35
  solution_mod = None
34
36
  if compile_solution:
35
37
  solution_nb = read_notebook(config.solution_file_path)
38
+
36
39
  for t in transformations:
37
40
  solution_nb = t(solution_nb)
41
+
38
42
  solution_mod = compile_partial_module(
39
43
  solution_nb,
40
44
  "solution_mod",
@@ -45,6 +49,10 @@ def notebook_grading(config, compile_solution=False):
45
49
 
46
50
 
47
51
  def non_notebook_grading(config):
52
+ if Path(config.submission_file_path).stat().st_size == 0:
53
+ msg = "Dummy file detected. Make sure you saved the correct file before submitting."
54
+ send_feedback(0.0, msg, err=True)
55
+
48
56
  try:
49
57
  with open(config.submission_file_path, "r") as file:
50
58
  contents = file.read()
@@ -59,7 +67,7 @@ def main() -> None:
59
67
  part_id = get_part_id()
60
68
 
61
69
  match part_id:
62
- case "123":
70
+ case "456":
63
71
  copy_submission_to_workdir(file_name="{{EXTRA_FILE_NAME}}")
64
72
  c = Config(submission_file="{{EXTRA_FILE_NAME}}")
65
73
  learner_mod, solution_mod = non_notebook_grading(c), None
@@ -9,7 +9,6 @@ def part_1(
9
9
  ) -> grading_function:
10
10
  @object_to_grade(learner_mod, "learner_func")
11
11
  def g(learner_func: FunctionType) -> list[test_case]:
12
-
13
12
  cases: list[test_case] = []
14
13
 
15
14
  t = test_case()
@@ -27,6 +26,6 @@ def part_1(
27
26
 
28
27
  def handle_part_id(part_id: str) -> grading_wrapper:
29
28
  grader_dict: dict[str, grading_wrapper] = {
30
- "": part_1,
29
+ "123": part_1,
31
30
  }
32
- return grader_dict[part_id]
31
+ return grader_dict[part_id]
@@ -0,0 +1,45 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "60acce47",
6
+ "metadata": {},
7
+ "source": [
8
+ "## Replace dummy submission with actual assignment"
9
+ ]
10
+ },
11
+ {
12
+ "cell_type": "code",
13
+ "execution_count": null,
14
+ "id": "ecf4869a",
15
+ "metadata": {
16
+ "deletable": false,
17
+ "tags": [
18
+ "graded"
19
+ ]
20
+ },
21
+ "outputs": [],
22
+ "source": [
23
+ "# GRADED FUNCTION: learner_func\n",
24
+ "\n",
25
+ "\n",
26
+ "def learner_func():\n",
27
+ " return \"dummy submission\""
28
+ ]
29
+ }
30
+ ],
31
+ "metadata": {
32
+ "grader_version": "1",
33
+ "kernelspec": {
34
+ "display_name": "adlp",
35
+ "language": "python",
36
+ "name": "python3"
37
+ },
38
+ "language_info": {
39
+ "name": "python",
40
+ "version": "3.11.13"
41
+ }
42
+ },
43
+ "nbformat": 4,
44
+ "nbformat_minor": 5
45
+ }
dlai_grader/templates.py CHANGED
@@ -138,6 +138,17 @@ def copy_grader_py() -> str:
138
138
  return src.read_text(encoding="utf-8")
139
139
 
140
140
 
141
+ def copy_submission_ipynb() -> str:
142
+ base_dir = Path(__file__).parent
143
+ src = base_dir / "templates" / "submission.ipynb"
144
+
145
+ if not src.exists():
146
+ raise FileNotFoundError(f"Template not found: {src}")
147
+
148
+ # shutil.copy(src, dst)
149
+ return src.read_text(encoding="utf-8")
150
+
151
+
141
152
  def load_templates() -> dict[str, str]:
142
153
  specialization = input("Name of the specialization: ")
143
154
  course = input("Number of the course: ")
@@ -283,6 +294,8 @@ def load_templates() -> dict[str, str]:
283
294
 
284
295
  grader_py = copy_grader_py()
285
296
 
297
+ submission_ipynb = copy_submission_ipynb()
298
+
286
299
  entry_py = copy_entry_script(
287
300
  sol_dir_required=sol_dir_required,
288
301
  non_notebook_grading=non_notebook_grading,
@@ -295,7 +308,12 @@ def load_templates() -> dict[str, str]:
295
308
  "conf": dedent(conf[1:]),
296
309
  "grader_py": dedent(grader_py),
297
310
  "entry_py": dedent(entry_py),
311
+ "extra_file_name": extra_file_name,
312
+ "submission_ipynb": submission_ipynb,
298
313
  # "copy_assignment_to_submission_sh": dedent(copy_assignment_to_submission_sh),
299
314
  }
300
315
 
316
+ if extra_file_name:
317
+ template_dict.update({"extra_file_name": extra_file_name})
318
+
301
319
  return template_dict
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dlai-grader
3
- Version: 2.0b3
3
+ Version: 2.1.0
4
4
  Summary: Grading utilities for DLAI courses
5
5
  Home-page: https://github.com/https-deeplearning-ai/grader
6
6
  Author: Andres Zarta
@@ -0,0 +1,28 @@
1
+ dlai_grader/__init__.py,sha256=eSSeMZvJT85eAYGnh15B6EpWIP_pnZNdBJWJTKPvdjk,210
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=DokK1tVF_r7v0p9tWpBN-7lOAlPmHSpFXDZiI8cGw7s,1821
5
+ dlai_grader/grading.py,sha256=BMIoZ_loQDuNCEk1Dj3on4IWz-FGgIbnhbDyk8HmQ7c,5041
6
+ dlai_grader/io.py,sha256=0kMumpaOpKO0O5J00CbXZL-FZrsQ2-RobozDs5vDxnA,9573
7
+ dlai_grader/notebook.py,sha256=MgxZFuetTXwwZ-HXSB5ItLVD_9LP45E0xHAngS0g4EU,12101
8
+ dlai_grader/templates.py,sha256=gToTofemIAcgz5G343-RPLdfq0dJj66Nv4ERgHf7Ezw,9810
9
+ dlai_grader/types.py,sha256=5uiFaF3aDn-vjxTp9ec-ND-PRqeeV2_NfPHS2ngGsRo,306
10
+ dlai_grader/templates/Makefile,sha256=hQLhl-xLGw5WmACjlSGxlXA0Bc13XOY_4i5RaAunWlU,1904
11
+ dlai_grader/templates/grader.py,sha256=AeazA3RzXTmplAwsFuDR9XKOluRj-EJSkhMLzJFGioo,899
12
+ dlai_grader/templates/submission.ipynb,sha256=xfjI4j1ZJzU2cXwPnvjVKaP0mv5PKuDvrYFbyLI1SOs,749
13
+ dlai_grader/templates/copy_assignment_sh/extrafile_n,sha256=qB9ZViBm69r69nT9WXDaJfrW57sVho03aCZXbTS-lTc,430
14
+ dlai_grader/templates/copy_assignment_sh/extrafile_y,sha256=Zh07IAViyN-rELp4_-ZOJJSmTIigh0GxHLexW0ZGnMQ,616
15
+ dlai_grader/templates/dockerfile/data_n_solution_n,sha256=mD_fHhkzrGCCG3EPwXmafYVn1AoIcgBmSZLX8eCeH_g,447
16
+ dlai_grader/templates/dockerfile/data_n_solution_y,sha256=9iSyDj3-Jwm6RyAHNtVUDeD-XrYODB61i-HB3HfA70g,480
17
+ dlai_grader/templates/dockerfile/data_y_solution_n,sha256=i9nWcTAUCQzyhx3kM1aH64j0dkEMlYlEb6FFiE5k5oc,472
18
+ dlai_grader/templates/dockerfile/data_y_solution_y,sha256=xs6p-puJ-j5AeIuHiESL7X9kNSFZVCZ3Wb9SAW9KlUU,505
19
+ dlai_grader/templates/entry_py/solution_n_file_n.py,sha256=hZr5pcijXi-LOrJCInjEiiux5afIZXwhamdz_QjWCW0,2354
20
+ dlai_grader/templates/entry_py/solution_n_file_y.py,sha256=maEfF2sjM9J1xPWppAtaR5Qf1sjCyPivvvjxdEzDCjU,3212
21
+ dlai_grader/templates/entry_py/solution_y_file_n.py,sha256=ejRspmifrha0qY3WWUcHmbDQB86jXDpj6hdt-VFmntA,2402
22
+ dlai_grader/templates/entry_py/solution_y_file_y.py,sha256=AXDb3qzLLf1Z-gYqC29xI6ucxj02bLk6GrOBVREeGqA,3280
23
+ dlai_grader-2.1.0.dist-info/licenses/LICENSE,sha256=a_kch_UqdJPtyxk35QJr9O84K_koPixqWPYW9On4-io,1072
24
+ dlai_grader-2.1.0.dist-info/METADATA,sha256=FhNsrExqMRIUvx8lGLq0xzRHpL5G8bUINyLL6lqrCTU,8776
25
+ dlai_grader-2.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
26
+ dlai_grader-2.1.0.dist-info/entry_points.txt,sha256=4OcSAUIluONXa3ymViQ7CBQ2Lk52nb6xZnfph1rlMnk,71
27
+ dlai_grader-2.1.0.dist-info/top_level.txt,sha256=4YKtA3ztisFtx_g4hsGivy3J2NHnXxFziIMqawC8HWg,12
28
+ dlai_grader-2.1.0.dist-info/RECORD,,
@@ -1,27 +0,0 @@
1
- dlai_grader/__init__.py,sha256=kisxRYjpk8bk5dZK5AMHM69PqUB6bwdnig0LWjY9E0o,210
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=DokK1tVF_r7v0p9tWpBN-7lOAlPmHSpFXDZiI8cGw7s,1821
5
- dlai_grader/grading.py,sha256=BMIoZ_loQDuNCEk1Dj3on4IWz-FGgIbnhbDyk8HmQ7c,5041
6
- dlai_grader/io.py,sha256=5hs7Bv5zfyHKZUrFP-2gVH7y9dbIFsyGiKgsqFYbrMs,9250
7
- dlai_grader/notebook.py,sha256=MgxZFuetTXwwZ-HXSB5ItLVD_9LP45E0xHAngS0g4EU,12101
8
- dlai_grader/templates.py,sha256=OdmwnmNS2KCCcZ4-9jqfclV43tmbJoSuCk-5QWU6KoE,9291
9
- dlai_grader/types.py,sha256=5uiFaF3aDn-vjxTp9ec-ND-PRqeeV2_NfPHS2ngGsRo,306
10
- dlai_grader/templates/Makefile,sha256=PhRJ-87fU3IMqYMt9ChrAAfr2BPlk0uwogygLZItZL8,1795
11
- dlai_grader/templates/grader.py,sha256=492Dzs3enoCGfDviq_mdnrzeF5e1qNl21i42M5tjv4Y,896
12
- dlai_grader/templates/copy_assignment_sh/extrafile_n,sha256=qB9ZViBm69r69nT9WXDaJfrW57sVho03aCZXbTS-lTc,430
13
- dlai_grader/templates/copy_assignment_sh/extrafile_y,sha256=Zh07IAViyN-rELp4_-ZOJJSmTIigh0GxHLexW0ZGnMQ,616
14
- dlai_grader/templates/dockerfile/data_n_solution_n,sha256=mD_fHhkzrGCCG3EPwXmafYVn1AoIcgBmSZLX8eCeH_g,447
15
- dlai_grader/templates/dockerfile/data_n_solution_y,sha256=9iSyDj3-Jwm6RyAHNtVUDeD-XrYODB61i-HB3HfA70g,480
16
- dlai_grader/templates/dockerfile/data_y_solution_n,sha256=i9nWcTAUCQzyhx3kM1aH64j0dkEMlYlEb6FFiE5k5oc,472
17
- dlai_grader/templates/dockerfile/data_y_solution_y,sha256=xs6p-puJ-j5AeIuHiESL7X9kNSFZVCZ3Wb9SAW9KlUU,505
18
- dlai_grader/templates/entry_py/solution_n_file_n.py,sha256=Y9cuwGuCrRHWfWmcvNP-Gh8mFcJL_JE0e9Ed09O7x6Q,2349
19
- dlai_grader/templates/entry_py/solution_n_file_y.py,sha256=yHXK4iRVaxlhAwq3FiOfFEJdSRApfOgs3FMQtIe-A_c,2984
20
- dlai_grader/templates/entry_py/solution_y_file_n.py,sha256=MKVmgXJVC1UtxtChsah7jUQ6-SL93kafZ02KrSayN0k,2397
21
- dlai_grader/templates/entry_py/solution_y_file_y.py,sha256=7ioDw33vx0bRDw3yFlMX5DsjA2ZJxOL0g3s7ukQ36so,3054
22
- dlai_grader-2.0b3.dist-info/licenses/LICENSE,sha256=a_kch_UqdJPtyxk35QJr9O84K_koPixqWPYW9On4-io,1072
23
- dlai_grader-2.0b3.dist-info/METADATA,sha256=6Q4Ioa45aZ9Pof5bpa-pMm2av7gryZwnzf0Hcp94bdM,8776
24
- dlai_grader-2.0b3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
25
- dlai_grader-2.0b3.dist-info/entry_points.txt,sha256=4OcSAUIluONXa3ymViQ7CBQ2Lk52nb6xZnfph1rlMnk,71
26
- dlai_grader-2.0b3.dist-info/top_level.txt,sha256=4YKtA3ztisFtx_g4hsGivy3J2NHnXxFziIMqawC8HWg,12
27
- dlai_grader-2.0b3.dist-info/RECORD,,