libinephany 0.15.4__tar.gz → 0.16.1__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.
- libinephany-0.16.1/CODE_VERSION.cfg +1 -0
- {libinephany-0.15.4/libinephany.egg-info → libinephany-0.16.1}/PKG-INFO +1 -1
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/observations/observation_utils.py +14 -3
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/observations/observer_pipeline.py +20 -9
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/observations/observers/observer_containers.py +13 -4
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/observations/pipeline_coordinator.py +9 -1
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/pydantic_models/schemas/observation_models.py +5 -1
- {libinephany-0.15.4 → libinephany-0.16.1/libinephany.egg-info}/PKG-INFO +1 -1
- libinephany-0.15.4/CODE_VERSION.cfg +0 -1
- {libinephany-0.15.4 → libinephany-0.16.1}/LICENSE +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/MANIFEST.in +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/README.md +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/__init__.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/aws/__init__.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/aws/s3_functions.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/observations/__init__.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/observations/observers/__init__.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/observations/observers/base_observers.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/observations/observers/global_observers.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/observations/observers/local_observers.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/observations/post_processors/__init__.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/observations/post_processors/postprocessors.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/observations/statistic_manager.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/observations/statistic_trackers.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/pydantic_models/__init__.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/pydantic_models/configs/__init__.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/pydantic_models/configs/hyperparameter_configs.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/pydantic_models/configs/observer_config.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/pydantic_models/configs/outer_model_config.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/pydantic_models/schemas/__init__.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/pydantic_models/schemas/agent_info.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/pydantic_models/schemas/inner_task_profile.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/pydantic_models/schemas/request_schemas.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/pydantic_models/schemas/response_schemas.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/pydantic_models/schemas/tensor_statistics.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/pydantic_models/states/__init__.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/pydantic_models/states/hyperparameter_states.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/utils/__init__.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/utils/agent_utils.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/utils/asyncio_worker.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/utils/backend_statuses.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/utils/constants.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/utils/directory_utils.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/utils/dropout_utils.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/utils/enums.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/utils/error_severities.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/utils/exceptions.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/utils/import_utils.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/utils/optim_utils.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/utils/random_seeds.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/utils/samplers.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/utils/standardizers.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/utils/torch_distributed_utils.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/utils/torch_utils.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/utils/transforms.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/utils/typing.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/web_apps/__init__.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/web_apps/error_logger.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany/web_apps/web_app_utils.py +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany.egg-info/SOURCES.txt +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany.egg-info/dependency_links.txt +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany.egg-info/requires.txt +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/libinephany.egg-info/top_level.txt +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/pyproject.toml +0 -0
- {libinephany-0.15.4 → libinephany-0.16.1}/setup.cfg +0 -0
@@ -0,0 +1 @@
|
|
1
|
+
0.16.1
|
@@ -4,6 +4,7 @@
|
|
4
4
|
#
|
5
5
|
# ======================================================================================================================
|
6
6
|
|
7
|
+
import math
|
7
8
|
from enum import Enum
|
8
9
|
from itertools import chain
|
9
10
|
from typing import Any, Callable
|
@@ -54,15 +55,25 @@ class StatisticStorageTypes(Enum):
|
|
54
55
|
# ======================================================================================================================
|
55
56
|
|
56
57
|
|
57
|
-
def get_exponential_weighted_average(values: list[float]) -> float:
|
58
|
+
def get_exponential_weighted_average(values: list[int | float]) -> float:
|
58
59
|
"""
|
59
60
|
:param values: List of values to average via EWA.
|
60
61
|
:return: EWA of the given values.
|
61
62
|
"""
|
62
63
|
|
63
|
-
|
64
|
-
|
64
|
+
# Check for NaN and infinite values in input
|
65
|
+
valid_values = [float(val) for val in values if not math.isnan(float(val)) and not math.isinf(float(val))]
|
66
|
+
|
67
|
+
if not valid_values:
|
68
|
+
raise ValueError("Cannot compute exponential weighted average on empty list")
|
65
69
|
|
70
|
+
if len(valid_values) == 1:
|
71
|
+
return valid_values[0]
|
72
|
+
|
73
|
+
exp_weighted_average = pd.Series(valid_values).ewm(alpha=0.1).mean().iloc[-1]
|
74
|
+
assert isinstance(exp_weighted_average, float)
|
75
|
+
assert not math.isnan(exp_weighted_average)
|
76
|
+
assert not math.isinf(exp_weighted_average)
|
66
77
|
return exp_weighted_average
|
67
78
|
|
68
79
|
|
@@ -4,6 +4,7 @@
|
|
4
4
|
#
|
5
5
|
# ======================================================================================================================
|
6
6
|
|
7
|
+
import copy
|
7
8
|
from typing import Any
|
8
9
|
|
9
10
|
import gymnasium as gym
|
@@ -216,33 +217,42 @@ class ObserverPipeline:
|
|
216
217
|
hyperparameter_states: HyperparameterStates,
|
217
218
|
tracked_statistics: dict[str, dict[str, float | TensorStatistics]],
|
218
219
|
actions_taken: dict[str, float | int | None],
|
219
|
-
|
220
|
+
return_dict: bool = False,
|
221
|
+
) -> tuple[dict[str, list[float | int]], bool, dict[str, dict[str, list[float | int]]] | None]:
|
220
222
|
"""
|
221
223
|
:param observation_inputs: Observation input metrics not calculated with statistic trackers.
|
222
224
|
:param hyperparameter_states: HyperparameterStates that manages the hyperparameters.
|
223
225
|
:param tracked_statistics: Dictionary mapping statistic tracker class names to dictionaries mapping module
|
224
226
|
names to floats or TensorStatistic models.
|
225
227
|
:param actions_taken: Dictionary mapping agent IDs to actions taken by that agent.
|
226
|
-
:
|
227
|
-
|
228
|
+
:param return_dict: Whether to return a dictionary of observations as well as the normal vector.
|
229
|
+
:return: Tuple of a dictionary mapping agent ID to that agent's completed observation vector, a boolean
|
230
|
+
indicating whether an observation clip occurred and a dictionary of observations.
|
228
231
|
"""
|
229
232
|
|
230
|
-
global_obs = self.global_observers.observe(
|
233
|
+
global_obs, global_obs_dict = self.global_observers.observe(
|
231
234
|
observation_inputs=observation_inputs,
|
232
235
|
hyperparameter_states=hyperparameter_states,
|
233
236
|
tracked_statistics=tracked_statistics,
|
234
237
|
action_taken=None,
|
238
|
+
return_dict=return_dict,
|
235
239
|
)
|
236
240
|
|
237
|
-
local_obs = {
|
238
|
-
|
241
|
+
local_obs: dict[str, list[float | int]] = {}
|
242
|
+
obs_as_dict: dict[str, dict[str, list[float | int]]] = {}
|
243
|
+
|
244
|
+
for agent_id, agent_observers in self.local_observers.items():
|
245
|
+
local_obs[agent_id], local_obs_dict = agent_observers.observe(
|
239
246
|
observation_inputs=observation_inputs,
|
240
247
|
hyperparameter_states=hyperparameter_states,
|
241
248
|
tracked_statistics=tracked_statistics,
|
242
249
|
action_taken=actions_taken[agent_id] if agent_id in actions_taken else None,
|
250
|
+
return_dict=return_dict,
|
243
251
|
)
|
244
|
-
|
245
|
-
|
252
|
+
|
253
|
+
if return_dict:
|
254
|
+
obs_as_dict[agent_id] = copy.deepcopy(global_obs_dict)
|
255
|
+
obs_as_dict[agent_id].update(local_obs_dict)
|
246
256
|
|
247
257
|
for post_processor in self.post_processors:
|
248
258
|
global_obs, local_obs = post_processor.postprocess(
|
@@ -252,8 +262,9 @@ class ObserverPipeline:
|
|
252
262
|
global_obs, local_obs, obs_clipped = self.clip_observations(
|
253
263
|
globals_to_clip=global_obs, locals_to_clip=local_obs
|
254
264
|
)
|
265
|
+
merged_obs = self.merge_globals_to_locals(global_obs=global_obs, local_obs=local_obs)
|
255
266
|
|
256
|
-
return
|
267
|
+
return merged_obs, obs_clipped, obs_as_dict if return_dict else None
|
257
268
|
|
258
269
|
def inform(self) -> tuple[ObservationInformation, dict[str, ObservationInformation]]:
|
259
270
|
"""
|
{libinephany-0.15.4 → libinephany-0.16.1}/libinephany/observations/observers/observer_containers.py
RENAMED
@@ -132,27 +132,36 @@ class ObserverContainer(ABC):
|
|
132
132
|
hyperparameter_states: HyperparameterStates,
|
133
133
|
tracked_statistics: dict[str, dict[str, float | TensorStatistics]],
|
134
134
|
action_taken: float | int | None,
|
135
|
-
|
135
|
+
return_dict: bool = False,
|
136
|
+
) -> tuple[list[float | int], dict[str, list[float | int]] | None]:
|
136
137
|
"""
|
137
138
|
:param observation_inputs: Observation input metrics not calculated with statistic trackers.
|
138
139
|
:param hyperparameter_states: HyperparameterStates that manages the hyperparameters.
|
139
140
|
:param tracked_statistics: Dictionary mapping statistic tracker class names to dictionaries mapping module
|
140
141
|
names to floats or TensorStatistic models.
|
141
142
|
:param action_taken: Action taken by the agent this class instance is assigned to.
|
142
|
-
:
|
143
|
+
:param return_dict: Whether to return a dictionary of observations as well as the normal vector.
|
144
|
+
:return: Tuple of a list of floats or integers to add to the agent's observation vector and a dictionary of
|
145
|
+
observations as well as the normal vector.
|
143
146
|
"""
|
144
147
|
|
145
148
|
observations = []
|
149
|
+
observations_dict = {}
|
146
150
|
|
147
151
|
for observer in self._observers:
|
148
|
-
|
152
|
+
observer_obs = observer.observe(
|
149
153
|
observation_inputs=observation_inputs,
|
150
154
|
hyperparameter_states=hyperparameter_states,
|
151
155
|
tracked_statistics=tracked_statistics,
|
152
156
|
action_taken=action_taken,
|
153
157
|
)
|
154
158
|
|
155
|
-
|
159
|
+
if return_dict:
|
160
|
+
observations_dict[observer.__class__.__name__] = observer_obs
|
161
|
+
|
162
|
+
observations += observer_obs
|
163
|
+
|
164
|
+
return observations, observations_dict if return_dict else None
|
156
165
|
|
157
166
|
@final
|
158
167
|
def inform(self) -> ObservationInformation:
|
@@ -120,6 +120,7 @@ class ObserverPipelineCoordinator:
|
|
120
120
|
hyperparameter_states: HyperparameterStates,
|
121
121
|
tracked_statistics: dict[str, dict[str, float | TensorStatistics]],
|
122
122
|
actions_taken: dict[str, float | int | None],
|
123
|
+
return_dict: bool = False,
|
123
124
|
) -> Observations:
|
124
125
|
"""
|
125
126
|
:param observation_inputs: Observation input metrics not calculated with statistic trackers.
|
@@ -127,18 +128,21 @@ class ObserverPipelineCoordinator:
|
|
127
128
|
:param tracked_statistics: Dictionary mapping statistic tracker class names to dictionaries mapping module
|
128
129
|
names to floats or TensorStatistic models.
|
129
130
|
:param actions_taken: Dictionary mapping agent IDs to actions taken by that agent.
|
131
|
+
:param return_dict: Whether to return a dictionary of observations as well as the normal vector.
|
130
132
|
:return: Observations pydantic model.
|
131
133
|
"""
|
132
134
|
|
133
135
|
clipped_observations = False
|
134
136
|
observations = {}
|
137
|
+
observations_as_dict: dict[str, dict[str, list[float | int]]] = {}
|
135
138
|
|
136
139
|
for pipeline in self.pipelines:
|
137
|
-
pipeline_observations, pipeline_clipped_observations = pipeline.observe(
|
140
|
+
pipeline_observations, pipeline_clipped_observations, pipeline_observations_dict = pipeline.observe(
|
138
141
|
observation_inputs=observation_inputs,
|
139
142
|
hyperparameter_states=hyperparameter_states,
|
140
143
|
tracked_statistics=tracked_statistics,
|
141
144
|
actions_taken=actions_taken,
|
145
|
+
return_dict=return_dict,
|
142
146
|
)
|
143
147
|
|
144
148
|
clipped_observations = clipped_observations if clipped_observations else pipeline_clipped_observations
|
@@ -152,10 +156,14 @@ class ObserverPipelineCoordinator:
|
|
152
156
|
|
153
157
|
observations[agent_id] = agent_obs
|
154
158
|
|
159
|
+
if return_dict:
|
160
|
+
observations_as_dict[agent_id] = pipeline_observations_dict[agent_id]
|
161
|
+
|
155
162
|
return Observations(
|
156
163
|
observation_inputs=observation_inputs,
|
157
164
|
agent_observations=observations,
|
158
165
|
hit_invalid_value=clipped_observations,
|
166
|
+
observations_as_dict=observations_as_dict if return_dict else None,
|
159
167
|
)
|
160
168
|
|
161
169
|
def inform(self) -> AgentInfo:
|
{libinephany-0.15.4 → libinephany-0.16.1}/libinephany/pydantic_models/schemas/observation_models.py
RENAMED
@@ -51,9 +51,13 @@ class Observations(BaseModel):
|
|
51
51
|
hit_invalid_value: bool
|
52
52
|
|
53
53
|
agent_observations: dict[str, list[float | int]]
|
54
|
+
observations_as_dict: dict[str, dict[str, list[float | int]]] | None = None
|
54
55
|
|
55
56
|
def observations_as_arrays(self, dtype: DTypeLike = np.float32) -> dict[str, np.ndarray]:
|
56
|
-
"""
|
57
|
+
"""
|
58
|
+
:param dtype: Data type to cast the observations to.
|
59
|
+
:return: Dictionary mapping agent IDs to their observation vectors as numpy arrays.
|
60
|
+
"""
|
57
61
|
|
58
62
|
return {
|
59
63
|
agent_id: np.array(observation_vector, dtype=dtype)
|
@@ -1 +0,0 @@
|
|
1
|
-
0.15.4
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{libinephany-0.15.4 → libinephany-0.16.1}/libinephany/observations/observers/base_observers.py
RENAMED
File without changes
|
{libinephany-0.15.4 → libinephany-0.16.1}/libinephany/observations/observers/global_observers.py
RENAMED
File without changes
|
{libinephany-0.15.4 → libinephany-0.16.1}/libinephany/observations/observers/local_observers.py
RENAMED
File without changes
|
{libinephany-0.15.4 → libinephany-0.16.1}/libinephany/observations/post_processors/__init__.py
RENAMED
File without changes
|
{libinephany-0.15.4 → libinephany-0.16.1}/libinephany/observations/post_processors/postprocessors.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{libinephany-0.15.4 → libinephany-0.16.1}/libinephany/pydantic_models/configs/observer_config.py
RENAMED
File without changes
|
{libinephany-0.15.4 → libinephany-0.16.1}/libinephany/pydantic_models/configs/outer_model_config.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{libinephany-0.15.4 → libinephany-0.16.1}/libinephany/pydantic_models/schemas/inner_task_profile.py
RENAMED
File without changes
|
{libinephany-0.15.4 → libinephany-0.16.1}/libinephany/pydantic_models/schemas/request_schemas.py
RENAMED
File without changes
|
{libinephany-0.15.4 → libinephany-0.16.1}/libinephany/pydantic_models/schemas/response_schemas.py
RENAMED
File without changes
|
{libinephany-0.15.4 → libinephany-0.16.1}/libinephany/pydantic_models/schemas/tensor_statistics.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|