FileResultStore.delete_expired crashes on JSON-materialized cache results
Los mantenedores suelen responder en 3 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 75/100
Línea de trabajo
Empieza por hamilton/caching/stores/file.py, especialmente por FileResultStore.delete_expired() y _load_result_from_path(), y después inspecciona las pruebas del almacén de archivos para comprobar la cobertura de la limpieza. Ejecuta las pruebas específicas y añade un caso de regresión usando JSONDataSaver y JSONDataLoader; el trabajo estará terminado cuando la limpieza se complete y el resultado no vencido siga siendo legible.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Jupyter Notebook
- Estrellas
- 2.6k
- Forks
- 230
- Merge medio
- 3 d 3 h
- PR fusionados (30 d)
- 22
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de apache/hamilton
-
Mypy supportAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 3 días
-
FunctionInputOutputTypeChecker rejects correct values for fixed-length tuple annotations (tuple[int, str])Posiblemente ocupada @tarang-tp la tomó hace 26 días. Abiertobug core-work
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 3 días
-
Engine crashes when client sends nan or inf float to UIQuizá libre de nuevo @Exudev la tomó hace 269 días y no hay ningún pull request abierto. Abiertobug SDK
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
apache/hamilton#1458 · 5 comentarios ·
Los mantenedores suelen responder en 3 días
-
More detailed type annotations in graph visualizationsQuizá libre de nuevo @Nishant-Manocha la tomó hace 404 días y no hay ningún pull request abierto. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
apache/hamilton#1383 · 4 comentarios ·
Los mantenedores suelen responder en 3 días
-
Documentation: add explainer for FastAPIQuizá libre de nuevo @Aditya-Deshwal23 la tomó hace 223 días y no hay ningún pull request abierto. Abiertodocumentation
Dificultad 2/5 1-2 días Aptitud para principiantes 65/100
apache/hamilton#1304 · 5 comentarios ·
Los mantenedores suelen responder en 3 días
Todos los issues de apache/hamilton
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
twilio/twilio-node#1241 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
[UBSan] spawn_simulator passes null child_options.args to uv_spawn (execvp nonnull violation)Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
tenstorrent/tt-umd#4017 ·
Los mantenedores suelen responder en 3 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
UKGovernmentBEIS/inspect_ai#6695 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día