feat: import_lerobot に LeRobotConverter を追加(取り込みのカスタマイズ)#285
Open
rikunosuke wants to merge 1 commit into
Open
Conversation
Client.import_lerobot に LeRobot v3 → FastLabel 取り込みのカスタマイズ点を
フックとして開放する LeRobotConverter を追加。
- LeRobotConverter(新規, pure strategy)。SDK が meta/info.json 付きで
__init__ 生成(クラス/ファクトリを渡す)。全体フロー(ループ・タスク作成・
アップロード・後処理)は Client が保持し、converter は hook のみ:
- select_observation_state_names / select_action_names: 残す feature 名を
選ぶ(name→index 変換は SDK が __init__ で1回だけ解決)
- build_observation_state / build_action / build_telemetry_frame:
telemetry の値・項目(gripper 等)を構築
- select_cameras: 登録動画を選別(Camera: path/key/content_name)
- build_task_kwargs: create_robotics_task へ渡す tags/metadatas 等
- select_episodes: episode 選別(index→frame数のみ, v3 非依存)
- build_episode_name: タスク/成果物の命名
- import_lerobot(converter=LeRobotConverter)。一時ディレクトリは
with tempfile.TemporaryDirectory で管理。ZIP はタスク作成前に生成し
orphan task を回避。想定内 (FastLabelException) は per-episode 記録、
想定外は伝播。
- レイヤ疎結合化: converter は v3 非依存 / v3 は version 固有データアクセス /
common は version 非依存の共有カーネル。info.json の feature 名で name
ベース選別が可能(例: observation.state を ".pos" のみ、カメラを主要4つ)。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
Client.import_lerobot(LeRobot v3 → FastLabel 取り込み)に、カスタマイズ点をフックとして開放するLeRobotConverterを追加しました。全体フロー(episode ループ・タスク作成・アップロード・後処理)はClientが保持し、ユーザーは必要な hook だけを override します。追加した hook(
LeRobotConverter)OBSERVATION_STATE_NAMES/ACTION_NAMES/CAMERA_KEYS(class var, tuple)select_observation_state_names/select_action_names__init__で1回解決)build_observation_state/build_action/build_telemetry_frameselect_camerasCamera:path/key/content_name)build_task_kwargscreate_robotics_taskへ渡すtags/metadatas等select_episodesindex→frame数のみ受け取り、dataset version 非依存)build_episode_nameconverterはクラス/ファクトリで渡し、SDK がmeta/info.json付きで生成します(デフォルトはLeRobotConverter=従来と同一の全件取り込み)。設計上のポイント
converter(ポリシー, version 非依存) /v3(version 固有のデータアクセス) /common(version 非依存の共有カーネル) /Client(オーケストレーション) を分離。converterはv3に依存しません。meta/info.jsonの feature 名で選別できるため、巨大なobservation.state(例 12014 次元)を関節値のみへ、カメラを主要4つのみへ、といった絞り込みが可能。with tempfile.TemporaryDirectoryで管理。ZIP はタスク作成前に生成し orphan task を回避。FastLabelException) は per-episode 記録して継続、想定外(接続エラー等)は伝播。後方互換
import_lerobot(project, lerobot_data_path, episode_indices=...)は従来通り動作(converter省略時は全件・全カメラ)。fastlabel.lerobot.format_episode_nameを削除(命名はLeRobotConverter.build_episode_nameに統合)。converter経由の取り込みはmeta/info.jsonを要求します。テスト
tests/test_lerobot_converter.py(新規, 純ロジック)+tests/test_lerobot_v3_parquet.py更新。pytest tests/→ 72 passed、flake8 / black / isort 通過。🤖 Generated with Claude Code