INNER CODE UNIT · Python

_history_sort_key

lij768423-svg/grok-register-panel · batch_traffic.py:143

def _history_sort_key(entry: dict) -> float:
    try:
        return float(entry.get("finished_at") or entry.get("started_at") or 0)
    except (TypeError, ValueError):
        return 0.0


def archive_batch(path: str | os.PathLike[str], metrics: object) -> bool:
    entry = _history_entry(metrics)
    if entry is None or entry["bytes_total"] <= 0:
        return False
    target = Path(path)
    ensure_private_dir(target.parent)
    with exclusive_file_lock(target.with_suffix(target.suffix + ".lock")):
        history = read_history(target)
        batches = [
            item
            for item in history["batches"]

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…