Skip to content

Commit 832f56e

Browse files
fix(export): address PR review — parity asserts, stderr warnings, JSONL newlinefix(export): address PR review — parity asserts, stderr warnings, JSONL newline
1 parent 2ce1e74 commit 832f56e

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

scripts/export.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ def cmd_export(args):
427427
skipped_mtime_unchanged = 0
428428

429429
def _on_export_error(sid: str, exc: Exception) -> None:
430-
print(f" Warning: failed to export {sid}: {exc}")
430+
print(f" Warning: failed to export {sid}: {exc}", file=sys.stderr)
431431

432432
collect_sink = ListSink()
433433
export_result = run_bulk_export(

tests/test_export_engine_parity.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,15 @@ def test_http_post_export_matches_cli_no_zip(tmp_path: Path, monkeypatch) -> Non
9292
assert resp.status_code == 200
9393

9494
zf = zipfile.ZipFile(io.BytesIO(resp.data))
95-
http_md = zf.read(
96-
next(n for n in zf.namelist() if n.endswith(".md"))
97-
).decode("utf-8")
95+
http_md_names = [n for n in zf.namelist() if n.endswith(".md")]
96+
assert len(http_md_names) == 1, f"expected one .md in zip, got {http_md_names}"
97+
http_md = zf.read(http_md_names[0]).decode("utf-8")
9898
http_manifest = [
9999
json.loads(line)
100100
for line in zf.read("manifest.jsonl").decode("utf-8").splitlines()
101101
if line.strip()
102102
]
103+
assert len(http_manifest) == 1, f"expected one manifest row, got {len(http_manifest)}"
103104

104105
out_dir = tmp_path / "cli_out"
105106
proc = _run_cli([

utils/export_engine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def add_session(
106106

107107
def finalize(self, manifest: list[dict[str, Any]]) -> None:
108108
if manifest:
109-
manifest_str = "\n".join(json.dumps(e, default=str) for e in manifest)
109+
manifest_str = "\n".join(json.dumps(e, default=str) for e in manifest) + "\n"
110110
self._zf.writestr("manifest.jsonl", manifest_str)
111111

112112

0 commit comments

Comments
 (0)