Skip to content

Commit 1f5d857

Browse files
committed
fix: Copy filtered submission files before converting notebooks
This ensures that all the files that should be included in the submission are copied. The original notebooks, which are to be autograded, are later overwritten with their converted versions, which is fine.
1 parent 70595dd commit 1f5d857

File tree

1 file changed

+7
-8
lines changed
  • grader_service/convert/converters

1 file changed

+7
-8
lines changed

grader_service/convert/converters/base.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,6 @@ def matches_allowed_patterns(file_path):
264264
"""
265265
Check if a file matches any of the allowed glob patterns.
266266
"""
267-
# Note: ignoring notebooks is needed to not overwrite converted notebooks
268-
# with the original ones as currently the copying process is done after the conversion
269-
if file_path.endswith(".ipynb"):
270-
return False
271267
return any(fnmatch.fnmatch(file_path, pattern) for pattern in files_patterns)
272268

273269
def is_ignored(file_path):
@@ -289,6 +285,9 @@ def is_ignored(file_path):
289285
] # Modify dirs in-place to ignore unwanted dirs
290286

291287
for file in files:
288+
if file == "gradebook.json":
289+
continue
290+
292291
abs_file_path = os.path.join(root, file)
293292
rel_file_path = os.path.relpath(abs_file_path, src)
294293

@@ -345,6 +344,10 @@ def _handle_failure(exception) -> None:
345344
if not should_process:
346345
return
347346

347+
json_path = os.path.join(self._output_directory, "gradebook.json")
348+
with Gradebook(json_path) as gb:
349+
self.copy_unmatched_files(gb)
350+
348351
self.run_pre_convert_hook()
349352

350353
# convert all the notebooks
@@ -355,10 +358,6 @@ def _handle_failure(exception) -> None:
355358
self.set_permissions()
356359
self.run_post_convert_hook()
357360

358-
json_path = os.path.join(self._output_directory, "gradebook.json")
359-
with Gradebook(json_path) as gb:
360-
self.copy_unmatched_files(gb)
361-
362361
except UnresponsiveKernelError as e:
363362
self.log.error(
364363
"While processing files %s, the kernel became "

0 commit comments

Comments
 (0)