otter-grader
otter-grader copied to clipboard
Close file handles in otter check zip validation
Fixes a bug from Slack similar to #389.
We are running into PermissionError when we try to run the student version of the notebook file only on Windows platform. The same notebook file is working on MAC platform. Can you please tell us what we are missing here? I have attached a zip file of the entire directory, including the master notebook file and the student directory with the error.
Error details:
Running your submission against local test cases...
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
File ~\anaconda3\lib\site-packages\otter\check\utils.py:78, in grade_zip_file(zip_path, nb_arcname, tests_dir)
77 if results.stderr:
---> 78 raise RuntimeError(results.stderr)
80 with open(results_path, "rb") as f:
RuntimeError: b'Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.\r\n'
During handling of the above exception, another exception occurred:
PermissionError Traceback (most recent call last)
Input In [7], in <cell line: 2>()
1 # Save your notebook first, then run this cell to export your submission.
----> 2 grader.export(pdf=False, run_tests=True)
File ~\anaconda3\lib\site-packages\otter\check\utils.py:151, in grading_mode_disabled(wrapped, self, args, kwargs)
149 if type(self)._grading_mode:
150 return
--> 151 return wrapped(*args, **kwargs)
File ~\anaconda3\lib\site-packages\otter\check\utils.py:138, in incompatible_with.<locals>.incompatible(wrapped, self, args, kwargs)
136 else:
137 return
--> 138 return wrapped(*args, **kwargs)
File ~\anaconda3\lib\site-packages\otter\check\utils.py:188, in logs_event.<locals>.event_logger(wrapped, self, args, kwargs)
186 except Exception as e:
187 self._log_event(event_type, success=False, error=e)
--> 188 raise e
190 else:
191 self._log_event(event_type, results=results, question=question, shelve_env=shelve_env)
File ~\anaconda3\lib\site-packages\otter\check\utils.py:182, in logs_event.<locals>.event_logger(wrapped, self, args, kwargs)
179 question, results, shelve_env = wrapped(*args, **kwargs)
181 else:
--> 182 results = wrapped(*args, **kwargs)
183 shelve_env = {}
184 question = None
File ~\anaconda3\lib\site-packages\otter\check\notebook.py:415, in Notebook.export(self, nb_path, export_path, pdf, filtering, pagebreaks, files, display_link, force_save, run_tests)
413 if run_tests:
414 print("Running your submission against local test cases...\n")
--> 415 results = grade_zip_file(zip_path, nb_path, self._path)
416 print(
417 "Your submission received the following results when run against " + \
418 "available test cases:\n\n" + indent(results.summary(), " "))
420 if display_link:
421 # create and display output HTML
File ~\anaconda3\lib\site-packages\otter\check\utils.py:86, in grade_zip_file(zip_path, nb_arcname, tests_dir)
83 return results
85 finally:
---> 86 os.remove(results_path)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\user\\AppData\\Local\\Temp\\tmpg3gsknc3.pkl'
Codecov Report
Merging #523 (8360900) into master (faffd75) will decrease coverage by
0.04%
. The diff coverage is20.00%
.
@@ Coverage Diff @@
## master #523 +/- ##
==========================================
- Coverage 72.55% 72.50% -0.05%
==========================================
Files 64 64
Lines 3917 3921 +4
==========================================
+ Hits 2842 2843 +1
- Misses 1075 1078 +3
Impacted Files | Coverage Δ | |
---|---|---|
otter/check/utils.py | 65.48% <20.00%> (-1.49%) |
:arrow_down: |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.