EvaluationWorkspace
This commit is contained in:
+7
-10
@@ -12,6 +12,8 @@ import json
|
||||
import threading
|
||||
import concurrent.futures
|
||||
|
||||
from copienator import atomic_write_json
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
sys.exit("Usage: python script.py 'InterroTest/Ex 2/Group_1.jpg' OR <InputDir> OR 'file1' 'file2'")
|
||||
|
||||
@@ -504,13 +506,11 @@ def process_single_task(task_tuple, precomputed_response=None):
|
||||
results[label] = []
|
||||
results[label].append(json_data)
|
||||
|
||||
with open(output_path, "w", encoding="utf-8") as f:
|
||||
json.dump(results, f, indent=2)
|
||||
atomic_write_json(output_path, results)
|
||||
|
||||
# To track progress
|
||||
completed_tasks.append((file_path, label))
|
||||
with open(progress_path, "w", encoding="utf-8") as f:
|
||||
json.dump(completed_tasks, f, indent=2)
|
||||
atomic_write_json(progress_path, completed_tasks)
|
||||
|
||||
except json.JSONDecodeError:
|
||||
tprint(f"Error decoding JSON for {file_path}", file=sys.stderr)
|
||||
@@ -598,8 +598,7 @@ def resolve_delayed_moves():
|
||||
del res["delayed"]
|
||||
|
||||
if new_tasks:
|
||||
with open(output_path, "w", encoding="utf-8") as f:
|
||||
json.dump(results, f, indent=2)
|
||||
atomic_write_json(output_path, results)
|
||||
|
||||
return new_tasks
|
||||
|
||||
@@ -675,10 +674,8 @@ if __name__ == "__main__":
|
||||
tasks_to_process.append((new_group_path, label, not is_new))
|
||||
|
||||
if dirty_results:
|
||||
with open(output_path, "w", encoding="utf-8") as f:
|
||||
json.dump(results, f, indent=2)
|
||||
with open(overwritten_path, "w", encoding="utf-8") as f:
|
||||
json.dump(overwritten_data, f, indent=2)
|
||||
atomic_write_json(output_path, results)
|
||||
atomic_write_json(overwritten_path, overwritten_data)
|
||||
else:
|
||||
print(f"Warning: --refaire flag used, but {refaire_path} not found.", file=sys.stderr)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user