1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5
6 # build-system
7 cmake,
8 setuptools,
9
10 # dependencies
11 av,
12 datasets,
13 deepdiff,
14 diffusers,
15 draccus,
16 einops,
17 flask,
18 gymnasium,
19 huggingface-hub,
20 imageio,
21 jsonlines,
22 opencv-python-headless,
23 packaging,
24 pynput,
25 pyserial,
26 rerun-sdk,
27 termcolor,
28 torch,
29 torchvision,
30 wandb,
31
32 # tests
33 pytestCheckHook,
34 writableTmpDirAsHomeHook,
35}:
36
37buildPythonPackage rec {
38 pname = "lerobot";
39 version = "0.3.3";
40 pyproject = true;
41
42 src = fetchFromGitHub {
43 owner = "huggingface";
44 repo = "lerobot";
45 tag = "v${version}";
46 hash = "sha256-JaspLUuSupmk6QD+mUVLuCSczTNjy0w+nsLBcy7tXnE=";
47 };
48
49 # ValueError: mutable default <class 'lerobot.configs.types.PolicyFeature'> for field value is not allowed: use default_factory
50 postPatch = ''
51 substituteInPlace tests/processor/test_pipeline.py \
52 --replace-fail \
53 "from dataclasses import dataclass" \
54 "from dataclasses import dataclass, field" \
55 --replace-fail \
56 "value: PolicyFeature = PolicyFeature(type=FeatureType.STATE, shape=(1,))" \
57 "value: PolicyFeature = field(default_factory=lambda: PolicyFeature(type=FeatureType.STATE, shape=(1,)))"
58 '';
59
60 build-system = [
61 cmake
62 setuptools
63 ];
64 dontUseCmakeConfigure = true;
65
66 pythonRelaxDeps = [
67 "datasets"
68 "draccus"
69 "gymnasium"
70 "rerun-sdk"
71 "torch"
72 "torchvision"
73 ];
74
75 dependencies = [
76 av
77 datasets
78 deepdiff
79 diffusers
80 draccus
81 einops
82 flask
83 gymnasium
84 huggingface-hub
85 imageio
86 jsonlines
87 opencv-python-headless
88 packaging
89 pynput
90 pyserial
91 rerun-sdk
92 termcolor
93 torch
94 torchvision
95 wandb
96 ];
97
98 pythonImportsCheck = [ "lerobot" ];
99
100 nativeCheckInputs = [
101 pytestCheckHook
102 writableTmpDirAsHomeHook
103 ];
104
105 disabledTests = [
106 # RuntimeError: OpenCVCamera(/build/source/tests/artifacts/cameras/image_480x270.png) read failed
107 "test_async_read"
108 "test_read"
109 "test_rotation"
110
111 # Require internet access
112 "test_act_backbone_lr"
113 "test_backward_compatibility"
114 "test_dataset_initialization"
115 "test_factory"
116 "test_policy_defaults"
117 "test_save_and_load_pretrained"
118
119 # TypeError: stack(): argument 'tensors' (position 1) must be tuple of Tensors, not Column
120 "test_check_timestamps_sync_slightly_off"
121 "test_check_timestamps_sync_synced"
122 "test_check_timestamps_sync_unsynced"
123 "test_check_timestamps_sync_unsynced_no_exception"
124 "test_compute_sampler_weights_drop_n_last_frames"
125 "test_compute_sampler_weights_nontrivial_ratio"
126 "test_compute_sampler_weights_nontrivial_ratio_and_drop_last_n"
127 "test_compute_sampler_weights_trivial"
128 "test_record_and_replay"
129 "test_record_and_resume"
130 "test_same_attributes_defined"
131
132 # AssertionError between two dicts. One has an extra `'_is_initial': False` entry.
133 "test_cosine_decay_with_warmup_scheduler"
134 "test_diffuser_scheduler"
135 "test_vqbet_scheduler"
136 ];
137
138 meta = {
139 description = "Making AI for Robotics more accessible with end-to-end learning";
140 homepage = "https://github.com/huggingface/lerobot";
141 changelog = "https://github.com/huggingface/lerobot/releases/tag/v${version}";
142 license = lib.licenses.asl20;
143 maintainers = with lib.maintainers; [ GaetanLepage ];
144 };
145}