Runs export: a truncated one counts the selection into X-Total-Count; the SDK and fluksio export warn how many runs were left out

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WgBfkm4rCmtd1T4vHWjEPx
This commit is contained in:
2026-10-14 23:29:48 +02:00
co-authored by Claude Opus 5.5
parent 02f43bf7c4
commit 8eec58d1d6
6 changed files with 66 additions and 17 deletions
+6 -1
View File
@@ -17,6 +17,7 @@ import pkgutil
import shutil
import sys
import time
import warnings
from collections.abc import Callable, Iterable, Iterator
from contextlib import contextmanager, nullcontext
from datetime import UTC, datetime
@@ -1326,7 +1327,11 @@ def _export(
try:
if getattr(args, "list_names", False):
return _list_names(client, args)
rows = fetch(client)
with warnings.catch_warnings(record=True) as caught:
warnings.simplefilter("always")
rows = fetch(client)
for warning in caught:
print(f"fluksio: warning: {warning.message}", file=sys.stderr)
except ApiError as exc:
if exc.status != 404:
raise
+13
View File
@@ -12,6 +12,7 @@ import os
import subprocess
import time
import uuid
import warnings
from collections.abc import Iterable
from pathlib import Path
from typing import Any
@@ -511,6 +512,8 @@ class Client:
jsonl on the wire rather than csv: it keeps the types the engine has,
and it is the format the CLI converts to parquet from. Read whole —
the streaming is the engine's side, and a notebook wants a list.
A selection past the engine's cap comes back without its oldest runs,
and that is a warning, since the rows alone look complete.
"""
if flow:
query["flow"] = flow
@@ -523,6 +526,16 @@ class Client:
response = self._request("GET", path, idempotent=True, params=query)
if response.status_code >= 400:
raise ApiError(response.status_code, _detail(response))
cap = response.headers.get("X-Truncated")
if cap:
# An engine older than the count sends the cap alone.
total = response.headers.get("X-Total-Count")
left = f"{int(total) - int(cap)} older runs" if total else "older runs"
warnings.warn(
f"the export stops at {cap} runs, so {left} of this selection "
"were left out; narrow it by flow, status, since or until",
stacklevel=3,
)
return [json.loads(line) for line in response.text.splitlines() if line]
def cancel(self, run_id: str) -> Any: