humalab 0.0.3__py3-none-any.whl → 0.0.5__py3-none-any.whl
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.
Potentially problematic release.
This version of humalab might be problematic. Click here for more details.
- humalab/assets/__init__.py +4 -0
- humalab/assets/files/__init__.py +4 -0
- humalab/assets/files/resource_file.py +41 -0
- humalab/assets/files/urdf_file.py +65 -0
- humalab/assets/resource_manager.py +58 -0
- humalab/dists/bernoulli.py +15 -0
- humalab/dists/categorical.py +7 -0
- humalab/dists/discrete.py +22 -0
- humalab/dists/gaussian.py +22 -0
- humalab/dists/log_uniform.py +22 -0
- humalab/dists/truncated_gaussian.py +36 -0
- humalab/dists/uniform.py +22 -0
- humalab/episode.py +26 -0
- humalab/evaluators/__init__.py +16 -0
- humalab/humalab.py +80 -65
- humalab/humalab_api_client.py +540 -49
- humalab/humalab_config.py +0 -13
- humalab/humalab_main.py +119 -0
- humalab/humalab_test.py +0 -12
- humalab/run.py +0 -12
- humalab/scenario.py +172 -16
- {humalab-0.0.3.dist-info → humalab-0.0.5.dist-info}/METADATA +1 -1
- humalab-0.0.5.dist-info/RECORD +37 -0
- humalab/assets/resource_file.py +0 -28
- humalab/assets/resource_handler.py +0 -175
- humalab-0.0.3.dist-info/RECORD +0 -32
- {humalab-0.0.3.dist-info → humalab-0.0.5.dist-info}/WHEEL +0 -0
- {humalab-0.0.3.dist-info → humalab-0.0.5.dist-info}/entry_points.txt +0 -0
- {humalab-0.0.3.dist-info → humalab-0.0.5.dist-info}/licenses/LICENSE +0 -0
- {humalab-0.0.3.dist-info → humalab-0.0.5.dist-info}/top_level.txt +0 -0
humalab/humalab_config.py
CHANGED
|
@@ -6,13 +6,11 @@ class HumalabConfig:
|
|
|
6
6
|
def __init__(self):
|
|
7
7
|
self._config = {
|
|
8
8
|
"workspace_path": "",
|
|
9
|
-
"entity": "",
|
|
10
9
|
"base_url": "",
|
|
11
10
|
"api_key": "",
|
|
12
11
|
"timeout": 30.0,
|
|
13
12
|
}
|
|
14
13
|
self._workspace_path = ""
|
|
15
|
-
self._entity = ""
|
|
16
14
|
self._base_url = ""
|
|
17
15
|
self._api_key = ""
|
|
18
16
|
self._timeout = 30.0
|
|
@@ -27,7 +25,6 @@ class HumalabConfig:
|
|
|
27
25
|
with open(config_path, "r") as f:
|
|
28
26
|
self._config = yaml.safe_load(f)
|
|
29
27
|
self._workspace_path = os.path.expanduser(self._config["workspace_path"]) if self._config and "workspace_path" in self._config else home_path
|
|
30
|
-
self._entity = self._config["entity"] if self._config and "entity" in self._config else ""
|
|
31
28
|
self._base_url = self._config["base_url"] if self._config and "base_url" in self._config else ""
|
|
32
29
|
self._api_key = self._config["api_key"] if self._config and "api_key" in self._config else ""
|
|
33
30
|
self._timeout = self._config["timeout"] if self._config and "timeout" in self._config else 30.0
|
|
@@ -45,16 +42,6 @@ class HumalabConfig:
|
|
|
45
42
|
self._config["workspace_path"] = path
|
|
46
43
|
self._save()
|
|
47
44
|
|
|
48
|
-
@property
|
|
49
|
-
def entity(self) -> str:
|
|
50
|
-
return str(self._entity)
|
|
51
|
-
|
|
52
|
-
@entity.setter
|
|
53
|
-
def entity(self, entity: str) -> None:
|
|
54
|
-
self._entity = entity
|
|
55
|
-
self._config["entity"] = entity
|
|
56
|
-
self._save()
|
|
57
|
-
|
|
58
45
|
@property
|
|
59
46
|
def base_url(self) -> str:
|
|
60
47
|
return str(self._base_url)
|
humalab/humalab_main.py
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
from humalab import init, login
|
|
2
|
+
|
|
3
|
+
from humalab.assets.files.resource_file import ResourceFile
|
|
4
|
+
from humalab.assets.files.urdf_file import URDFFile
|
|
5
|
+
from humalab.assets.resource_manager import ResourceManager
|
|
6
|
+
|
|
7
|
+
# hlb_UJRzdxW4B0e4zSuy2PRwdOBu2d1zWQDNbnQykWiOdqw
|
|
8
|
+
if __name__ == "__main__":
|
|
9
|
+
login(api_key="hlb_srVXVzRgiVbA_9a0TRcbQmrfkoeEI0STVBX1dUubkiU",
|
|
10
|
+
host="http://localhost:8000")
|
|
11
|
+
|
|
12
|
+
with init(project="test",
|
|
13
|
+
name="my first run",
|
|
14
|
+
description="testing the humalab sdk",
|
|
15
|
+
tags=["tag1", "tag2"],
|
|
16
|
+
scenario_id="ff85e0c2-ba92-4b08-82df-9e6e87366ecd"
|
|
17
|
+
#scenario_id="941f9f8a-cf5a-4099-8da3-557e44f94037"
|
|
18
|
+
) as run:
|
|
19
|
+
print(f"Run ID: {run.id}")
|
|
20
|
+
print(f"Run Name: {run.name}")
|
|
21
|
+
print(f"Run Description: {run.description}")
|
|
22
|
+
print(f"Run Tags: {run.tags}")
|
|
23
|
+
print(f"Run Scenario YAML:\n{run.scenario.yaml}")
|
|
24
|
+
|
|
25
|
+
scenario = run.scenario
|
|
26
|
+
# Simulate some operations
|
|
27
|
+
# print("CUP position: ", scenario.scenario.cup.position)
|
|
28
|
+
# print("CUP orientation: ", scenario.scenario.cup.orientation)
|
|
29
|
+
# print("Asset: ", scenario.scenario.cup.asset)
|
|
30
|
+
# print("Friction: ", scenario.scenario.cup.friction)
|
|
31
|
+
print("Num Objects: ", scenario.scenario.jkjk)
|
|
32
|
+
scenario.reset()
|
|
33
|
+
print("======================SCENARIO RESET==========================")
|
|
34
|
+
# print("CUP position: ", scenario.scenario.cup.position)
|
|
35
|
+
# print("CUP orientation: ", scenario.scenario.cup.orientation)
|
|
36
|
+
# print("Asset: ", scenario.scenario.cup.asset)
|
|
37
|
+
# print("Friction: ", scenario.scenario.cup.friction)
|
|
38
|
+
print("Num Objects: ", scenario.scenario.jkjk)
|
|
39
|
+
|
|
40
|
+
scenario_string = """
|
|
41
|
+
scenario:
|
|
42
|
+
cup:
|
|
43
|
+
position: "${uniform_3d: [0.7, 0.7, 0.7],
|
|
44
|
+
[1.5, 1.3, 0.7]}"
|
|
45
|
+
orientation: "${uniform: 0.3, 0.7}"
|
|
46
|
+
asset: "${categorical_1d: ['lerobot', 'apple2', 'apple3'], [0.1, 0.3, 0.5]}"
|
|
47
|
+
friction: "${gaussian_1d: 0.3, 0.05}"
|
|
48
|
+
hello: 13
|
|
49
|
+
jkjk: test
|
|
50
|
+
num_objects: "${discrete_1d: 5, 10}"
|
|
51
|
+
dfdjkjk: "hello"
|
|
52
|
+
"""
|
|
53
|
+
with init(
|
|
54
|
+
project="test",
|
|
55
|
+
name="my first run",
|
|
56
|
+
description="testing the humalab sdk",
|
|
57
|
+
tags=["tag1", "tag2"],
|
|
58
|
+
scenario=scenario_string,
|
|
59
|
+
auto_create_scenario=False) as run:
|
|
60
|
+
print(f"Run ID: {run.id}")
|
|
61
|
+
print(f"Run Name: {run.name}")
|
|
62
|
+
print(f"Run Description: {run.description}")
|
|
63
|
+
print(f"Run Tags: {run.tags}")
|
|
64
|
+
print(f"Run Scenario YAML:\n{run.scenario.yaml}")
|
|
65
|
+
|
|
66
|
+
scenario = run.scenario
|
|
67
|
+
# Simulate some operations
|
|
68
|
+
print("CUP position: ", scenario.scenario.cup.position)
|
|
69
|
+
print("CUP orientation: ", scenario.scenario.cup.orientation)
|
|
70
|
+
print("Asset: ", scenario.scenario.cup.asset)
|
|
71
|
+
print("Friction: ", scenario.scenario.cup.friction)
|
|
72
|
+
print("Num Objects: ", scenario.scenario.num_objects)
|
|
73
|
+
scenario.reset()
|
|
74
|
+
print("======================SCENARIO RESET==========================")
|
|
75
|
+
print("CUP position: ", scenario.scenario.cup.position)
|
|
76
|
+
print("CUP orientation: ", scenario.scenario.cup.orientation)
|
|
77
|
+
print("Asset: ", scenario.scenario.cup.asset)
|
|
78
|
+
print("Friction: ", scenario.scenario.cup.friction)
|
|
79
|
+
print("Num Objects: ", scenario.scenario.num_objects)
|
|
80
|
+
|
|
81
|
+
resource = ResourceManager()
|
|
82
|
+
urdf_file: URDFFile = resource.download(project="default", name="lerobot", version=1)
|
|
83
|
+
print("URDF File: ", urdf_file.filename)
|
|
84
|
+
print("URDF Description: ", urdf_file.description)
|
|
85
|
+
print("URDF Created At: ", urdf_file.created_at)
|
|
86
|
+
print("URDF Root Path: ", urdf_file._root_path)
|
|
87
|
+
print("URDF Root Path: ", urdf_file._urdf_filename)
|
|
88
|
+
|
|
89
|
+
urdf_file: URDFFile = resource.download(project="default", name="lerobot")
|
|
90
|
+
print("URDF File: ", urdf_file.filename)
|
|
91
|
+
print("URDF Description: ", urdf_file.description)
|
|
92
|
+
print("URDF Created At: ", urdf_file.created_at)
|
|
93
|
+
print("URDF Root Path: ", urdf_file._root_path)
|
|
94
|
+
print("URDF Root Path: ", urdf_file._urdf_filename)
|
|
95
|
+
|
|
96
|
+
atlas_file: ResourceFile = resource.download(project="default", name="atlas")
|
|
97
|
+
print("Atlas File: ", atlas_file.filename)
|
|
98
|
+
print("Atlas Description: ", atlas_file.description)
|
|
99
|
+
print("Atlas Created At: ", atlas_file.created_at)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
"""
|
|
103
|
+
humalab_config = HumalabConfig()
|
|
104
|
+
base_url = humalab_config.base_url
|
|
105
|
+
api_key = humalab_config.api_key
|
|
106
|
+
timeout = humalab_config.timeout
|
|
107
|
+
|
|
108
|
+
api_client = HumaLabApiClient(base_url=base_url,
|
|
109
|
+
api_key=api_key,
|
|
110
|
+
timeout=timeout)
|
|
111
|
+
resource = api_client.get_resource(name="lerobot", version=1)
|
|
112
|
+
print("Resource metadata: ", resource)
|
|
113
|
+
file_content = api_client.download_resource(name="lerobot")
|
|
114
|
+
filename = os.path.basename(resource['resource_url'])
|
|
115
|
+
filename = os.path.join(humalab_config.workspace_path, filename)
|
|
116
|
+
with open(filename, "wb") as f:
|
|
117
|
+
f.write(file_content)
|
|
118
|
+
print(f"Resource file downloaded: {filename}")
|
|
119
|
+
"""
|
humalab/humalab_test.py
CHANGED
|
@@ -78,7 +78,6 @@ class HumalabTest(unittest.TestCase):
|
|
|
78
78
|
def test_init_should_create_run_with_provided_parameters(self, mock_run_class, mock_scenario_class, mock_config_class, mock_api_client_class):
|
|
79
79
|
"""Test that init() creates a Run with provided parameters."""
|
|
80
80
|
# Pre-condition
|
|
81
|
-
entity = "test_entity"
|
|
82
81
|
project = "test_project"
|
|
83
82
|
name = "test_name"
|
|
84
83
|
description = "test_description"
|
|
@@ -87,7 +86,6 @@ class HumalabTest(unittest.TestCase):
|
|
|
87
86
|
scenario_data = {"key": "value"}
|
|
88
87
|
|
|
89
88
|
mock_config = Mock()
|
|
90
|
-
mock_config.entity = "default_entity"
|
|
91
89
|
mock_config.base_url = "http://localhost:8000"
|
|
92
90
|
mock_config.api_key = "test_key"
|
|
93
91
|
mock_config.timeout = 30.0
|
|
@@ -104,7 +102,6 @@ class HumalabTest(unittest.TestCase):
|
|
|
104
102
|
|
|
105
103
|
# In-test
|
|
106
104
|
with humalab.init(
|
|
107
|
-
entity=entity,
|
|
108
105
|
project=project,
|
|
109
106
|
name=name,
|
|
110
107
|
description=description,
|
|
@@ -116,7 +113,6 @@ class HumalabTest(unittest.TestCase):
|
|
|
116
113
|
self.assertEqual(run, mock_run_inst)
|
|
117
114
|
mock_run_class.assert_called_once()
|
|
118
115
|
call_kwargs = mock_run_class.call_args.kwargs
|
|
119
|
-
self.assertEqual(call_kwargs['entity'], entity)
|
|
120
116
|
self.assertEqual(call_kwargs['project'], project)
|
|
121
117
|
self.assertEqual(call_kwargs['name'], name)
|
|
122
118
|
self.assertEqual(call_kwargs['description'], description)
|
|
@@ -135,7 +131,6 @@ class HumalabTest(unittest.TestCase):
|
|
|
135
131
|
"""Test that init() uses config defaults when parameters are not provided."""
|
|
136
132
|
# Pre-condition
|
|
137
133
|
mock_config = Mock()
|
|
138
|
-
mock_config.entity = "config_entity"
|
|
139
134
|
mock_config.base_url = "http://config:8000"
|
|
140
135
|
mock_config.api_key = "config_key"
|
|
141
136
|
mock_config.timeout = 60.0
|
|
@@ -154,7 +149,6 @@ class HumalabTest(unittest.TestCase):
|
|
|
154
149
|
with humalab.init() as run:
|
|
155
150
|
# Post-condition
|
|
156
151
|
call_kwargs = mock_run_class.call_args.kwargs
|
|
157
|
-
self.assertEqual(call_kwargs['entity'], "config_entity")
|
|
158
152
|
self.assertEqual(call_kwargs['project'], "default")
|
|
159
153
|
self.assertEqual(call_kwargs['name'], "")
|
|
160
154
|
self.assertEqual(call_kwargs['description'], "")
|
|
@@ -171,7 +165,6 @@ class HumalabTest(unittest.TestCase):
|
|
|
171
165
|
"""Test that init() generates a UUID when id is not provided."""
|
|
172
166
|
# Pre-condition
|
|
173
167
|
mock_config = Mock()
|
|
174
|
-
mock_config.entity = "test_entity"
|
|
175
168
|
mock_config.base_url = "http://localhost:8000"
|
|
176
169
|
mock_config.api_key = "test_key"
|
|
177
170
|
mock_config.timeout = 30.0
|
|
@@ -207,7 +200,6 @@ class HumalabTest(unittest.TestCase):
|
|
|
207
200
|
scenario_data = {"key": "value"}
|
|
208
201
|
|
|
209
202
|
mock_config = Mock()
|
|
210
|
-
mock_config.entity = "test_entity"
|
|
211
203
|
mock_config.base_url = "http://localhost:8000"
|
|
212
204
|
mock_config.api_key = "test_key"
|
|
213
205
|
mock_config.timeout = 30.0
|
|
@@ -243,7 +235,6 @@ class HumalabTest(unittest.TestCase):
|
|
|
243
235
|
yaml_content = "scenario: from_api"
|
|
244
236
|
|
|
245
237
|
mock_config = Mock()
|
|
246
|
-
mock_config.entity = "test_entity"
|
|
247
238
|
mock_config.base_url = "http://localhost:8000"
|
|
248
239
|
mock_config.api_key = "test_key"
|
|
249
240
|
mock_config.timeout = 30.0
|
|
@@ -277,7 +268,6 @@ class HumalabTest(unittest.TestCase):
|
|
|
277
268
|
"""Test that init() sets the global _cur_run variable."""
|
|
278
269
|
# Pre-condition
|
|
279
270
|
mock_config = Mock()
|
|
280
|
-
mock_config.entity = "test_entity"
|
|
281
271
|
mock_config.base_url = "http://localhost:8000"
|
|
282
272
|
mock_config.api_key = "test_key"
|
|
283
273
|
mock_config.timeout = 30.0
|
|
@@ -308,7 +298,6 @@ class HumalabTest(unittest.TestCase):
|
|
|
308
298
|
"""Test that init() calls finish even when exception occurs in context."""
|
|
309
299
|
# Pre-condition
|
|
310
300
|
mock_config = Mock()
|
|
311
|
-
mock_config.entity = "test_entity"
|
|
312
301
|
mock_config.base_url = "http://localhost:8000"
|
|
313
302
|
mock_config.api_key = "test_key"
|
|
314
303
|
mock_config.timeout = 30.0
|
|
@@ -343,7 +332,6 @@ class HumalabTest(unittest.TestCase):
|
|
|
343
332
|
timeout = 120.0
|
|
344
333
|
|
|
345
334
|
mock_config = Mock()
|
|
346
|
-
mock_config.entity = "test_entity"
|
|
347
335
|
mock_config.base_url = "http://localhost:8000"
|
|
348
336
|
mock_config.api_key = "default_key"
|
|
349
337
|
mock_config.timeout = 30.0
|
humalab/run.py
CHANGED
|
@@ -8,7 +8,6 @@ from humalab.scenario import Scenario
|
|
|
8
8
|
|
|
9
9
|
class Run:
|
|
10
10
|
def __init__(self,
|
|
11
|
-
entity: str,
|
|
12
11
|
project: str,
|
|
13
12
|
scenario: Scenario,
|
|
14
13
|
name: str | None = None,
|
|
@@ -20,7 +19,6 @@ class Run:
|
|
|
20
19
|
Initialize a new Run instance.
|
|
21
20
|
|
|
22
21
|
Args:
|
|
23
|
-
entity (str): The entity (user or team) under which the run is created.
|
|
24
22
|
project (str): The project name under which the run is created.
|
|
25
23
|
scenario (Scenario): The scenario instance for the run.
|
|
26
24
|
name (str | None): The name of the run.
|
|
@@ -28,7 +26,6 @@ class Run:
|
|
|
28
26
|
id (str | None): The unique identifier for the run. If None, a UUID is generated.
|
|
29
27
|
tags (list[str] | None): A list of tags associated with the run.
|
|
30
28
|
"""
|
|
31
|
-
self._entity = entity
|
|
32
29
|
self._project = project
|
|
33
30
|
self._id = id or str(uuid.uuid4())
|
|
34
31
|
self._name = name or ""
|
|
@@ -42,15 +39,6 @@ class Run:
|
|
|
42
39
|
|
|
43
40
|
self._metrics = {}
|
|
44
41
|
|
|
45
|
-
@property
|
|
46
|
-
def entity(self) -> str:
|
|
47
|
-
"""The entity (user or team) under which the run is created.
|
|
48
|
-
|
|
49
|
-
Returns:
|
|
50
|
-
str: The entity name.
|
|
51
|
-
"""
|
|
52
|
-
return self._entity
|
|
53
|
-
|
|
54
42
|
@property
|
|
55
43
|
def project(self) -> str:
|
|
56
44
|
"""The project name under which the run is created.
|
humalab/scenario.py
CHANGED
|
@@ -17,6 +17,7 @@ import copy
|
|
|
17
17
|
import uuid
|
|
18
18
|
|
|
19
19
|
DISTRIBUTION_MAP = {
|
|
20
|
+
# 0D distributions
|
|
20
21
|
"uniform": Uniform,
|
|
21
22
|
"bernoulli": Bernoulli,
|
|
22
23
|
"categorical": Categorical,
|
|
@@ -24,16 +25,163 @@ DISTRIBUTION_MAP = {
|
|
|
24
25
|
"log_uniform": LogUniform,
|
|
25
26
|
"gaussian": Gaussian,
|
|
26
27
|
"truncated_gaussian": TruncatedGaussian,
|
|
28
|
+
|
|
29
|
+
# 1D distributions
|
|
30
|
+
"uniform_1d": Uniform,
|
|
31
|
+
"bernoulli_1d": Bernoulli,
|
|
32
|
+
"categorical_1d": Categorical,
|
|
33
|
+
"discrete_1d": Discrete,
|
|
34
|
+
"log_uniform_1d": LogUniform,
|
|
35
|
+
"gaussian_1d": Gaussian,
|
|
36
|
+
"truncated_gaussian_1d": TruncatedGaussian,
|
|
37
|
+
|
|
38
|
+
# 2D distributions
|
|
39
|
+
"uniform_2d": Uniform,
|
|
40
|
+
"bernoulli_2d": Bernoulli,
|
|
41
|
+
"categorical_2d": Categorical,
|
|
42
|
+
"discrete_2d": Discrete,
|
|
43
|
+
"log_uniform_2d": LogUniform,
|
|
44
|
+
"gaussian_2d": Gaussian,
|
|
45
|
+
"truncated_gaussian_2d": TruncatedGaussian,
|
|
46
|
+
|
|
47
|
+
# 3D distributions
|
|
48
|
+
"uniform_3d": Uniform,
|
|
49
|
+
"bernoulli_3d": Bernoulli,
|
|
50
|
+
"categorical_3d": Categorical,
|
|
51
|
+
"discrete_3d": Discrete,
|
|
52
|
+
"log_uniform_3d": LogUniform,
|
|
53
|
+
"gaussian_3d": Gaussian,
|
|
54
|
+
"truncated_gaussian_3d": TruncatedGaussian,
|
|
55
|
+
|
|
56
|
+
# 4D distributions
|
|
57
|
+
"uniform_4d": Uniform,
|
|
58
|
+
"bernoulli_4d": Bernoulli,
|
|
59
|
+
"categorical_4d": Categorical,
|
|
60
|
+
"discrete_4d": Discrete,
|
|
61
|
+
"log_uniform_4d": LogUniform,
|
|
62
|
+
"gaussian_4d": Gaussian,
|
|
63
|
+
"truncated_gaussian_4d": TruncatedGaussian,
|
|
64
|
+
|
|
65
|
+
# nD distributions
|
|
66
|
+
"uniform_nd": Uniform,
|
|
67
|
+
"bernoulli_nd": Bernoulli,
|
|
68
|
+
"categorical_nd": Categorical,
|
|
69
|
+
"discrete_nd": Discrete,
|
|
70
|
+
"log_uniform_nd": LogUniform,
|
|
71
|
+
"gaussian_nd": Gaussian,
|
|
72
|
+
"truncated_gaussian_nd": TruncatedGaussian,
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
DISTRIBUTION_DIMENSION_MAP = {
|
|
76
|
+
# 0D distributions
|
|
77
|
+
"uniform": 0,
|
|
78
|
+
"bernoulli": 0,
|
|
79
|
+
"categorical": 0,
|
|
80
|
+
"discrete": 0,
|
|
81
|
+
"log_uniform": 0,
|
|
82
|
+
"gaussian": 0,
|
|
83
|
+
"truncated_gaussian": 0,
|
|
84
|
+
|
|
85
|
+
# 1D distributions
|
|
86
|
+
"uniform_1d": 1,
|
|
87
|
+
"bernoulli_1d": 1,
|
|
88
|
+
"categorical_1d": 1,
|
|
89
|
+
"discrete_1d": 1,
|
|
90
|
+
"log_uniform_1d": 1,
|
|
91
|
+
"gaussian_1d": 1,
|
|
92
|
+
"truncated_gaussian_1d": 1,
|
|
93
|
+
|
|
94
|
+
# 2D distributions
|
|
95
|
+
"uniform_2d": 2,
|
|
96
|
+
"bernoulli_2d": 2,
|
|
97
|
+
"categorical_2d": 2,
|
|
98
|
+
"discrete_2d": 2,
|
|
99
|
+
"log_uniform_2d": 2,
|
|
100
|
+
"gaussian_2d": 2,
|
|
101
|
+
"truncated_gaussian_2d": 2,
|
|
102
|
+
|
|
103
|
+
# 3D distributions
|
|
104
|
+
"uniform_3d": 3,
|
|
105
|
+
"bernoulli_3d": 3,
|
|
106
|
+
"categorical_3d": 3,
|
|
107
|
+
"discrete_3d": 3,
|
|
108
|
+
"log_uniform_3d": 3,
|
|
109
|
+
"gaussian_3d": 3,
|
|
110
|
+
"truncated_gaussian_3d": 3,
|
|
111
|
+
|
|
112
|
+
# 4D distributions
|
|
113
|
+
"uniform_4d": 4,
|
|
114
|
+
"bernoulli_4d": 4,
|
|
115
|
+
"categorical_4d": 4,
|
|
116
|
+
"discrete_4d": 4,
|
|
117
|
+
"log_uniform_4d": 4,
|
|
118
|
+
"gaussian_4d": 4,
|
|
119
|
+
"truncated_gaussian_4d": 4,
|
|
120
|
+
|
|
121
|
+
# nD distributions
|
|
122
|
+
"uniform_nd": -1,
|
|
123
|
+
"bernoulli_nd": -1,
|
|
124
|
+
"categorical_nd": -1,
|
|
125
|
+
"discrete_nd": -1,
|
|
126
|
+
"log_uniform_nd": -1,
|
|
127
|
+
"gaussian_nd": -1,
|
|
128
|
+
"truncated_gaussian_nd": -1,
|
|
27
129
|
}
|
|
28
130
|
|
|
29
131
|
DISTRIBUTION_PARAM_NUM_MAP = {
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
132
|
+
# 0D distributions
|
|
133
|
+
"uniform": 2,
|
|
134
|
+
"bernoulli": 1,
|
|
135
|
+
"categorical": 2,
|
|
136
|
+
"discrete": 3,
|
|
137
|
+
"log_uniform": 2,
|
|
138
|
+
"gaussian": 2,
|
|
139
|
+
"truncated_gaussian": 4,
|
|
140
|
+
|
|
141
|
+
# 1D distributions
|
|
142
|
+
"uniform_1d": 2,
|
|
143
|
+
"bernoulli_1d": 1,
|
|
144
|
+
"categorical_1d": 2,
|
|
145
|
+
"discrete_1d": 3,
|
|
146
|
+
"log_uniform_1d": 2,
|
|
147
|
+
"gaussian_1d": 2,
|
|
148
|
+
"truncated_gaussian_1d": 4,
|
|
149
|
+
|
|
150
|
+
# 2D distributions
|
|
151
|
+
"uniform_2d": 2,
|
|
152
|
+
"bernoulli_2d": 1,
|
|
153
|
+
"categorical_2d": 2,
|
|
154
|
+
"discrete_2d": 3,
|
|
155
|
+
"log_uniform_2d": 2,
|
|
156
|
+
"gaussian_2d": 2,
|
|
157
|
+
"truncated_gaussian_2d": 4,
|
|
158
|
+
|
|
159
|
+
# 3D distributions
|
|
160
|
+
"uniform_3d": 2,
|
|
161
|
+
"bernoulli_3d": 1,
|
|
162
|
+
"categorical_3d": 2,
|
|
163
|
+
"discrete_3d": 3,
|
|
164
|
+
"log_uniform_3d": 2,
|
|
165
|
+
"gaussian_3d": 2,
|
|
166
|
+
"truncated_gaussian_3d": 4,
|
|
167
|
+
|
|
168
|
+
# 4D distributions
|
|
169
|
+
"uniform_4d": 2,
|
|
170
|
+
"bernoulli_4d": 1,
|
|
171
|
+
"categorical_4d": 2,
|
|
172
|
+
"discrete_4d": 3,
|
|
173
|
+
"log_uniform_4d": 2,
|
|
174
|
+
"gaussian_4d": 2,
|
|
175
|
+
"truncated_gaussian_4d": 4,
|
|
176
|
+
|
|
177
|
+
# nD distributions
|
|
178
|
+
"uniform_nd": 3,
|
|
179
|
+
"bernoulli_nd": 2,
|
|
180
|
+
"categorical_nd": 3,
|
|
181
|
+
"discrete_nd": 4,
|
|
182
|
+
"log_uniform_nd": 3,
|
|
183
|
+
"gaussian_nd": 3,
|
|
184
|
+
"truncated_gaussian_nd": 5,
|
|
37
185
|
}
|
|
38
186
|
|
|
39
187
|
class Scenario:
|
|
@@ -50,7 +198,8 @@ class Scenario:
|
|
|
50
198
|
scenario: str | list | dict | None = None,
|
|
51
199
|
seed: int | None=None,
|
|
52
200
|
scenario_id: str | None=None,
|
|
53
|
-
num_env: int | None = None
|
|
201
|
+
# num_env: int | None = None
|
|
202
|
+
) -> None:
|
|
54
203
|
"""
|
|
55
204
|
Initialize the scenario with the given parameters.
|
|
56
205
|
|
|
@@ -60,19 +209,24 @@ class Scenario:
|
|
|
60
209
|
scenario: The scenario configuration (YAML string, list, or dict).
|
|
61
210
|
seed: Optional seed for random number generation.
|
|
62
211
|
scenario_id: Optional scenario ID. If None, a new UUID is generated.
|
|
63
|
-
num_env: Optional number of parallel environments.
|
|
212
|
+
# num_env: Optional number of parallel environments.
|
|
64
213
|
"""
|
|
65
214
|
self._run_id = run_id
|
|
66
215
|
self._episode_id = episode_id
|
|
67
216
|
self._metrics = {}
|
|
68
217
|
|
|
69
|
-
self._num_env = num_env
|
|
218
|
+
self._num_env = None # num_env
|
|
70
219
|
self._scenario_id = scenario_id or str(uuid.uuid4())
|
|
71
220
|
self._generator = np.random.default_rng(seed)
|
|
72
221
|
self._configure()
|
|
73
222
|
scenario = scenario or {}
|
|
74
223
|
self._scenario_template = OmegaConf.create(scenario)
|
|
75
224
|
self.reset(episode_id=episode_id)
|
|
225
|
+
|
|
226
|
+
def _validate_distribution_params(self, dist_name: str, *args: tuple) -> None:
|
|
227
|
+
dimensions = DISTRIBUTION_DIMENSION_MAP[dist_name]
|
|
228
|
+
if not DISTRIBUTION_MAP[dist_name].validate(dimensions, *args):
|
|
229
|
+
raise ValueError(f"Invalid parameters for distribution {dist_name} with dimensions {dimensions}: {args}")
|
|
76
230
|
|
|
77
231
|
def _get_final_size(self, size: int | tuple[int, ...] | None) -> int | tuple[int, ...] | None:
|
|
78
232
|
n = self._num_env
|
|
@@ -127,6 +281,7 @@ class Scenario:
|
|
|
127
281
|
args = args[:DISTRIBUTION_PARAM_NUM_MAP[dist_name]]
|
|
128
282
|
print(f"Warning: Too many parameters for {dist_name}, expected {DISTRIBUTION_PARAM_NUM_MAP[dist_name]}, got {len(args)}. Extra parameters will be ignored.")
|
|
129
283
|
|
|
284
|
+
self._validate_distribution_params(dist_name, *args)
|
|
130
285
|
# print("_node_: ", _node_, type(_node_))
|
|
131
286
|
# print("_root_: ", _root_, type(_root_))
|
|
132
287
|
# print("_parent_: ", _parent_, type(_parent_))
|
|
@@ -135,20 +290,21 @@ class Scenario:
|
|
|
135
290
|
|
|
136
291
|
root_yaml = yaml.safe_load(OmegaConf.to_yaml(_root_))
|
|
137
292
|
key_path = self._get_node_path(root_yaml, str(_node_))
|
|
138
|
-
# print("Key path: ", key_path)
|
|
139
293
|
|
|
140
294
|
if key_path not in self._metrics:
|
|
141
295
|
self._metrics[key_path] = DistributionMetric(name=key_path,
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
296
|
+
distribution_type=dist_name,
|
|
297
|
+
run_id=self._run_id,
|
|
298
|
+
episode_id=self._episode_id,
|
|
299
|
+
granularity=MetricGranularity.EPISODE)
|
|
146
300
|
|
|
147
301
|
shape = None
|
|
148
302
|
|
|
149
|
-
if
|
|
303
|
+
if DISTRIBUTION_DIMENSION_MAP[dist_name] == -1:
|
|
150
304
|
shape = args[DISTRIBUTION_PARAM_NUM_MAP[dist_name] - 1]
|
|
151
305
|
args = args[:-1]
|
|
306
|
+
else:
|
|
307
|
+
shape = DISTRIBUTION_DIMENSION_MAP[dist_name] if DISTRIBUTION_DIMENSION_MAP[dist_name] > 0 else None
|
|
152
308
|
shape = self._get_final_size(shape)
|
|
153
309
|
|
|
154
310
|
key = str(_node_)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
humalab/__init__.py,sha256=LIL4eEPT_Boiond6pZegbAPvZwNX-ZWHHMVPkv3ehcU,140
|
|
2
|
+
humalab/constants.py,sha256=YSiUI7R7g0gkImD6ezufRlOMdIBS5wJ--dLy11Qb2qY,135
|
|
3
|
+
humalab/episode.py,sha256=mfoz57O2gQBYWbkqqFN8bzqjC8pjIib3vp0Gn6k3sHA,733
|
|
4
|
+
humalab/humalab.py,sha256=dcIS6bbMCbwl6654OFXmcU3E38FBXxWUC3H9c6wOsws,6208
|
|
5
|
+
humalab/humalab_api_client.py,sha256=QS0VMLpT4hObT9um9Pg1TkSdVabRzJ0IBpsn87kz_v4,23103
|
|
6
|
+
humalab/humalab_config.py,sha256=K-RC1MfAhuD_FCORySV7uyjKzW-bYf2tY6EOZslR0kg,2316
|
|
7
|
+
humalab/humalab_main.py,sha256=rhNPPJUODNqiKzbRce6TtgTyAzp_nKaN4i6kv18iTbw,5097
|
|
8
|
+
humalab/humalab_test.py,sha256=TI2EEbEFmkFUL1OBpPbEmQWgkTZ-tRwtZQ7AIzZxGHw,18469
|
|
9
|
+
humalab/run.py,sha256=PgyZ6DW6Dy-eNqWIKh9NXClDd4m5BVNZaLZV9h62Z5g,7480
|
|
10
|
+
humalab/scenario.py,sha256=Aw5S9_JZJLqmsMeDJxL5GwPklQahaPMLiTVVUBsE4IQ,12274
|
|
11
|
+
humalab/scenario_test.py,sha256=9AyDj_l_43bO_ovhzhIvADTh4bAkq8YaMnPQ_sRPTog,28604
|
|
12
|
+
humalab/assets/__init__.py,sha256=xDYsBILuE1PZ2inkjc4uuiPI0o7Hs_EOXmOfj7tMoAM,146
|
|
13
|
+
humalab/assets/archive.py,sha256=PALZRnpNExDfXiURVNEj6xxWqcW4nd9UBZ7QIHa8mI8,3119
|
|
14
|
+
humalab/assets/resource_manager.py,sha256=WcthO8Bgw_FjJEDPIWEBPP4XNkynoH7-raftjdjfubg,2684
|
|
15
|
+
humalab/assets/files/__init__.py,sha256=9XF-Zp2nldx060v8A3tMTcB5o5vJCUTFKF9rrIFZE_s,111
|
|
16
|
+
humalab/assets/files/resource_file.py,sha256=mvwmE13dQWUu4XGi4kL6hzsYadldt3fVkGubRZ1D-6w,1020
|
|
17
|
+
humalab/assets/files/urdf_file.py,sha256=fCn8lDnLnRJvM3r1XcRfx0jRDPnG0yt7H5uCy1lReaQ,2645
|
|
18
|
+
humalab/dists/__init__.py,sha256=Q7zQbFGC_CnTgExMcnRtJdqJitqy1oBk4D6Qyvunlqc,387
|
|
19
|
+
humalab/dists/bernoulli.py,sha256=cXLE0zpnGXInpp5jneD4D0BKO1AOIQNoJwtoNAJhiCE,1973
|
|
20
|
+
humalab/dists/categorical.py,sha256=plEIZIx5LRiaNreUCIk9EkhBD6eflxwMJy3XbseeUBw,2114
|
|
21
|
+
humalab/dists/discrete.py,sha256=kaygCgPpeUK5uXYZVUrpMFuUFU2_IQwTBw57pyKW79U,2887
|
|
22
|
+
humalab/dists/distribution.py,sha256=t0qTUjS_N0adiy_j2fdf-NHSlRs1pr0swpnszizs04I,1048
|
|
23
|
+
humalab/dists/gaussian.py,sha256=JEpcA7flE5ZLpUC_LExdoZu-lGEbjDky9ux6IjeN8h8,2590
|
|
24
|
+
humalab/dists/log_uniform.py,sha256=4DV5rCAIjhaIxG1Fu6x9r9qdidwvbCyv4x2NusutBeg,2624
|
|
25
|
+
humalab/dists/truncated_gaussian.py,sha256=aYSy24Rvk7Uk5qoHj7NcnD3u-zK1PjUGOQDcEF22WZQ,4005
|
|
26
|
+
humalab/dists/uniform.py,sha256=ouUAY8fvtu7azNCltU9g5t8jCw5OFQyYp8BlD7OWS5E,2545
|
|
27
|
+
humalab/evaluators/__init__.py,sha256=p1JmSbA01s9_JvNteuIy-gk7-JQTWAkQGqgJxqz34-Q,581
|
|
28
|
+
humalab/metrics/__init__.py,sha256=e0PPkAMP5nW-kGfb67SjMMlgxK9Bkp7nQVD-JWoV-qw,246
|
|
29
|
+
humalab/metrics/dist_metric.py,sha256=C7IpdFolw-VpkTHv-HTAK63kafH-WUjRTLxbF7h4W7g,921
|
|
30
|
+
humalab/metrics/metric.py,sha256=W1mWQKEPVs9x257zzJvJQmAadRNnDqGAEU2BAq1skwM,4194
|
|
31
|
+
humalab/metrics/summary.py,sha256=CloYeVkYgZAiaeM2gS6V8_tABukTkxAFJt0mpfmpbLI,2255
|
|
32
|
+
humalab-0.0.5.dist-info/licenses/LICENSE,sha256=Gy0Nw_Z9pbrNSu-loW-PCDWJyrC8eWpIqqIGW-DFtp8,1064
|
|
33
|
+
humalab-0.0.5.dist-info/METADATA,sha256=on4y8DY6lYIvJqCmyTlDAyriRrYWTnHjoo_LgExTxDg,1704
|
|
34
|
+
humalab-0.0.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
35
|
+
humalab-0.0.5.dist-info/entry_points.txt,sha256=aY-hS7Kg8y5kGgYA14YmtTz5odBrgJIZ2fQMXAbVW_U,49
|
|
36
|
+
humalab-0.0.5.dist-info/top_level.txt,sha256=hp7XXBDE40hi9T3Jx6mPFc6wJbAMzektD5VWXlSCW6o,8
|
|
37
|
+
humalab-0.0.5.dist-info/RECORD,,
|
humalab/assets/resource_file.py
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
class ResourceFile:
|
|
4
|
-
def __init__(self,
|
|
5
|
-
name: str,
|
|
6
|
-
version: int,
|
|
7
|
-
resource_type: str,
|
|
8
|
-
filepath: str):
|
|
9
|
-
self._name = name
|
|
10
|
-
self._version = version
|
|
11
|
-
self._resource_type = resource_type
|
|
12
|
-
self._filepath = filepath
|
|
13
|
-
|
|
14
|
-
@property
|
|
15
|
-
def name(self) -> str:
|
|
16
|
-
return self._name
|
|
17
|
-
|
|
18
|
-
@property
|
|
19
|
-
def version(self) -> int:
|
|
20
|
-
return self._version
|
|
21
|
-
|
|
22
|
-
@property
|
|
23
|
-
def resource_type(self) -> str:
|
|
24
|
-
return self._resource_type
|
|
25
|
-
|
|
26
|
-
@property
|
|
27
|
-
def filepath(self) -> str:
|
|
28
|
-
return self._filepath
|