robocandywrapper 0.2.5__tar.gz → 0.2.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. {robocandywrapper-0.2.5/robocandywrapper.egg-info → robocandywrapper-0.2.7}/PKG-INFO +1 -1
  2. {robocandywrapper-0.2.5 → robocandywrapper-0.2.7}/pyproject.toml +1 -1
  3. {robocandywrapper-0.2.5 → robocandywrapper-0.2.7}/robocandywrapper/__init__.py +1 -1
  4. {robocandywrapper-0.2.5 → robocandywrapper-0.2.7}/robocandywrapper/metadata_view.py +37 -5
  5. {robocandywrapper-0.2.5 → robocandywrapper-0.2.7}/robocandywrapper/wrapper.py +1 -1
  6. {robocandywrapper-0.2.5 → robocandywrapper-0.2.7/robocandywrapper.egg-info}/PKG-INFO +1 -1
  7. {robocandywrapper-0.2.5 → robocandywrapper-0.2.7}/setup.py +1 -1
  8. {robocandywrapper-0.2.5 → robocandywrapper-0.2.7}/LICENSE +0 -0
  9. {robocandywrapper-0.2.5 → robocandywrapper-0.2.7}/MANIFEST.in +0 -0
  10. {robocandywrapper-0.2.5 → robocandywrapper-0.2.7}/README.md +0 -0
  11. {robocandywrapper-0.2.5 → robocandywrapper-0.2.7}/robocandywrapper/constants.py +0 -0
  12. {robocandywrapper-0.2.5 → robocandywrapper-0.2.7}/robocandywrapper/dataformats/__init__.py +0 -0
  13. {robocandywrapper-0.2.5 → robocandywrapper-0.2.7}/robocandywrapper/dataformats/lerobot_21/__init__.py +0 -0
  14. {robocandywrapper-0.2.5 → robocandywrapper-0.2.7}/robocandywrapper/dataformats/lerobot_21/dataset.py +0 -0
  15. {robocandywrapper-0.2.5 → robocandywrapper-0.2.7}/robocandywrapper/dataformats/lerobot_21/utils.py +0 -0
  16. {robocandywrapper-0.2.5 → robocandywrapper-0.2.7}/robocandywrapper/factory.py +0 -0
  17. {robocandywrapper-0.2.5 → robocandywrapper-0.2.7}/robocandywrapper/plugin.py +0 -0
  18. {robocandywrapper-0.2.5 → robocandywrapper-0.2.7}/robocandywrapper/plugins/__init__.py +0 -0
  19. {robocandywrapper-0.2.5 → robocandywrapper-0.2.7}/robocandywrapper/plugins/affordance.py +0 -0
  20. {robocandywrapper-0.2.5 → robocandywrapper-0.2.7}/robocandywrapper/plugins/episode_outcome.py +0 -0
  21. {robocandywrapper-0.2.5 → robocandywrapper-0.2.7}/robocandywrapper/samplers/__init__.py +0 -0
  22. {robocandywrapper-0.2.5 → robocandywrapper-0.2.7}/robocandywrapper/samplers/config.py +0 -0
  23. {robocandywrapper-0.2.5 → robocandywrapper-0.2.7}/robocandywrapper/samplers/factory.py +0 -0
  24. {robocandywrapper-0.2.5 → robocandywrapper-0.2.7}/robocandywrapper/samplers/weighted.py +0 -0
  25. {robocandywrapper-0.2.5 → robocandywrapper-0.2.7}/robocandywrapper/utils.py +0 -0
  26. {robocandywrapper-0.2.5 → robocandywrapper-0.2.7}/robocandywrapper.egg-info/SOURCES.txt +0 -0
  27. {robocandywrapper-0.2.5 → robocandywrapper-0.2.7}/robocandywrapper.egg-info/dependency_links.txt +0 -0
  28. {robocandywrapper-0.2.5 → robocandywrapper-0.2.7}/robocandywrapper.egg-info/requires.txt +0 -0
  29. {robocandywrapper-0.2.5 → robocandywrapper-0.2.7}/robocandywrapper.egg-info/top_level.txt +0 -0
  30. {robocandywrapper-0.2.5 → robocandywrapper-0.2.7}/setup.cfg +0 -0
  31. {robocandywrapper-0.2.5 → robocandywrapper-0.2.7}/tests/test_dataset_weights_integration.py +0 -0
  32. {robocandywrapper-0.2.5 → robocandywrapper-0.2.7}/tests/test_key_rename_stats.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: robocandywrapper
3
- Version: 0.2.5
3
+ Version: 0.2.7
4
4
  Summary: Sweet wrappers for extending and remixing LeRobot Datasets
5
5
  Author: RoboCandyWrapper Contributors
6
6
  License: MIT License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "robocandywrapper"
