mirror of
https://github.com/huggingface/lerobot.git
synced 2026-07-24 02:06:15 +00:00
update docstring inside DatasetInfo.from_dict()
* sorts the unknown to have deterministic output Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Maxime Ellerbach <maxime@ellerbach.net>
This commit is contained in:
@@ -162,11 +162,12 @@ class DatasetInfo:
|
|||||||
def from_dict(cls, data: dict) -> "DatasetInfo":
|
def from_dict(cls, data: dict) -> "DatasetInfo":
|
||||||
"""Construct from a raw dict (e.g. loaded directly from JSON).
|
"""Construct from a raw dict (e.g. loaded directly from JSON).
|
||||||
|
|
||||||
Unknown keys are silently ignored for forward compatibility with
|
Unknown keys are ignored for forward compatibility with datasets that
|
||||||
datasets that carry additional fields (e.g. ``total_videos`` from v2.x).
|
carry additional fields (e.g. ``total_videos`` from v2.x). A warning is
|
||||||
|
logged when such fields are present.
|
||||||
"""
|
"""
|
||||||
known = {f.name for f in dataclasses.fields(cls)}
|
known = {f.name for f in dataclasses.fields(cls)}
|
||||||
unknown = {k for k in data if k not in known}
|
unknown = sorted(k for k in data if k not in known)
|
||||||
if unknown:
|
if unknown:
|
||||||
logger.warning(f"Unknown fields in DatasetInfo: {unknown}. These will be ignored.")
|
logger.warning(f"Unknown fields in DatasetInfo: {unknown}. These will be ignored.")
|
||||||
return cls(**{k: v for k, v in data.items() if k in known})
|
return cls(**{k: v for k, v in data.items() if k in known})
|
||||||
|
|||||||
Reference in New Issue
Block a user