Skip to content

Limit W&B tag length to comply with 64‑character limit #995

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions lerobot/common/utils/wandb_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,28 @@
from lerobot.configs.train import TrainPipelineConfig


def cfg_to_group(cfg: TrainPipelineConfig, return_list: bool = False) -> list[str] | str:
def cfg_to_group(
cfg: TrainPipelineConfig, return_list: bool = False, truncate_tags: bool = False, max_tag_bytes: int = 64
) -> list[str] | str:
"""Return a group name for logging. Optionally returns group name as list."""

def _maybe_truncate(tag: str) -> str:
"""Truncate `tag` in UTF‑8 bytes if required."""
raw = tag.encode("utf-8")
if len(raw) <= max_tag_bytes:
return tag
# Cut at byte‑level, then decode; characters split mid‑sequence are dropped.
return raw[:max_tag_bytes].decode("utf-8", errors="ignore")

lst = [
f"policy:{cfg.policy.type}",
f"dataset:{cfg.dataset.repo_id}",
f"seed:{cfg.seed}",
]
if cfg.env is not None:
lst.append(f"env:{cfg.env.type}")
if truncate_tags:
lst = [_maybe_truncate(tag) for tag in lst]
return lst if return_list else "-".join(lst)


Expand Down Expand Up @@ -82,7 +95,7 @@ def __init__(self, cfg: TrainPipelineConfig):
entity=self.cfg.entity,
name=self.job_name,
notes=self.cfg.notes,
tags=cfg_to_group(cfg, return_list=True),
tags=cfg_to_group(cfg, return_list=True, truncate_tags=True),
dir=self.log_dir,
config=cfg.to_dict(),
# TODO(rcadene): try set to True
Expand Down