Skip to content

Commit d221d82

Browse files
pass args in from top function
1 parent d4b1bc4 commit d221d82

File tree

2 files changed

+38
-26
lines changed

2 files changed

+38
-26
lines changed

marking_and_admin/mark_functions.py

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ def update_repos(row: Series) -> str:
301301
return message
302302

303303

304-
def try_to_kill(file_path: str, CHATTY: bool = False):
304+
def try_to_kill(file_path: str):
305305
"""Attempt to delete the file specified by file_path."""
306306
try:
307307
os.remove(file_path)
@@ -311,9 +311,9 @@ def try_to_kill(file_path: str, CHATTY: bool = False):
311311
print(file_path, mystery_error)
312312

313313

314-
def pull_all_repos(dir_list, CHATTY: bool = False, hardcore_pull: bool = False):
314+
def pull_all_repos(dir_list, hardcore_pull: bool = False):
315315
"""Pull latest version of all repos."""
316-
# TODO: make sure chatty is actually a global
316+
317317
of_total = len(dir_list)
318318
for i, student_repo in enumerate(dir_list):
319319
repo_is_here = os.path.join(ROOTDIR, student_repo)
@@ -666,12 +666,12 @@ def do_the_marking(
666666
force_marking=False,
667667
marking_spreadsheet_id: str = "16tESt_4BUf-9-oD04suTprkd1O0oEl6WjzflF_avSKY", # 2022
668668
marks_csv: str = "marks.csv",
669-
mark_w1: bool = True,
670-
mark_w2: bool = False,
671-
mark_w3: bool = False,
672-
mark_w4: bool = False,
673-
mark_w5: bool = False,
674-
mark_exam: bool = False,
669+
w1: dict[str, int | bool] = {"timeout": 5, "active": False},
670+
w2: dict[str, int | bool] = {"timeout": 5, "active": False},
671+
w3: dict[str, int | bool] = {"timeout": 5, "active": False},
672+
w4: dict[str, int | bool] = {"timeout": 5, "active": False},
673+
w5: dict[str, int | bool] = {"timeout": 5, "active": False},
674+
exam: dict[str, int | bool] = {"timeout": 5, "active": False},
675675
test_number_of_students: int = 0,
676676
force_repos: list[str] = [],
677677
) -> None:
@@ -728,14 +728,23 @@ def do_the_marking(
728728
mark_sheet["updated"] = mark_sheet.apply(update_repos, axis=1)
729729
mark_sheet["last_commit"] = mark_sheet.apply(get_last_commit, axis=1)
730730

731-
# TODO: Pass in timeouts and activity through the args, probably like {timeout=15, active=True}
732-
mark_sheet["set1"] = mark_week(mark_sheet, set_number=1, timeout=15, active=mark_w1)
733-
mark_sheet["set2"] = mark_week(mark_sheet, set_number=2, timeout=15, active=mark_w2)
734-
mark_sheet["set3"] = mark_week(mark_sheet, set_number=3, timeout=30, active=mark_w3)
735-
mark_sheet["set4"] = mark_week(mark_sheet, set_number=4, timeout=50, active=mark_w4)
736-
mark_sheet["set5"] = mark_week(mark_sheet, set_number=5, timeout=50, active=mark_w5)
731+
mark_sheet["set1"] = mark_week(
732+
mark_sheet, set_number=1, timeout=w1["timeout"], active=w1["active"]
733+
)
734+
mark_sheet["set2"] = mark_week(
735+
mark_sheet, set_number=2, timeout=w2["timeout"], active=w2["active"]
736+
)
737+
mark_sheet["set3"] = mark_week(
738+
mark_sheet, set_number=3, timeout=w3["timeout"], active=w3["active"]
739+
)
740+
mark_sheet["set4"] = mark_week(
741+
mark_sheet, set_number=4, timeout=w4["timeout"], active=w4["active"]
742+
)
743+
mark_sheet["set5"] = mark_week(
744+
mark_sheet, set_number=5, timeout=w5["timeout"], active=w5["active"]
745+
)
737746
mark_sheet["exam"] = mark_week(
738-
mark_sheet, set_number=8, timeout=45, active=mark_exam
747+
mark_sheet, set_number=8, timeout=exam["timeout"], active=exam["active"]
739748
)
740749
mark_sheet.drop(["name"], axis=1, errors="ignore", inplace=True)
741750

@@ -790,9 +799,6 @@ def convert_one_results_dict_to_an_int(results_dict) -> int:
790799

791800

792801
def get_student_data():
793-
# TODO: instead of loading the pickle, load the marks.csv file so that
794-
# the dataframe is preloaded with values. Then it doesn't need to mark students
795-
# that haven't updated their work.
796802
students = None
797803
file_name = "student.json"
798804
if os.path.exists(file_name):

marking_and_admin/marker.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,18 @@
2222
force_marking=True,
2323
marking_spreadsheet_id=MARKING_SPREADSHEET_ID,
2424
marks_csv="marking_and_admin/marks.csv",
25-
mark_w1=True,
26-
mark_w2=True,
27-
mark_w3=True,
28-
mark_w4=True,
29-
mark_w5=False,
30-
mark_exam=False,
25+
mark_w1={"timeout":15, "active":True},
26+
mark_w2={"timeout":15, "active":True},
27+
mark_w3={"timeout":30, "active":True},
28+
mark_w4={"timeout":50, "active":True},
29+
mark_w5={"timeout":50, "active":False},
30+
mark_exam={"timeout":45, "active":True},
3131
test_number_of_students=0, # if more than 0, will only mark a sample of N repos
32-
force_repos=["lvl-lim"],
32+
force_repos=["lvl-lim", "JeWang"],
33+
)
34+
elif MARKING_SPREADSHEET_ID == "":
35+
print(
36+
"The MARKING_SPREADSHEET_ID is supposed to come from the env. Either "
37+
"Ben hasn't granted you permissions, or the env is broken in some way."
38+
"It's stored in the codespace's secrets."
3339
)

0 commit comments

Comments
 (0)