FileResultStore.delete_expired crashes on JSON-materialized cache results
Maintainer thường phản hồi trong vòng 3 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 75/100
Hướng nghiên cứu
Bắt đầu với hamilton/caching/stores/file.py, đặc biệt là FileResultStore.delete_expired() và _load_result_from_path(), sau đó kiểm tra các bài kiểm thử của kho lưu trữ tệp để xem mức độ bao phủ của việc dọn dẹp. Chạy các bài kiểm thử tập trung và thêm một trường hợp hồi quy sử dụng JSONDataSaver và JSONDataLoader; hoàn thành khi việc dọn dẹp kết thúc và kết quả chưa hết hạn vẫn đọc được.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Jupyter Notebook
- Star
- 2.6k
- Fork
- 230
- Merge trung bình
- 3 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 22
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của apache/hamilton
-
Mypy supportĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 3 ngày
-
FunctionInputOutputTypeChecker rejects correct values for fixed-length tuple annotations (tuple[int, str])Có thể đã có người làm @tarang-tp đã nhận 26 ngày trước. Đang mởbug core-work
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Engine crashes when client sends nan or inf float to UICó thể làm lại được @Exudev đã nhận 269 ngày trước và không có pull request nào đang mở. Đang mởbug SDK
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
apache/hamilton#1458 · 5 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
More detailed type annotations in graph visualizationsCó thể làm lại được @Nishant-Manocha đã nhận 404 ngày trước và không có pull request nào đang mở. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
apache/hamilton#1383 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Documentation: add explainer for FastAPICó thể làm lại được @Aditya-Deshwal23 đã nhận 223 ngày trước và không có pull request nào đang mở. Đang mởdocumentation
Độ khó 2/5 1-2 ngày Mức phù hợp với người mới 65/100
apache/hamilton#1304 · 5 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
Tất cả issue của apache/hamilton
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
twilio/twilio-node#1241 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[UBSan] spawn_simulator passes null child_options.args to uv_spawn (execvp nonnull violation)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
tenstorrent/tt-umd#4017 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
UKGovernmentBEIS/inspect_ai#6695 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày