Bug
Environment
OS: Linux
Browser: Not applicable
Python: 3.12.11
AISteer360 commit: 1d7c84314b19341ac78c9ae4ee1eabf4e2f58632
Issue Summary
to_jsonable() does not recursively convert values inside NumPy arrays. It calls ndarray.tolist() and returns the resulting list directly.
For object arrays, values such as Path instances or sets remain unchanged. Benchmark._save_checkpoint() then passes the result to json.dump(), which raises TypeError instead of saving the checkpoint.
Steps to Reproduce
import json
from pathlib import Path
import numpy as np
from aisteer360.evaluation.utils.data_utils import to_jsonable
profiles = {
"params": np.array(
[Path("models/base"), {"layers": {1, 2}}],
dtype=object,
)
}
safe = to_jsonable(profiles)
json.dumps(safe)
The converted value still contains a Path and a set:
{'params': [PosixPath('models/base'), {'layers': {1, 2}}]}
The final call fails with:
TypeError: Object of type PosixPath is not JSON serializable
Expected Behaviour
Values produced by ndarray.tolist() should pass through the same recursive conversion used for ordinary lists. The result should be accepted by json.dump() so benchmark checkpoint saving does not fail.
Bug
Environment
OS: Linux
Browser: Not applicable
Python: 3.12.11
AISteer360 commit:
1d7c84314b19341ac78c9ae4ee1eabf4e2f58632Issue Summary
to_jsonable()does not recursively convert values inside NumPy arrays. It callsndarray.tolist()and returns the resulting list directly.For object arrays, values such as
Pathinstances or sets remain unchanged.Benchmark._save_checkpoint()then passes the result tojson.dump(), which raisesTypeErrorinstead of saving the checkpoint.Steps to Reproduce
The converted value still contains a
Pathand a set:The final call fails with:
Expected Behaviour
Values produced by
ndarray.tolist()should pass through the same recursive conversion used for ordinary lists. The result should be accepted byjson.dump()so benchmark checkpoint saving does not fail.