FileResultStore.delete_expired crashes on JSON-materialized cache results
メンテナーはふだん 3 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 75/100
調査の方向性
まず hamilton/caching/stores/file.py、特に FileResultStore.delete_expired() と _load_result_from_path() を確認し、次にファイルストアのテストでクリーンアップがカバーされているか調べます。対象を絞ったテストを実行し、JSONDataSaver と JSONDataLoader を使った回帰テストケースを追加します。クリーンアップが完了し、有効期限の切れていない結果を引き続き読み取れる状態になれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Current behavior
FileResultStore.delete_expired() raises UnpicklingError after storing a result with the built-in JSON saver/loader. The result can be read successfully before cleanup, and nothing has expired.
This prevents cleanup of a store containing valid JSON-materialized results.
Steps to reproduce
from pathlib import Path
from tempfile import TemporaryDirectory
from hamilton.caching.stores.file import FileResultStore
from hamilton.io.default_data_loaders import JSONDataLoader, JSONDataSaver
with TemporaryDirectory() as directory:
store = FileResultStore(directory)
store.set(
"example",
{"value": 1},
saver_cls=JSONDataSaver,
loader_cls=JSONDataLoader,
)
assert store.get("example") == {"value": 1}
print(sorted(path.name for path in Path(directory).iterdir()), flush=True)
store.delete_expired()
assert store.get("example") == {"value": 1}
Observed output and traceback (paths shortened):
['example', 'example.json']
Traceback (most recent call last):
File "repro.py", line 17, in <module>
store.delete_expired()
File "hamilton/caching/stores/file.py", line 138, in delete_expired
stored_result = self._load_result_from_path(file_path)
File "hamilton/caching/stores/file.py", line 55, in _load_result_from_path
return StoredResult.load(data)
File "hamilton/caching/stores/base.py", line 234, in load
loaded = pickle.loads(raw)
_pickle.UnpicklingError: invalid load key, '{'.
Expected behavior
Cleanup should complete without attempting to unpickle the JSON payload, and the unexpired result should remain readable.
Library and system information
- Hamilton 1.90.0, editable checkout at
2bd9dbc7ee22e1c2a4f6cd687a353aa0079d4d81 - Python 3.11.17, macOS arm64
- Compared both affected files (
caching/stores/file.pyandcaching/stores/base.py) with upstreammainatef88b1e96140a01f3d72967316c2335f8b62a067; they are byte-for-byte identical.
Proposed contribution
set() writes a pickled loader reference and a separate .json payload into the same directory. delete_expired() iterates every directory entry and passes each to StoredResult.load(), including the JSON payload.
I would like to contribute a focused fix that distinguishes stored-result entries from materialized payloads, with a regression test showing cleanup preserves a readable JSON result. Would you be open to me taking this on, and is there a preferred way to identify those entries? I would keep any broader expiration/serialization redesign separate.
- 主要言語
- Jupyter Notebook
- スター
- 2.6k
- フォーク
- 230
- 平均マージ
- 3日 3時間
- マージ済み PR(30日)
- 22
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/hamilton のほかの issue
-
Mypy supportオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 3 日以内に返信
-
FunctionInputOutputTypeChecker rejects correct values for fixed-length tuple annotations (tuple[int, str])対応中かも @tarang-tp が 26 日前に担当しました。 オープンbug core-work
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 3 日以内に返信
-
Engine crashes when client sends nan or inf float to UI再び着手できるかも @Exudev が 269 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンbug SDK
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
apache/hamilton#1458 · コメント 5 件 ·
メンテナーはふだん 3 日以内に返信
-
More detailed type annotations in graph visualizations再び着手できるかも @Nishant-Manocha が 404 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
apache/hamilton#1383 · コメント 4 件 ·
メンテナーはふだん 3 日以内に返信
-
Documentation: add explainer for FastAPI再び着手できるかも @Aditya-Deshwal23 が 223 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンdocumentation
難易度 2/5 1〜2日 初心者へのやさしさ 65/100
apache/hamilton#1304 · コメント 5 件 ·
メンテナーはふだん 3 日以内に返信
apache/hamilton の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
twilio/twilio-node#1241 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
tenstorrent/tt-umd#4017 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
UKGovernmentBEIS/inspect_ai#6695 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信