PyKubeGrader 0.2.20__tar.gz → 0.2.21__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {pykubegrader-0.2.20/src/PyKubeGrader.egg-info → pykubegrader-0.2.21}/PKG-INFO +1 -1
- {pykubegrader-0.2.20 → pykubegrader-0.2.21/src/PyKubeGrader.egg-info}/PKG-INFO +1 -1
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/src/pykubegrader/build/api_notebook_builder.py +6 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/src/pykubegrader/build/build_folder.py +57 -14
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/src/pykubegrader/tokens/validate_token.py +11 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/.coveragerc +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/.github/workflows/main.yml +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/.gitignore +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/.readthedocs.yml +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/AUTHORS.rst +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/CHANGELOG.rst +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/CONTRIBUTING.rst +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/LICENSE.txt +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/README.rst +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/docs/Makefile +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/docs/_static/Drexel_blue_Logo_square_Dark.png +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/docs/_static/Drexel_blue_Logo_square_Light.png +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/docs/_static/custom.css +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/docs/authors.rst +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/docs/changelog.rst +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/docs/conf.py +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/docs/contributing.rst +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/docs/index.rst +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/docs/license.rst +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/docs/readme.rst +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/docs/requirements.txt +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/examples/.responses.json +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/examples/true_false.ipynb +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/pyproject.toml +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/setup.cfg +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/setup.py +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/src/PyKubeGrader.egg-info/SOURCES.txt +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/src/PyKubeGrader.egg-info/dependency_links.txt +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/src/PyKubeGrader.egg-info/entry_points.txt +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/src/PyKubeGrader.egg-info/not-zip-safe +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/src/PyKubeGrader.egg-info/requires.txt +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/src/PyKubeGrader.egg-info/top_level.txt +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/src/pykubegrader/__init__.py +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/src/pykubegrader/build/__init__.py +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/src/pykubegrader/build/clean_folder.py +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/src/pykubegrader/graders/__init__.py +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/src/pykubegrader/graders/late_assignments.py +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/src/pykubegrader/initialize.py +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/src/pykubegrader/log_parser/__init__.py +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/src/pykubegrader/log_parser/parse.ipynb +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/src/pykubegrader/log_parser/parse.py +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/src/pykubegrader/submit/submit_assignment.py +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/src/pykubegrader/telemetry.py +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/src/pykubegrader/tokens/tokens.py +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/src/pykubegrader/utils.py +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/src/pykubegrader/validate.py +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/src/pykubegrader/widgets/__init__.py +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/src/pykubegrader/widgets/multiple_choice.py +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/src/pykubegrader/widgets/reading_question.py +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/src/pykubegrader/widgets/select_many.py +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/src/pykubegrader/widgets/student_info.py +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/src/pykubegrader/widgets/style.py +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/src/pykubegrader/widgets/true_false.py +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/src/pykubegrader/widgets/types_question.py +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/src/pykubegrader/widgets_base/__init__.py +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/src/pykubegrader/widgets_base/multi_select.py +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/src/pykubegrader/widgets_base/reading.py +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/src/pykubegrader/widgets_base/select.py +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/tests/conftest.py +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/tests/import_test.py +0 -0
- {pykubegrader-0.2.20 → pykubegrader-0.2.21}/tox.ini +0 -0
@@ -14,6 +14,7 @@ class FastAPINotebookBuilder:
|
|
14
14
|
notebook_path: str
|
15
15
|
temp_notebook: Optional[str] = None
|
16
16
|
assignment_tag: Optional[str] = ""
|
17
|
+
require_key: Optional[bool] = False
|
17
18
|
|
18
19
|
def __post_init__(self):
|
19
20
|
self.root_path, self.filename = FastAPINotebookBuilder.get_filename_and_root(
|
@@ -119,6 +120,11 @@ class FastAPINotebookBuilder:
|
|
119
120
|
f"os.environ['TOTAL_POINTS_FREE_RESPONSE'] = str({self.total_points})\n"
|
120
121
|
)
|
121
122
|
|
123
|
+
if self.require_key:
|
124
|
+
first_cell_header.append(
|
125
|
+
"from pykubegrader.submit.submit_assignment import validate_token\nvalidate_token()\n"
|
126
|
+
)
|
127
|
+
|
122
128
|
short_filename = self.filename.split(".")[0].replace("_temp", "")
|
123
129
|
first_cell_header.extend(
|
124
130
|
[
|
@@ -46,6 +46,7 @@ class NotebookProcessor:
|
|
46
46
|
solutions_folder: str = field(init=False)
|
47
47
|
verbose: bool = False
|
48
48
|
log: bool = True
|
49
|
+
require_key: bool = False
|
49
50
|
|
50
51
|
def __post_init__(self):
|
51
52
|
"""
|
@@ -559,11 +560,22 @@ class NotebookProcessor:
|
|
559
560
|
"you should see your score."
|
560
561
|
)
|
561
562
|
|
562
|
-
|
563
|
-
|
564
|
-
"from pykubegrader.submit.submit_assignment import
|
565
|
-
|
566
|
-
|
563
|
+
if self.require_key:
|
564
|
+
# Add an additional line for validate_token()
|
565
|
+
validate_token_line = "from pykubegrader.submit.submit_assignment import validate_token\nvalidate_token()\n"
|
566
|
+
|
567
|
+
# Define the Code cell
|
568
|
+
code_cell = nbformat.v4.new_code_cell(
|
569
|
+
f"{validate_token_line}\n\n" # Add the validate_token() line
|
570
|
+
"from pykubegrader.submit.submit_assignment import submit_assignment\n\n"
|
571
|
+
f'submit_assignment("week{self.week_num}-{self.assignment_type}", "{os.path.basename(notebook_path).replace(".ipynb", "")}")'
|
572
|
+
)
|
573
|
+
else:
|
574
|
+
# Define the Code cell without validate_token()
|
575
|
+
code_cell = nbformat.v4.new_code_cell(
|
576
|
+
"from pykubegrader.submit.submit_assignment import submit_assignment\n\n"
|
577
|
+
f'submit_assignment("week{self.week_num}-{self.assignment_type}", "{os.path.basename(notebook_path).replace(".ipynb", "")}")'
|
578
|
+
)
|
567
579
|
|
568
580
|
# Make the code cell non-editable and non-deletable
|
569
581
|
code_cell.metadata = {"editable": False, "deletable": False}
|
@@ -607,7 +619,9 @@ class NotebookProcessor:
|
|
607
619
|
shutil.copy("./keys/.server_public_key.bin", server_public_key)
|
608
620
|
|
609
621
|
out = FastAPINotebookBuilder(
|
610
|
-
notebook_path=temp_notebook_path,
|
622
|
+
notebook_path=temp_notebook_path,
|
623
|
+
assignment_tag=self.assignment_tag,
|
624
|
+
require_key=self.require_key,
|
611
625
|
)
|
612
626
|
|
613
627
|
debug_notebook = os.path.join(
|
@@ -632,7 +646,10 @@ class NotebookProcessor:
|
|
632
646
|
)
|
633
647
|
|
634
648
|
NotebookProcessor.add_initialization_code(
|
635
|
-
student_notebook,
|
649
|
+
student_notebook,
|
650
|
+
self.week,
|
651
|
+
self.assignment_type,
|
652
|
+
require_key=self.require_key,
|
636
653
|
)
|
637
654
|
|
638
655
|
NotebookProcessor.replace_temp_in_notebook(
|
@@ -659,7 +676,10 @@ class NotebookProcessor:
|
|
659
676
|
return student_notebook, out.total_points
|
660
677
|
else:
|
661
678
|
NotebookProcessor.add_initialization_code(
|
662
|
-
temp_notebook_path,
|
679
|
+
temp_notebook_path,
|
680
|
+
self.week,
|
681
|
+
self.assignment_type,
|
682
|
+
require_key=self.require_key,
|
663
683
|
)
|
664
684
|
NotebookProcessor.replace_temp_no_otter(
|
665
685
|
temp_notebook_path, temp_notebook_path
|
@@ -691,11 +711,19 @@ class NotebookProcessor:
|
|
691
711
|
nbformat.write(notebook, f)
|
692
712
|
|
693
713
|
@staticmethod
|
694
|
-
def add_initialization_code(
|
714
|
+
def add_initialization_code(
|
715
|
+
notebook_path, week, assignment_type, require_key=False
|
716
|
+
):
|
695
717
|
# finds the first code cell
|
696
718
|
index, cell = find_first_code_cell(notebook_path)
|
697
719
|
cell = cell["source"]
|
698
|
-
import_text = "
|
720
|
+
import_text = "# You must make sure to run all cells in sequence using shift + enter or you might encounter errors\n"
|
721
|
+
import_text += "from pykubegrader.initialize import initialize_assignment\n"
|
722
|
+
if require_key:
|
723
|
+
import_text += (
|
724
|
+
"from pykubegrader.token.validate_token import validate_token\n"
|
725
|
+
)
|
726
|
+
import_text += "validate_token('type the key provided by your TA here')\n"
|
699
727
|
import_text += f'\nresponses = initialize_assignment("{os.path.splitext(os.path.basename(notebook_path))[0]}", "{week}", "{assignment_type}" )\n'
|
700
728
|
cell = f"{import_text}\n" + cell
|
701
729
|
replace_cell_source(notebook_path, index, cell)
|
@@ -1740,7 +1768,9 @@ def generate_mcq_file(data_dict, output_file="mc_questions.py"):
|
|
1740
1768
|
)
|
1741
1769
|
f.write(" def __init__(self):\n")
|
1742
1770
|
f.write(" super().__init__(\n")
|
1743
|
-
f.write(
|
1771
|
+
f.write(
|
1772
|
+
f' title=f"Question{q_value['question number']}: {q_value['title']}",\n'
|
1773
|
+
)
|
1744
1774
|
f.write(" style=MCQ,\n")
|
1745
1775
|
f.write(
|
1746
1776
|
f" question_number={q_value['question number']},\n"
|
@@ -1811,7 +1841,9 @@ def generate_select_many_file(data_dict, output_file="select_many_questions.py")
|
|
1811
1841
|
)
|
1812
1842
|
f.write(" def __init__(self):\n")
|
1813
1843
|
f.write(" super().__init__(\n")
|
1814
|
-
f.write(
|
1844
|
+
f.write(
|
1845
|
+
f' title=f"Question{q_value['question number']}: {q_value['title']}",\n'
|
1846
|
+
)
|
1815
1847
|
f.write(" style=MultiSelect,\n")
|
1816
1848
|
f.write(
|
1817
1849
|
f" question_number={q_value['question number']},\n"
|
@@ -1888,7 +1920,9 @@ def generate_tf_file(data_dict, output_file="tf_questions.py"):
|
|
1888
1920
|
)
|
1889
1921
|
f.write(" def __init__(self):\n")
|
1890
1922
|
f.write(" super().__init__(\n")
|
1891
|
-
f.write(
|
1923
|
+
f.write(
|
1924
|
+
f' title=f"Question{q_value['question number']}: {q_value['title']}",\n'
|
1925
|
+
)
|
1892
1926
|
f.write(" style=TFStyle,\n")
|
1893
1927
|
f.write(
|
1894
1928
|
f" question_number={q_value['question number']},\n"
|
@@ -2060,9 +2094,18 @@ def main():
|
|
2060
2094
|
default="Reading-Week-X",
|
2061
2095
|
)
|
2062
2096
|
|
2097
|
+
parser.add_argument(
|
2098
|
+
"--require-key",
|
2099
|
+
type=bool,
|
2100
|
+
help="Require a key to be generated for the assignment",
|
2101
|
+
default=False,
|
2102
|
+
)
|
2103
|
+
|
2063
2104
|
args = parser.parse_args()
|
2064
2105
|
processor = NotebookProcessor(
|
2065
|
-
root_folder=args.root_folder,
|
2106
|
+
root_folder=args.root_folder,
|
2107
|
+
assignment_tag=args.assignment_tag,
|
2108
|
+
require_key=args.require_key,
|
2066
2109
|
)
|
2067
2110
|
processor.process_notebooks()
|
2068
2111
|
|
@@ -52,6 +52,16 @@ async def async_validate_token(token: str) -> None:
|
|
52
52
|
Returns:
|
53
53
|
None: If the token is valid, the function will pass silently.
|
54
54
|
"""
|
55
|
+
|
56
|
+
if token is not None:
|
57
|
+
os.environ["TOKEN"] = token
|
58
|
+
|
59
|
+
if token is None:
|
60
|
+
token = os.getenv("TOKEN", None)
|
61
|
+
|
62
|
+
if token is None:
|
63
|
+
raise TokenValidationError("No token provided")
|
64
|
+
|
55
65
|
# Fetch the endpoint URL
|
56
66
|
base_url = os.getenv("DB_URL")
|
57
67
|
if not base_url:
|
@@ -106,6 +116,7 @@ def validate_token(token: str) -> None:
|
|
106
116
|
Returns:
|
107
117
|
None: If the token is valid, the function will pass silently.
|
108
118
|
"""
|
119
|
+
|
109
120
|
# Get the current event loop or create one
|
110
121
|
try:
|
111
122
|
loop = asyncio.get_event_loop()
|
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
|
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
|
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
|
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
|
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
|
File without changes
|