Let a jsonl export keep a record a value
`--format jsonl` existed, but `_cell` ran json.dumps at row-build time, before a format was chosen — so a nested value was a string by then and jsonl only re-escaped it, leaving a consumer against csv's 128KB field limit either way. Stringifying moved to the csv writer, so csv is byte-identical and jsonl carries json. The runs TUI followed, or a record would draw as a Python repr.
This commit is contained in:
@@ -4,6 +4,7 @@ The pipeline half — what a hit restores and what a key is made of — is in
|
||||
`tests/flow/test_runs.py`, which runs without one.
|
||||
"""
|
||||
|
||||
import csv
|
||||
import json
|
||||
from datetime import UTC, datetime, timedelta
|
||||
|
||||
@@ -954,6 +955,15 @@ def test_an_exported_run_row_carries_every_recorded_input(
|
||||
"metric.test_metrics.known.perfect"
|
||||
)
|
||||
|
||||
# `final_metrics` alone, short of `.train_loss`, is a record rather than a
|
||||
# leaf — the shape a large nested blob is. jsonl keeps it a json value;
|
||||
# csv still has nowhere to put it but a quoted string, unchanged.
|
||||
nested = _lines(export(format="jsonl", metrics="final_metrics"))
|
||||
assert nested[0]["metric.final_metrics"] == {"train_loss": 0.5}
|
||||
|
||||
rows = list(csv.reader(export(metrics="final_metrics").text.splitlines()))
|
||||
assert rows[1][-1] == '{"train_loss": 0.5}'
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def paged():
|
||||
|
||||
Reference in New Issue
Block a user