nathanael-fijalkow commited on
Commit
38d2a61
·
1 Parent(s): 5b08ad0

bytecode cache issue

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -163,7 +163,16 @@ def evaluate_submission(file_obj, debug=False):
163
  print(f"\n{'='*60}")
164
  print(f"EVALUATING: {file_path}")
165
  print(f"{'='*60}\n")
166
-
 
 
 
 
 
 
 
 
 
167
  # Import with a unique module name each time
168
  module_name = f"student_module_{int(time.time() * 1000000)}"
169
  spec = importlib.util.spec_from_file_location(module_name, file_path)
 
163
  print(f"\n{'='*60}")
164
  print(f"EVALUATING: {file_path}")
165
  print(f"{'='*60}\n")
166
+
167
+ # Clear bytecode cache to prevent "unmarshallable object" errors
168
+ from pathlib import Path
169
+ import shutil
170
+ pycache = Path(file_path).parent / "__pycache__"
171
+ if pycache.exists():
172
+ shutil.rmtree(pycache, ignore_errors=True)
173
+
174
+ print("### Cleared bytecode cache.")
175
+
176
  # Import with a unique module name each time
177
  module_name = f"student_module_{int(time.time() * 1000000)}"
178
  spec = importlib.util.spec_from_file_location(module_name, file_path)