fix: unclosed file handle in evaluate_ner() when dumping metrics
- Lingua principale
- Python
- Stelle
- 2k
- Fork
- 258
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
## Problem
In `scispacy/train_utils.py` line 29, `evaluate_ner()` opens a file handle for writing metrics but never closes it:
```python
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.
## Affected File
- `scispacy/train_utils.py` line 29
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.