Repository navigation
Conversation
The JSONL event encoder handled only NumPy integers and floats and then raised for any other value. With log_to_file=True and verbosity=3, save(pathlib.Path(...)) therefore failed on its save_started event before writing the artifact. Encode paths with os.fspath, NumPy booleans and arrays as JSON values, and anything else by its string form, as write_run_config() and write_run_summary() already do. Fixes #545
ChrisW09
force-pushed
the
fix/jsonl-encoder
branch
from
October 21, 2026 21:58
a24f94d to
fbd029e
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #545
Problem
The
lifecycle.jsonlwriter serializes events with_JsonEncoder, which handled only NumPy integers and floats and otherwise calledjson.JSONEncoder.default, which raises. The exception propagated out of the event logger into the operation that emitted the event. Withstructured_logging=True,log_to_file=Trueandverbosity=3,model.save(pathlib.Path(...))failed on itssave_startedevent, beforetorch.saveran, so no artifact was written.Fix
_JsonEncoder.defaultindeeptab/core/observability.pynow also encodes:booland arrays as lists;os.fspath;str(o), the same fallback thatwrite_run_config()andwrite_run_summary()use (default=str).A value the JSON encoder could not serialize (paths, NumPy booleans and arrays, other objects) no longer makes the logged operation fail.
Tests
In
tests/core/test_observability.py:test_lifecycle_jsonl_records_values_json_cannot_encode: aPath, a NumPy integer, boolean and array, and an arbitrary object are written tolifecycle.jsonlwith the expected JSON values.test_save_to_a_path_object_with_file_logging: needsstructlog. A fittedMLPRegressorwith file logging at verbosity 3 saves to apathlib.Path, andsave_completedis logged.Both fail on
mainand pass with this change.Docs
No change needed.
Checks
just test: 3238 passed, 46 skipped, 28 xfailed; coverage 91.49%just docs: build succeeded (warnings treated as errors)just check: all hooks passed (ruff, prettier, pyright)