You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In scispacy/train_utils.py line 29, evaluate_ner() opens a file handle for writing metrics but never closes it:
json.dump(metrics, open(dump_path, "a+"))
The open() call creates a file object that is passed directly to json.dump(). After json.dump() returns, the file handle is not explicitly closed. While CPython"s reference counting will eventually close it, this is not guaranteed on other Python implementations (PyPy, Jython) and is a resource leak.
More importantly, without explicit close/flush, the written data may not be flushed to disk immediately, which could cause data loss if the process crashes after this point.
Problem
In
scispacy/train_utils.pyline 29,evaluate_ner()opens a file handle for writing metrics but never closes it:The
open()call creates a file object that is passed directly tojson.dump(). Afterjson.dump()returns, the file handle is not explicitly closed. While CPython"s reference counting will eventually close it, this is not guaranteed on other Python implementations (PyPy, Jython) and is a resource leak.More importantly, without explicit close/flush, the written data may not be flushed to disk immediately, which could cause data loss if the process crashes after this point.
Affected File
scispacy/train_utils.pyline 29