From 79f2eafcc6306d44b7312500cb91ad7daaab3bec Mon Sep 17 00:00:00 2001 From: Nicolas Rabault Date: Wed, 24 Jun 2026 11:01:58 +0200 Subject: [PATCH] refactor(jobs): build remote config dict via cfg.to_dict() TrainPipelineConfig.to_dict() already returns the canonical draccus encoding, so the StringIO + draccus.dump + json.loads round-trip was redundant. Use it directly and drop the now-unused io/draccus imports. --- src/lerobot/jobs/hf.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/lerobot/jobs/hf.py b/src/lerobot/jobs/hf.py index 1e0b0e7c8..8b1103504 100644 --- a/src/lerobot/jobs/hf.py +++ b/src/lerobot/jobs/hf.py @@ -21,7 +21,6 @@ from __future__ import annotations import copy import datetime as dt -import io import json import netrc import os @@ -32,7 +31,6 @@ import threading from pathlib import Path from typing import TYPE_CHECKING -import draccus from huggingface_hub import ( HfApi, create_repo, @@ -107,12 +105,9 @@ def build_remote_config_file(cfg, repo_id: str, dest: Path, tags: list[str] | No existing = list(remote.policy.tags or []) remote.policy.tags = existing + [t for t in tags if t not in existing] - # Round-trip through draccus to get the canonical, pod-parseable layout, then - # drop the keys the released trainer image doesn't know about. - buf = io.StringIO() - with draccus.config_type("json"): - draccus.dump(remote, buf, indent=4) - data = json.loads(buf.getvalue()) + # Encode to the canonical, pod-parseable dict, then drop the keys the released + # trainer image doesn't know about. + data = remote.to_dict() data.pop("job", None) if not remote.save_checkpoint_to_hub: data.pop("save_checkpoint_to_hub", None)