PyKubeGrader 0.2.1__py3-none-any.whl → 0.2.2__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyKubeGrader
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: Add a short description here!
5
5
  Home-page: https://github.com/pyscaffold/pyscaffold/
6
6
  Author: jagar2
@@ -1,11 +1,11 @@
1
1
  pykubegrader/__init__.py,sha256=AoAkdfIjDDZGWLlsIRENNq06L9h46kDGBIE8vRmsCfg,311
2
2
  pykubegrader/initialize.py,sha256=t3iSdeIcndfY8LoHBVUEZfTW6sUWHyeFLirKo4GwSQE,3328
3
- pykubegrader/telemetry.py,sha256=jRInaDqIpdeT7F0rxLJgO38lA-SMtmLcYE8nEAGah1Q,4922
3
+ pykubegrader/telemetry.py,sha256=bgBWt9B3zqbfV2xWKDZKg41ZEBaF6X43O74do1fRylM,5325
4
4
  pykubegrader/utils.py,sha256=T3GYnLnTL9VXjTZNPr00sUgMgobQYsNTGwynMyXdvHk,696
5
5
  pykubegrader/validate.py,sha256=2KLSB3wfFZbBh1NGgmrOV073paKAgrQz4AgA6LmCIj4,11076
6
6
  pykubegrader/build/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
7
7
  pykubegrader/build/api_notebook_builder.py,sha256=FEaTj1fEsPAes7KNrPuhClEvKzLuOL3wG7Hgr7FQc-o,20083
8
- pykubegrader/build/build_folder.py,sha256=e27Ni64qpgmzg4Yu94nQieyK3IflZUQ0BvEOzwMGKMU,70729
8
+ pykubegrader/build/build_folder.py,sha256=uJ4pSokOEQ9OFw0MFNtFJ-IfvCC0knT3EPPPfY74cUQ,70942
9
9
  pykubegrader/build/clean_folder.py,sha256=8N0KyL4eXRs0DCw-V_2jR9igtFs_mOFMQufdL6tD-38,1323
10
10
  pykubegrader/graders/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
11
11
  pykubegrader/graders/late_assignments.py,sha256=_2-rA5RqO0BWY9WAQA_mbCxxPKTOiJOl-byD2CYWaE0,1393
@@ -24,9 +24,9 @@ pykubegrader/widgets_base/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-
24
24
  pykubegrader/widgets_base/multi_select.py,sha256=Cl0IN21wXLZuFu-zC65aS9tD4jMfzCRJ2DPjHao5_Ak,4044
25
25
  pykubegrader/widgets_base/reading.py,sha256=_vjUPynqmJe_R4vf-7hVhGnQR726S9GL6qT8bflBXBM,5383
26
26
  pykubegrader/widgets_base/select.py,sha256=Fw3uFNOIWo1a3CvlzSx23bvi6bSmA3TqutuRbhD4Dp8,2525
27
- PyKubeGrader-0.2.1.dist-info/LICENSE.txt,sha256=YTp-Ewc8Kems8PJEE27KnBPFnZSxoWvSg7nnknzPyYw,1546
28
- PyKubeGrader-0.2.1.dist-info/METADATA,sha256=tY6eIv1slUtGb-qLeuoxkXxPc55sAjxqGG_f9MFf5Oo,2729
29
- PyKubeGrader-0.2.1.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
30
- PyKubeGrader-0.2.1.dist-info/entry_points.txt,sha256=UPMdTT46fQwTYJWtrUwIWIbXbwyOPfNQgBFRa0frWzw,138
31
- PyKubeGrader-0.2.1.dist-info/top_level.txt,sha256=e550Klfze6higFxER1V62fnGOcIgiKRbsrl9CC4UdtQ,13
32
- PyKubeGrader-0.2.1.dist-info/RECORD,,
27
+ PyKubeGrader-0.2.2.dist-info/LICENSE.txt,sha256=YTp-Ewc8Kems8PJEE27KnBPFnZSxoWvSg7nnknzPyYw,1546
28
+ PyKubeGrader-0.2.2.dist-info/METADATA,sha256=HH2a7leI9j-Lf9pcak_eWU8zSiQusCes-5zqZtLQg0A,2729
29
+ PyKubeGrader-0.2.2.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
30
+ PyKubeGrader-0.2.2.dist-info/entry_points.txt,sha256=UPMdTT46fQwTYJWtrUwIWIbXbwyOPfNQgBFRa0frWzw,138
31
+ PyKubeGrader-0.2.2.dist-info/top_level.txt,sha256=e550Klfze6higFxER1V62fnGOcIgiKRbsrl9CC4UdtQ,13
32
+ PyKubeGrader-0.2.2.dist-info/RECORD,,
@@ -503,6 +503,9 @@ class NotebookProcessor:
503
503
  NotebookProcessor.add_initialization_code(
504
504
  temp_notebook_path, self.week, self.assignment_type
505
505
  )
