humalab 0.0.4__py3-none-any.whl → 0.0.6__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/__init__.py +11 -0
- humalab/assets/__init__.py +2 -2
- humalab/assets/files/resource_file.py +29 -3
- humalab/assets/files/urdf_file.py +14 -10
- humalab/assets/resource_operator.py +91 -0
- humalab/constants.py +39 -5
- humalab/dists/bernoulli.py +16 -0
- humalab/dists/categorical.py +4 -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 +196 -0
- humalab/humalab.py +116 -153
- humalab/humalab_api_client.py +760 -62
- humalab/humalab_config.py +0 -13
- humalab/humalab_test.py +46 -29
- humalab/metrics/__init__.py +5 -5
- humalab/metrics/code.py +28 -0
- humalab/metrics/metric.py +41 -108
- humalab/metrics/scenario_stats.py +95 -0
- humalab/metrics/summary.py +24 -18
- humalab/run.py +180 -115
- humalab/scenarios/__init__.py +4 -0
- humalab/scenarios/scenario.py +372 -0
- humalab/scenarios/scenario_operator.py +82 -0
- humalab/{scenario_test.py → scenarios/scenario_test.py} +150 -269
- humalab/utils.py +37 -0
- {humalab-0.0.4.dist-info → humalab-0.0.6.dist-info}/METADATA +1 -1
- humalab-0.0.6.dist-info/RECORD +39 -0
- humalab/assets/resource_manager.py +0 -57
- humalab/metrics/dist_metric.py +0 -22
- humalab/scenario.py +0 -225
- humalab-0.0.4.dist-info/RECORD +0 -34
- {humalab-0.0.4.dist-info → humalab-0.0.6.dist-info}/WHEEL +0 -0
- {humalab-0.0.4.dist-info → humalab-0.0.6.dist-info}/entry_points.txt +0 -0
- {humalab-0.0.4.dist-info → humalab-0.0.6.dist-info}/licenses/LICENSE +0 -0
- {humalab-0.0.4.dist-info → humalab-0.0.6.dist-info}/top_level.txt +0 -0
humalab/utils.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import builtins
|
|
2
|
+
|
|
3
|
+
# Define what counts as "standard" types
|
|
4
|
+
STANDARD_TYPES = (
|
|
5
|
+
int, float, complex, bool, str, bytes, bytearray,
|
|
6
|
+
list, tuple, dict, set, frozenset, type(None)
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
def is_standard_type(obj, _seen=None):
|
|
10
|
+
"""Recursively check if an object only contains standard Python types."""
|
|
11
|
+
if _seen is None:
|
|
12
|
+
_seen = set()
|
|
13
|
+
|
|
14
|
+
obj_id = id(obj)
|
|
15
|
+
if obj_id in _seen:
|
|
16
|
+
return True # Prevent infinite recursion for self-referential structures
|
|
17
|
+
_seen.add(obj_id)
|
|
18
|
+
|
|
19
|
+
if isinstance(obj, STANDARD_TYPES):
|
|
20
|
+
if isinstance(obj, (list, tuple, set, frozenset)):
|
|
21
|
+
return all(is_standard_type(i, _seen) for i in obj)
|
|
22
|
+
elif isinstance(obj, dict):
|
|
23
|
+
return all(
|
|
24
|
+
is_standard_type(k, _seen) and is_standard_type(v, _seen)
|
|
25
|
+
for k, v in obj.items()
|
|
26
|
+
)
|
|
27
|
+
return True
|
|
28
|
+
|
|
29
|
+
# If it's a builtin constant type (e.g., Ellipsis, NotImplemented)
|
|
30
|
+
if obj in (Ellipsis, NotImplemented):
|
|
31
|
+
return True
|
|
32
|
+
|
|
33
|
+
# Check if it's a built-in type object (like int, str)
|
|
34
|
+
if isinstance(obj, type) and obj.__module__ == 'builtins':
|
|
35
|
+
return True
|
|
36
|
+
|
|
37
|
+
return False
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
humalab/__init__.py,sha256=d6RcDYAWf4HzzF_is-_nlTZXAg2UjLSoWRJegNOYz9U,416
|
|
2
|
+
humalab/constants.py,sha256=gIdDoKnrAjfCMbnv4MnPncGYQXqELsaVYs3bQmH6k0s,852
|
|
3
|
+
humalab/episode.py,sha256=WpWIxzkQSBm-YGCEnvjL2b5pEN5OQBzFZJb_b3f8mKM,6917
|
|
4
|
+
humalab/humalab.py,sha256=FiC551LnCa1iQOvQ9tOUsbocs2Q2M3zy8gDgMAMFsJg,6712
|
|
5
|
+
humalab/humalab_api_client.py,sha256=uy6Re-e4v-Z5lPhZnu_HeSOcxDfdxW1uaMOb5Dbu0JE,29549
|
|
6
|
+
humalab/humalab_config.py,sha256=K-RC1MfAhuD_FCORySV7uyjKzW-bYf2tY6EOZslR0kg,2316
|
|
7
|
+
humalab/humalab_test.py,sha256=YMwOIH-sAOMnxwq8yR-Ut4vYk5Ksix9zS9yUIxi3GU8,20725
|
|
8
|
+
humalab/run.py,sha256=GSO_YrEkWqEBu7fvPjL1ru-xkEYMvXYXS2ReMm42V3k,10129
|
|
9
|
+
humalab/utils.py,sha256=KMIPoduAbQzha9wvnyX8OjE8X-3TaNpecx2o-kgHbdw,1161
|
|
10
|
+
humalab/assets/__init__.py,sha256=9WnZmRuS04q1GMAVfS8-SIjH5m50kmEnsKC2VAH1obA,167
|
|
11
|
+
humalab/assets/archive.py,sha256=PALZRnpNExDfXiURVNEj6xxWqcW4nd9UBZ7QIHa8mI8,3119
|
|
12
|
+
humalab/assets/resource_operator.py,sha256=YoKQ8_rfHDuvpn7zJsbaOIcouO5Oaehs0duFfB_rczg,4184
|
|
13
|
+
humalab/assets/files/__init__.py,sha256=9XF-Zp2nldx060v8A3tMTcB5o5vJCUTFKF9rrIFZE_s,111
|
|
14
|
+
humalab/assets/files/resource_file.py,sha256=HpPM4FVAya0kEggx8bFB__2S6CxyJyHyWZCQ6VcQLi4,1773
|
|
15
|
+
humalab/assets/files/urdf_file.py,sha256=UehIGgF9qL5oFiMX81l3aolSca7rkzN_B6t6k3o51UE,2802
|
|
16
|
+
humalab/dists/__init__.py,sha256=Q7zQbFGC_CnTgExMcnRtJdqJitqy1oBk4D6Qyvunlqc,387
|
|
17
|
+
humalab/dists/bernoulli.py,sha256=4RSYBkeyTHkqOzkn-of4y_oNJPhhfkMOuW2APjNa8Eo,1975
|
|
18
|
+
humalab/dists/categorical.py,sha256=plEIZIx5LRiaNreUCIk9EkhBD6eflxwMJy3XbseeUBw,2114
|
|
19
|
+
humalab/dists/discrete.py,sha256=X2VufaTsI7x125ev7RL7Sc59JhWh51tlE2dXAD51XBU,2889
|
|
20
|
+
humalab/dists/distribution.py,sha256=t0qTUjS_N0adiy_j2fdf-NHSlRs1pr0swpnszizs04I,1048
|
|
21
|
+
humalab/dists/gaussian.py,sha256=eezw8qpcRIRpoSM7Vgnny8berqsbcfKm0v00Hxv9KI8,2592
|
|
22
|
+
humalab/dists/log_uniform.py,sha256=mcJUYSoapxsIiynq_MZS_1NH1sxlC-Oupop2S3-EVHw,2626
|
|
23
|
+
humalab/dists/truncated_gaussian.py,sha256=tB0BQHaiSDmB1eNb143dKHysbDEG3_pjuCzYBOy4ks8,4009
|
|
24
|
+
humalab/dists/uniform.py,sha256=ouUAY8fvtu7azNCltU9g5t8jCw5OFQyYp8BlD7OWS5E,2545
|
|
25
|
+
humalab/metrics/__init__.py,sha256=lI1QCl_8mws5yfxxrAHCoIj1n5WEtiTZB5mTGFqAPCo,200
|
|
26
|
+
humalab/metrics/code.py,sha256=CybaYFX3KdJLFGshSY9Ss1jpkWwA5X2wD0hZNZJXUJw,713
|
|
27
|
+
humalab/metrics/metric.py,sha256=3lw3386UE3-pWHsOcYXoEM_RBfFR38bqd8Ehzj7aByw,1970
|
|
28
|
+
humalab/metrics/scenario_stats.py,sha256=lW-8tYrKh1nc_mclF7tg_o0UrhDoNgkVHPtabHgzdiQ,3004
|
|
29
|
+
humalab/metrics/summary.py,sha256=Y6AbDJv7vF4N82JqkTmJuwyaJ9WnlgJ6aExT8SSqnGQ,2194
|
|
30
|
+
humalab/scenarios/__init__.py,sha256=Q76ohPaMrU_NVwVVFQrxJIzIFjtibaOS60ljV1I54Os,148
|
|
31
|
+
humalab/scenarios/scenario.py,sha256=SmknTAZ3f304DmOSAKIkaZljrZ-ucxHs062CQKtS7js,12326
|
|
32
|
+
humalab/scenarios/scenario_operator.py,sha256=GxOB20UP-A6J5Y_ftHbWHpIrTMV6dx52r09Tr-WXfWU,3152
|
|
33
|
+
humalab/scenarios/scenario_test.py,sha256=YYSzKfaeZVK0Kv09pVYgZvLP7Zrz02jgUOpQ-0btanc,24397
|
|
34
|
+
humalab-0.0.6.dist-info/licenses/LICENSE,sha256=Gy0Nw_Z9pbrNSu-loW-PCDWJyrC8eWpIqqIGW-DFtp8,1064
|
|
35
|
+
humalab-0.0.6.dist-info/METADATA,sha256=KqqLNrCKPoBkDNYRwUKxjZoS2jogk7pHLaKYBHcBjmE,1704
|
|
36
|
+
humalab-0.0.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
37
|
+
humalab-0.0.6.dist-info/entry_points.txt,sha256=aY-hS7Kg8y5kGgYA14YmtTz5odBrgJIZ2fQMXAbVW_U,49
|
|
38
|
+
humalab-0.0.6.dist-info/top_level.txt,sha256=hp7XXBDE40hi9T3Jx6mPFc6wJbAMzektD5VWXlSCW6o,8
|
|
39
|
+
humalab-0.0.6.dist-info/RECORD,,
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
from humalab.assets.files.resource_file import ResourceFile
|
|
2
|
-
from humalab.humalab_config import HumalabConfig
|
|
3
|
-
from humalab.humalab_api_client import HumaLabApiClient
|
|
4
|
-
from humalab.assets.files.urdf_file import URDFFile
|
|
5
|
-
import os
|
|
6
|
-
from typing import Any
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class ResourceManager:
|
|
10
|
-
def __init__(self,
|
|
11
|
-
api_key: str | None = None,
|
|
12
|
-
host: str | None = None,
|
|
13
|
-
timeout: float | None = None):
|
|
14
|
-
self._humalab_config = HumalabConfig()
|
|
15
|
-
self._base_url = host or self._humalab_config.base_url
|
|
16
|
-
self._api_key = api_key or self._humalab_config.api_key
|
|
17
|
-
self._timeout = timeout or self._humalab_config.timeout
|
|
18
|
-
|
|
19
|
-
self._api_client = HumaLabApiClient(base_url=self._base_url,
|
|
20
|
-
api_key=self._api_key,
|
|
21
|
-
timeout=self._timeout)
|
|
22
|
-
|
|
23
|
-
def _asset_dir(self, name: str, version: int) -> str:
|
|
24
|
-
return os.path.join(self._humalab_config.workspace_path, "assets", name, f"{version}")
|
|
25
|
-
|
|
26
|
-
def _create_asset_dir(self, name: str, version: int) -> bool:
|
|
27
|
-
asset_dir = self._asset_dir(name, version)
|
|
28
|
-
if not os.path.exists(asset_dir):
|
|
29
|
-
os.makedirs(asset_dir, exist_ok=True)
|
|
30
|
-
return True
|
|
31
|
-
return False
|
|
32
|
-
|
|
33
|
-
def download(self,
|
|
34
|
-
name: str,
|
|
35
|
-
version: int | None=None) -> Any:
|
|
36
|
-
resource = self._api_client.get_resource(name=name, version=version)
|
|
37
|
-
file_content = self._api_client.download_resource(name="lerobot")
|
|
38
|
-
filename = os.path.basename(resource['resource_url'])
|
|
39
|
-
filename = os.path.join(self._asset_dir(name, resource["version"]), filename)
|
|
40
|
-
if self._create_asset_dir(name, resource["version"]):
|
|
41
|
-
with open(filename, "wb") as f:
|
|
42
|
-
f.write(file_content)
|
|
43
|
-
|
|
44
|
-
if resource["resource_type"].lower() == "urdf":
|
|
45
|
-
return URDFFile(name=resource["name"],
|
|
46
|
-
version=resource["version"],
|
|
47
|
-
description=resource.get("description"),
|
|
48
|
-
filename=filename,
|
|
49
|
-
urdf_filename=resource.get("filename"),
|
|
50
|
-
created_at=resource.get("created_at"))
|
|
51
|
-
|
|
52
|
-
return ResourceFile(name=name,
|
|
53
|
-
version=resource["version"],
|
|
54
|
-
filename=filename,
|
|
55
|
-
resource_type=resource["resource_type"],
|
|
56
|
-
description=resource.get("description"),
|
|
57
|
-
created_at=resource.get("created_at"))
|
humalab/metrics/dist_metric.py
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
from humalab.metrics.metric import MetricGranularity, Metrics, MetricType
|
|
3
|
-
|
|
4
|
-
class DistributionMetric(Metrics):
|
|
5
|
-
def __init__(self,
|
|
6
|
-
name: str,
|
|
7
|
-
distribution_type: str,
|
|
8
|
-
episode_id: str,
|
|
9
|
-
run_id: str,
|
|
10
|
-
granularity: MetricGranularity = MetricGranularity.EPISODE) -> None:
|
|
11
|
-
"""
|
|
12
|
-
Initialize the distribution metric.
|
|
13
|
-
|
|
14
|
-
Args:
|
|
15
|
-
name (str): The name of the metric.
|
|
16
|
-
distribution_type (str): The type of distribution (e.g., "normal", "uniform").
|
|
17
|
-
episode_id (str): The ID of the episode.
|
|
18
|
-
run_id (str): The ID of the run.
|
|
19
|
-
granularity (MetricGranularity): The granularity of the metric.
|
|
20
|
-
"""
|
|
21
|
-
super().__init__(name, MetricType.DISTRIBUTION, episode_id=episode_id, run_id=run_id, granularity=granularity)
|
|
22
|
-
self.distribution_type = distribution_type
|
humalab/scenario.py
DELETED
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
from typing import Any
|
|
2
|
-
import numpy as np
|
|
3
|
-
from omegaconf import OmegaConf, ListConfig, AnyNode, DictConfig
|
|
4
|
-
import yaml
|
|
5
|
-
from humalab.dists.bernoulli import Bernoulli
|
|
6
|
-
from humalab.dists.categorical import Categorical
|
|
7
|
-
from humalab.dists.uniform import Uniform
|
|
8
|
-
from humalab.dists.discrete import Discrete
|
|
9
|
-
from humalab.dists.log_uniform import LogUniform
|
|
10
|
-
from humalab.dists.gaussian import Gaussian
|
|
11
|
-
from humalab.dists.truncated_gaussian import TruncatedGaussian
|
|
12
|
-
from functools import partial
|
|
13
|
-
from humalab.constants import EpisodeStatus
|
|
14
|
-
from humalab.metrics.dist_metric import DistributionMetric
|
|
15
|
-
from humalab.metrics.metric import MetricGranularity
|
|
16
|
-
import copy
|
|
17
|
-
import uuid
|
|
18
|
-
|
|
19
|
-
DISTRIBUTION_MAP = {
|
|
20
|
-
"uniform": Uniform,
|
|
21
|
-
"bernoulli": Bernoulli,
|
|
22
|
-
"categorical": Categorical,
|
|
23
|
-
"discrete": Discrete,
|
|
24
|
-
"log_uniform": LogUniform,
|
|
25
|
-
"gaussian": Gaussian,
|
|
26
|
-
"truncated_gaussian": TruncatedGaussian,
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
DISTRIBUTION_PARAM_NUM_MAP = {
|
|
30
|
-
"uniform": 3,
|
|
31
|
-
"bernoulli": 2,
|
|
32
|
-
"categorical": 3,
|
|
33
|
-
"discrete": 4,
|
|
34
|
-
"log_uniform": 3,
|
|
35
|
-
"gaussian": 3,
|
|
36
|
-
"truncated_gaussian": 5,
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
class Scenario:
|
|
40
|
-
dist_cache = {}
|
|
41
|
-
def __init__(self) -> None:
|
|
42
|
-
self._generator = np.random.default_rng()
|
|
43
|
-
self._scenario_template = OmegaConf.create()
|
|
44
|
-
self._cur_scenario = OmegaConf.create()
|
|
45
|
-
self._scenario_id = None
|
|
46
|
-
|
|
47
|
-
def init(self,
|
|
48
|
-
run_id: str,
|
|
49
|
-
episode_id: str,
|
|
50
|
-
scenario: str | list | dict | None = None,
|
|
51
|
-
seed: int | None=None,
|
|
52
|
-
scenario_id: str | None=None,
|
|
53
|
-
num_env: int | None = None) -> None:
|
|
54
|
-
"""
|
|
55
|
-
Initialize the scenario with the given parameters.
|
|
56
|
-
|
|
57
|
-
Args:
|
|
58
|
-
run_id: The ID of the current run.
|
|
59
|
-
episode_id: The ID of the current episode.
|
|
60
|
-
scenario: The scenario configuration (YAML string, list, or dict).
|
|
61
|
-
seed: Optional seed for random number generation.
|
|
62
|
-
scenario_id: Optional scenario ID. If None, a new UUID is generated.
|
|
63
|
-
num_env: Optional number of parallel environments.
|
|
64
|
-
"""
|
|
65
|
-
self._run_id = run_id
|
|
66
|
-
self._episode_id = episode_id
|
|
67
|
-
self._metrics = {}
|
|
68
|
-
|
|
69
|
-
self._num_env = num_env
|
|
70
|
-
self._scenario_id = scenario_id or str(uuid.uuid4())
|
|
71
|
-
self._generator = np.random.default_rng(seed)
|
|
72
|
-
self._configure()
|
|
73
|
-
scenario = scenario or {}
|
|
74
|
-
self._scenario_template = OmegaConf.create(scenario)
|
|
75
|
-
self.reset(episode_id=episode_id)
|
|
76
|
-
|
|
77
|
-
def _get_final_size(self, size: int | tuple[int, ...] | None) -> int | tuple[int, ...] | None:
|
|
78
|
-
n = self._num_env
|
|
79
|
-
if size is None:
|
|
80
|
-
return n
|
|
81
|
-
if n is None:
|
|
82
|
-
return size
|
|
83
|
-
if isinstance(size, int):
|
|
84
|
-
return (n, size)
|
|
85
|
-
return (n, *size)
|
|
86
|
-
|
|
87
|
-
def _get_node_path(self, root: dict | list, node: str) -> str:
|
|
88
|
-
if isinstance(root, list):
|
|
89
|
-
root = {str(i): v for i, v in enumerate(root)}
|
|
90
|
-
|
|
91
|
-
for key, value in root.items():
|
|
92
|
-
if value == node:
|
|
93
|
-
return str(key)
|
|
94
|
-
if isinstance(value, dict):
|
|
95
|
-
sub_path = self._get_node_path(value, node)
|
|
96
|
-
if sub_path:
|
|
97
|
-
return f"{key}.{sub_path}"
|
|
98
|
-
elif isinstance(value, list):
|
|
99
|
-
for idx, item in enumerate(value):
|
|
100
|
-
if item == node:
|
|
101
|
-
return f"{key}[{idx}]"
|
|
102
|
-
if isinstance(item, (dict, list)):
|
|
103
|
-
sub_path = self._get_node_path(item, node)
|
|
104
|
-
if sub_path:
|
|
105
|
-
return f"{key}[{idx}].{sub_path}"
|
|
106
|
-
return ""
|
|
107
|
-
|
|
108
|
-
@staticmethod
|
|
109
|
-
def _convert_to_python(obj) -> Any:
|
|
110
|
-
if not isinstance(obj, (np.ndarray, np.generic)):
|
|
111
|
-
return obj
|
|
112
|
-
|
|
113
|
-
# NumPy scalar (np.generic) or 0-D ndarray
|
|
114
|
-
if isinstance(obj, np.generic) or (isinstance(obj, np.ndarray) and obj.ndim == 0):
|
|
115
|
-
return obj.item()
|
|
116
|
-
|
|
117
|
-
# Regular ndarray (1-D or higher)
|
|
118
|
-
if isinstance(obj, np.ndarray):
|
|
119
|
-
return obj.tolist()
|
|
120
|
-
|
|
121
|
-
return obj
|
|
122
|
-
|
|
123
|
-
def _configure(self) -> None:
|
|
124
|
-
self._clear_resolvers()
|
|
125
|
-
def distribution_resolver(dist_name: str, *args, _node_, _root_, _parent_, **kwargs):
|
|
126
|
-
if len(args) > DISTRIBUTION_PARAM_NUM_MAP[dist_name]:
|
|
127
|
-
args = args[:DISTRIBUTION_PARAM_NUM_MAP[dist_name]]
|
|
128
|
-
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
|
-
|
|
130
|
-
# print("_node_: ", _node_, type(_node_))
|
|
131
|
-
# print("_root_: ", _root_, type(_root_))
|
|
132
|
-
# print("_parent_: ", _parent_, type(_parent_))
|
|
133
|
-
# print("Args: ", args, len(args))
|
|
134
|
-
# print("Kwargs: ", kwargs)
|
|
135
|
-
|
|
136
|
-
root_yaml = yaml.safe_load(OmegaConf.to_yaml(_root_))
|
|
137
|
-
key_path = self._get_node_path(root_yaml, str(_node_))
|
|
138
|
-
# print("Key path: ", key_path)
|
|
139
|
-
|
|
140
|
-
if key_path not in self._metrics:
|
|
141
|
-
self._metrics[key_path] = DistributionMetric(name=key_path,
|
|
142
|
-
distribution_type=dist_name,
|
|
143
|
-
run_id=self._run_id,
|
|
144
|
-
episode_id=self._episode_id,
|
|
145
|
-
granularity=MetricGranularity.EPISODE)
|
|
146
|
-
|
|
147
|
-
shape = None
|
|
148
|
-
|
|
149
|
-
if len(args) == DISTRIBUTION_PARAM_NUM_MAP[dist_name]:
|
|
150
|
-
shape = args[DISTRIBUTION_PARAM_NUM_MAP[dist_name] - 1]
|
|
151
|
-
args = args[:-1]
|
|
152
|
-
shape = self._get_final_size(shape)
|
|
153
|
-
|
|
154
|
-
key = str(_node_)
|
|
155
|
-
if key not in Scenario.dist_cache:
|
|
156
|
-
Scenario.dist_cache[key] = DISTRIBUTION_MAP[dist_name].create(self._generator, *args, size=shape, **kwargs)
|
|
157
|
-
ret_val = Scenario.dist_cache[key].sample()
|
|
158
|
-
ret_val = Scenario._convert_to_python(ret_val)
|
|
159
|
-
|
|
160
|
-
if isinstance(ret_val, list):
|
|
161
|
-
ret_val = ListConfig(ret_val)
|
|
162
|
-
self._metrics[key_path].log(ret_val)
|
|
163
|
-
return ret_val
|
|
164
|
-
|
|
165
|
-
for dist_name in DISTRIBUTION_MAP.keys():
|
|
166
|
-
OmegaConf.register_new_resolver(dist_name, partial(distribution_resolver, dist_name))
|
|
167
|
-
|
|
168
|
-
def _clear_resolvers(self) -> None:
|
|
169
|
-
self.dist_cache.clear()
|
|
170
|
-
OmegaConf.clear_resolvers()
|
|
171
|
-
|
|
172
|
-
def __getattr__(self, name: Any) -> Any:
|
|
173
|
-
if name in self._cur_scenario:
|
|
174
|
-
return self._cur_scenario[name]
|
|
175
|
-
raise AttributeError(f"'Scenario' object has no attribute '{name}'")
|
|
176
|
-
|
|
177
|
-
def __getitem__(self, key: Any) -> Any:
|
|
178
|
-
if key in self._cur_scenario:
|
|
179
|
-
return self._cur_scenario[key]
|
|
180
|
-
raise KeyError(f"'Scenario' object has no key '{key}'")
|
|
181
|
-
|
|
182
|
-
def reset(self,
|
|
183
|
-
episode_id: str | None = None) -> None:
|
|
184
|
-
"""Reset the scenario for a new episode.
|
|
185
|
-
|
|
186
|
-
Args:
|
|
187
|
-
episode_id: Optional new episode ID. If None, keeps the current episode ID.
|
|
188
|
-
"""
|
|
189
|
-
for metric in self._metrics.values():
|
|
190
|
-
metric.reset(episode_id=episode_id)
|
|
191
|
-
self._cur_scenario = copy.deepcopy(self._scenario_template)
|
|
192
|
-
OmegaConf.resolve(self._cur_scenario)
|
|
193
|
-
|
|
194
|
-
def finish(self) -> None:
|
|
195
|
-
"""Finish the scenario and submit final metrics.
|
|
196
|
-
"""
|
|
197
|
-
for metric in self._metrics.values():
|
|
198
|
-
metric.finish()
|
|
199
|
-
|
|
200
|
-
@property
|
|
201
|
-
def template(self) -> Any:
|
|
202
|
-
"""The template scenario configuration.
|
|
203
|
-
|
|
204
|
-
Returns:
|
|
205
|
-
Any: The template scenario as an OmegaConf object.
|
|
206
|
-
"""
|
|
207
|
-
return self._scenario_template
|
|
208
|
-
|
|
209
|
-
@property
|
|
210
|
-
def cur_scenario(self) -> Any:
|
|
211
|
-
"""The current scenario configuration.
|
|
212
|
-
|
|
213
|
-
Returns:
|
|
214
|
-
Any: The current scenario as an OmegaConf object.
|
|
215
|
-
"""
|
|
216
|
-
return self._cur_scenario
|
|
217
|
-
|
|
218
|
-
@property
|
|
219
|
-
def yaml(self) -> str:
|
|
220
|
-
"""The current scenario configuration as a YAML string.
|
|
221
|
-
|
|
222
|
-
Returns:
|
|
223
|
-
str: The current scenario as a YAML string.
|
|
224
|
-
"""
|
|
225
|
-
return OmegaConf.to_yaml(self._cur_scenario)
|
humalab-0.0.4.dist-info/RECORD
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
humalab/__init__.py,sha256=LIL4eEPT_Boiond6pZegbAPvZwNX-ZWHHMVPkv3ehcU,140
|
|
2
|
-
humalab/constants.py,sha256=YSiUI7R7g0gkImD6ezufRlOMdIBS5wJ--dLy11Qb2qY,135
|
|
3
|
-
humalab/humalab.py,sha256=gudSi9nWLY09jJk-JJhAr0d5Gzmru4Y7FA2ttO7HXSQ,8617
|
|
4
|
-
humalab/humalab_api_client.py,sha256=V1PSe1pVngfBUJgxWW-lJzrM1ElQH2ZIolHiDieXlec,8806
|
|
5
|
-
humalab/humalab_config.py,sha256=CdjPgZFGYmmeYq5qsL84ZN8tGdoRP2TjaqS3wojKejg,2698
|
|
6
|
-
humalab/humalab_test.py,sha256=X07HDp9JLllGMuJ2kYxs4WB1o1r1VErn30AAvmn4zuM,19005
|
|
7
|
-
humalab/run.py,sha256=QloVqoZAWlBL5eYVCOqdIRWsjaUoY9BVQvd1BvNEgmY,7841
|
|
8
|
-
humalab/scenario.py,sha256=Zc9ymN5VI-cSnXhX7KYQOM62FCCm8GeAYSyUiUBZl_8,8275
|
|
9
|
-
humalab/scenario_test.py,sha256=9AyDj_l_43bO_ovhzhIvADTh4bAkq8YaMnPQ_sRPTog,28604
|
|
10
|
-
humalab/assets/__init__.py,sha256=fTtwY08nfLxv7whDLGAMWRxwBJDrEZFb-1t19M4cxlc,138
|
|
11
|
-
humalab/assets/archive.py,sha256=PALZRnpNExDfXiURVNEj6xxWqcW4nd9UBZ7QIHa8mI8,3119
|
|
12
|
-
humalab/assets/resource_manager.py,sha256=GeVfjerdtvRL4njQO8a75bZaOf_h4KdFTwN8h103vsg,2605
|
|
13
|
-
humalab/assets/files/__init__.py,sha256=9XF-Zp2nldx060v8A3tMTcB5o5vJCUTFKF9rrIFZE_s,111
|
|
14
|
-
humalab/assets/files/resource_file.py,sha256=mvwmE13dQWUu4XGi4kL6hzsYadldt3fVkGubRZ1D-6w,1020
|
|
15
|
-
humalab/assets/files/urdf_file.py,sha256=t91OdI5vvpv9-ELLyjrE9mkgd1TT2y3pPVpUYSXKZA0,2647
|
|
16
|
-
humalab/dists/__init__.py,sha256=Q7zQbFGC_CnTgExMcnRtJdqJitqy1oBk4D6Qyvunlqc,387
|
|
17
|
-
humalab/dists/bernoulli.py,sha256=6JdeuEPdoL2hVwcP94anmTbIDk_TsSeUctooCzugQag,1500
|
|
18
|
-
humalab/dists/categorical.py,sha256=t0LwN8PKAXa2Qx4RjYRGbTs-6InT3s4Qbi0srr7iDZQ,2025
|
|
19
|
-
humalab/dists/discrete.py,sha256=Yk-JebgGyBgmTrtibmaF5sJLIsdgsCSUwa8arO8XUHQ,2167
|
|
20
|
-
humalab/dists/distribution.py,sha256=t0qTUjS_N0adiy_j2fdf-NHSlRs1pr0swpnszizs04I,1048
|
|
21
|
-
humalab/dists/gaussian.py,sha256=ueGm8CLTj8cVxfU4fi5cQKZVnPRI6dBy_PLzUMqn2-A,1838
|
|
22
|
-
humalab/dists/log_uniform.py,sha256=TeQdZA3JJHh5ptqEvKNLoOgTxafiSkCfF7HIThULo3Y,1868
|
|
23
|
-
humalab/dists/truncated_gaussian.py,sha256=b7LP8O7l5fobdTutatkdGneA_FThurz7fnMpdX9csKs,2691
|
|
24
|
-
humalab/dists/uniform.py,sha256=BBPlL10EUMAbV7UWuktfGlUDEZhRrqHYKi1qY92j7pk,1793
|
|
25
|
-
humalab/metrics/__init__.py,sha256=e0PPkAMP5nW-kGfb67SjMMlgxK9Bkp7nQVD-JWoV-qw,246
|
|
26
|
-
humalab/metrics/dist_metric.py,sha256=C7IpdFolw-VpkTHv-HTAK63kafH-WUjRTLxbF7h4W7g,921
|
|
27
|
-
humalab/metrics/metric.py,sha256=W1mWQKEPVs9x257zzJvJQmAadRNnDqGAEU2BAq1skwM,4194
|
|
28
|
-
humalab/metrics/summary.py,sha256=CloYeVkYgZAiaeM2gS6V8_tABukTkxAFJt0mpfmpbLI,2255
|
|
29
|
-
humalab-0.0.4.dist-info/licenses/LICENSE,sha256=Gy0Nw_Z9pbrNSu-loW-PCDWJyrC8eWpIqqIGW-DFtp8,1064
|
|
30
|
-
humalab-0.0.4.dist-info/METADATA,sha256=TlQItL7q4I-T3NcRMuLKCHcef5Tg85fgMOlY_AEtjbw,1704
|
|
31
|
-
humalab-0.0.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
32
|
-
humalab-0.0.4.dist-info/entry_points.txt,sha256=aY-hS7Kg8y5kGgYA14YmtTz5odBrgJIZ2fQMXAbVW_U,49
|
|
33
|
-
humalab-0.0.4.dist-info/top_level.txt,sha256=hp7XXBDE40hi9T3Jx6mPFc6wJbAMzektD5VWXlSCW6o,8
|
|
34
|
-
humalab-0.0.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|