fix: unclosed file handle in evaluate_ner() when dumping metrics
- 主要語言
- Python
- 星號
- 2k
- 分支
- 258
- PR 合併指標
- 30 天內沒有已合併 PR
描述
## 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
貢獻指南
這個儲存庫沒有索引到貢獻指南
研究方向
Start in scispacy/train_utils.py at evaluate_ner(), especially the metrics dump on line 29, and inspect how its file handle is managed. Done means the metrics are written with explicit resource cleanup so the handle is closed and data is flushed after dumping.
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- machine-learning
- Issue 類型
- 缺陷
- 難度
- 1/5
- 預估耗時
- 1 小時以內
- 活躍度
- 冷清
- 描述清晰度
- 描述清楚
- 新手友好度
- 84/100