506
+ NotebookProcessor.replace_temp_in_notebook(
507
+ temp_notebook_path, temp_notebook_path
508
+ )
506
509
  return None, 0
507
510
 
508
511
  @staticmethod
@@ -1398,6 +1401,8 @@ def clean_notebook(notebook_path):
1398
1401
  cell.metadata["editable"] = cell.metadata.get("editable", False)
1399
1402
  cell.metadata["deletable"] = cell.metadata.get("deletable", False)
1400
1403
  if cell.cell_type == "code":
1404
+ if "grader.check(" in cell.source:
1405
+ continue
1401
1406
  cell.metadata["tags"] = cell.metadata.get("tags", [])
1402
1407
  if "skip-execution" not in cell.metadata["tags"]:
1403
1408
  cell.metadata["tags"].append("skip-execution")
@@ -1563,7 +1568,7 @@ def generate_mcq_file(data_dict, output_file="mc_questions.py"):
1563
1568
  )
1564
1569
  f.write(" def __init__(self):\n")
1565
1570
  f.write(" super().__init__(\n")
1566
- f.write(f" title=f'{q_value['question_text']}',\n")
1571
+ f.write(f' title=f"{q_value['question_text']}",\n')
1567
1572
  f.write(" style=MCQ,\n")
1568
1573
  f.write(
1569
1574
  f" question_number={q_value['question number']},\n"
pykubegrader/telemetry.py CHANGED
@@ -10,6 +10,7 @@ import requests
10
10
  from IPython.core.interactiveshell import ExecutionInfo
11
11
  from requests import Response
12
12
  from requests.auth import HTTPBasicAuth
13
+ from requests.exceptions import RequestException
13
14
 
14
15
  #
15
16
  # Logging setup
@@ -122,7 +123,6 @@ def update_responses(key: str, value) -> dict:
122
123
  #
123
124
 
124
125
 
125
- # TODO: Improve error handling
126
126
  def score_question(
127
127
  term: str = "winter_2025",
128
128
  base_url: str = "https://engr-131-api.eastus.cloudapp.azure.com",
@@ -140,16 +140,24 @@ def score_question(
140
140
  "responses": responses,
141
141
  }
142
142
 
143
- res = requests.post(url, json=payload, auth=HTTPBasicAuth("student", "capture"))
144
-
145
- res_data: dict[str, tuple[float, float]] = res.json()
146
-
147
- for question, (points_earned, max_points) in res_data.items():
148
- log_variable(
149
- assignment_name=responses["assignment"],
150
- value=f"{points_earned}, {max_points}",
151
- info_type=question,
152
- )
143
+ try:
144
+ res = requests.post(url, json=payload, auth=HTTPBasicAuth("student", "capture"))
145
+ res.raise_for_status()
146
+
147
+ res_data: dict[str, tuple[float, float]] = res.json()
148
+
149
+ for question, (points_earned, max_points) in res_data.items():
150
+ log_variable(
151
+ assignment_name=responses["assignment"],
152
+ value=f"{points_earned}, {max_points}",
153
+ info_type=question,
154
+ )
155
+ except RequestException as e:
156
+ raise RuntimeError("Failed to access question-scoring endpoint") from e
157
+ except ValueError as e:
158
+ raise ValueError("Failed to parse question-scoring JSON response") from e
159
+ except Exception as e:
160
+ raise RuntimeError("Failed to score question") from e
153
161
 
154
162
 
155
163
  def submit_question(