Skip to content

fix: close metrics file and use write mode in evaluate_ner#603

Open
Chessing234 wants to merge 1 commit into
allenai:mainfrom
Chessing234:fix/evaluate-ner-metrics-write-mode
Open

fix: close metrics file and use write mode in evaluate_ner#603
Chessing234 wants to merge 1 commit into
allenai:mainfrom
Chessing234:fix/evaluate-ner-metrics-write-mode

Conversation

@Chessing234

Copy link
Copy Markdown

Fixes #597

evaluate_ner dumped metrics with json.dump(metrics, open(dump_path, "a+")), leaving the handle unclosed and using append mode. Each re-run to the same --output path concatenated JSON objects into an invalid file.

Use with open(dump_path, "w") so the file is closed/flushed and each evaluation overwrites with a single valid JSON object.

Made with Cursor

Use a context manager and "w" mode so metrics are flushed/closed and
re-runs overwrite instead of appending invalid concatenated JSON.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: unclosed file handle in evaluate_ner() when dumping metrics

1 participant