Skip to content
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
04656bd
add hmtl changes
mishig25 Dec 3, 2024
0a9d8d7
use .meta properties
mishig25 Dec 3, 2024
283a675
correct html template
mishig25 Dec 3, 2024
27bf982
fix dim keys
mishig25 Dec 3, 2024
cc474f0
dataset["features"]
mishig25 Dec 3, 2024
b360f22
Revert "fix dim keys"
mishig25 Dec 3, 2024
ae2c617
fix meta keys
mishig25 Dec 3, 2024
8598d14
format
mishig25 Dec 3, 2024
5af2871
fix padding
mishig25 Dec 3, 2024
d4bc181
fix filenames
mishig25 Dec 3, 2024
40164d1
fix meta version
mishig25 Dec 3, 2024
3d5ed47
debug
mishig25 Dec 3, 2024
545b1bb
fix cache
mishig25 Dec 3, 2024
51c6cdf
fix cache more
mishig25 Dec 3, 2024
4032783
debug
mishig25 Dec 3, 2024
4d8d44c
use pandas directly
mishig25 Dec 3, 2024
39d5aa4
less diff with main
mishig25 Dec 4, 2024
6a432dd
use namespace
mishig25 Dec 4, 2024
ca5a721
doc
mishig25 Dec 4, 2024
d51cf86
more dot notation
mishig25 Dec 4, 2024
09eac27
more dot notation
mishig25 Dec 4, 2024
03c35ee
correct task index
mishig25 Dec 4, 2024
4ac7738
pass column motor names
mishig25 Dec 4, 2024
9738dba
generalize columns in html
mishig25 Dec 4, 2024
7e82572
fix field motors names
mishig25 Dec 13, 2024
c427d71
refactor columns logic
mishig25 Dec 13, 2024
05e778a
Merge branch 'main' into v2_dataset_viz
mishig25 Dec 13, 2024
8cfac30
rm unused time_param = all_params["t"]
mishig25 Dec 13, 2024
84a0baa
rm dev
mishig25 Dec 13, 2024
48c2254
ruff check --fix
mishig25 Dec 13, 2024
5e14006
use row labels
mishig25 Dec 13, 2024
832ae0c
fix wrap
mishig25 Dec 13, 2024
42812df
rm unneeded test
mishig25 Dec 13, 2024
cdd032c
rm debug
mishig25 Dec 13, 2024
de382d6
better v2 error msg
mishig25 Dec 16, 2024
d605f0c
fix image_keys
mishig25 Dec 16, 2024
c425bd8
use python3.10> types
mishig25 Dec 20, 2024
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
58 changes: 57 additions & 1 deletion lerobot/common/datasets/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
from itertools import accumulate
from pathlib import Path
from pprint import pformat
from typing import Any
from types import SimpleNamespace
from typing import Any, Dict, Iterator
Copy link
Collaborator

@aliberts aliberts Dec 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: since we're using python >=3.10 we don't need typing.Dict and we can type-hint directly with dict.
Similarly, typing.Iterator is deprecated and can be replaced by collections.abc.Iterable

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handled in c425bd8


import datasets
import jsonlines
Expand Down Expand Up @@ -502,3 +503,58 @@ def create_lerobot_dataset_card(
template_path=str(card_template_path),
**kwargs,
)


class IterableNamespace(SimpleNamespace):
"""
A namespace object that supports both dictionary-like iteration and dot notation access.
Automatically converts nested dictionaries into IterableNamespaces.

This class extends SimpleNamespace to provide:
- Dictionary-style iteration over keys
- Access to items via both dot notation (obj.key) and brackets (obj["key"])
- Dictionary-like methods: items(), keys(), values()
- Recursive conversion of nested dictionaries

Args:
dictionary: Optional dictionary to initialize the namespace
**kwargs: Additional keyword arguments passed to SimpleNamespace

Examples:
>>> data = {"name": "Alice", "details": {"age": 25}}
>>> ns = IterableNamespace(data)
>>> ns.name
'Alice'
>>> ns.details.age
25
>>> list(ns.keys())
['name', 'details']
>>> for key, value in ns.items():
... print(f"{key}: {value}")
name: Alice
details: IterableNamespace(age=25)
"""

def __init__(self, dictionary: Dict[str, Any] = None, **kwargs):
super().__init__(**kwargs)
if dictionary is not None:
for key, value in dictionary.items():
if isinstance(value, dict):
setattr(self, key, IterableNamespace(value))
else:
setattr(self, key, value)

def __iter__(self) -> Iterator[str]:
return iter(vars(self))

def __getitem__(self, key: str) -> Any:
return vars(self)[key]

def items(self):
return vars(self).items()

def values(self):
return vars(self).values()

def keys(self):
return vars(self).keys()
Loading
Loading