7
- version = "0.2.5"
7
+ version = "0.2.7"
8
8
  description = "Sweet wrappers for extending and remixing LeRobot Datasets"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -17,7 +17,7 @@ from robocandywrapper.constants import (
17
17
  EPISODE_OUTCOME_PLUGIN_NAME,
18
18
  )
19
19
 
20
- __version__ = "0.2.5"
20
+ __version__ = "0.2.7"
21
21
 
22
22
  __all__ = [
23
23
  "DatasetPlugin",
@@ -5,6 +5,39 @@ import logging
5
5
  from typing import Optional
6
6
 
7
7
  import numpy as np
8
+ import pandas as pd
9
+
10
+
11
+ def _task_names_from_meta_tasks(meta_tasks) -> set[str]:
12
+ """
13
+ Extract task name strings from a dataset's meta.tasks in either format.
14
+
15
+ - LeRobot 2.1 (dict): tasks is dict[task_index, task_name].
16
+ - LeRobot 3.0 (parquet/DataFrame): tasks is a pandas DataFrame where the
17
+ *row index* is the task name (string) and the only column is "task_index"
18
+ (integer). So: df.index = task names, df["task_index"] = indices.
19
+
20
+ Returns a set of unique task name strings.
21
+ """
22
+ if meta_tasks is None:
23
+ return set()
24
+ if isinstance(meta_tasks, dict):
25
+ return {str(v) for v in meta_tasks.values() if isinstance(v, str)}
26
+ # DataFrame or object with to_pandas() (e.g. HuggingFace Dataset)
27
+ df = None
28
+ if hasattr(meta_tasks, "to_pandas"):
29
+ df = meta_tasks.to_pandas()
30
+ elif isinstance(meta_tasks, pd.DataFrame):
31
+ df = meta_tasks
32
+ if df is None:
33
+ return set()
34
+ # 3.0 format: optional "task" column, else task names are the row index
35
+ if "task" in df.columns:
36
+ return set(df["task"].dropna().astype(str).unique())
37
+ if "task_index" in df.columns:
38
+ # Task names are the DataFrame index (row labels), not the column
39
+ return set(df.index.astype(str))
40
+ return set()
8
41
 
9
42
 
10
43
  def aggregate_stats_weighted(
@@ -241,7 +274,9 @@ class WrappedRobotDatasetMetadataView:
241
274
  Collated task index -> task name mapping across all datasets.
242
275
 
243
276
  Collects all unique task strings from every dataset that has a `tasks`
244
- attribute on its meta (e.g. LeRobot v2.1 datasets). Assigns a unified
277
+ attribute on its meta. Supports both formats: LeRobot 2.1 (dict
278
+ task_index -> task name) and LeRobot 3.0 (parquet/pandas DataFrame with
279
+ "task" column, or object with to_pandas()). Assigns a unified
245
280
  task_index to each unique task name (sorted for determinism), so
246
281
  consumers get a single dict[int, str] suitable for _coerce_task_mapping
247
282
  and similar use.
@@ -252,10 +287,7 @@ class WrappedRobotDatasetMetadataView:
252
287
  all_task_names: set[str] = set()
253
288
  for dataset in self._datasets:
254
289
  meta_tasks = getattr(dataset.meta, "tasks", None)
255
- if meta_tasks is not None and isinstance(meta_tasks, dict):
256
- for _idx, name in meta_tasks.items():
257
- if isinstance(name, str):
258
- all_task_names.add(name)
290
+ all_task_names.update(_task_names_from_meta_tasks(meta_tasks))
259
291
 
260
292
  sorted_names = sorted(all_task_names)
261
293
  self._tasks = {idx: name for idx, name in enumerate(sorted_names)}
@@ -452,7 +452,7 @@ class WrappedRobotDataset(torch.utils.data.Dataset):
452
452
  return None
453
453
 
454
454
  for instance in self._plugin_instances[dataset_idx]:
455
- if isinstance(instance, plugin_type.attach(self._datasets[0]).__class__):
455
+ if isinstance(instance, plugin_type.attach(self._datasets[dataset_idx]).__class__):
456
456
  # Check if the instance came from the right plugin type
457
457
  # This is a bit hacky - better to store plugin class reference
458
458
  pass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: robocandywrapper
3
- Version: 0.2.5
3
+ Version: 0.2.7
4
4
  Summary: Sweet wrappers for extending and remixing LeRobot Datasets
5
5
  Author: RoboCandyWrapper Contributors
6
6
  License: MIT License
@@ -9,7 +9,7 @@ long_description = readme_file.read_text(encoding="utf-8") if readme_file.exists
9
9
 
10
10
  setup(
11
11
  name="robocandywrapper",
12
- version="0.2.5",
12
+ version="0.2.7",
13
13
  description="Sweet wrappers for extending and remixing LeRobot Datasets",
14
14
  long_description=long_description,
15
15
  long_description_content_type="text/markdown",