libinephany 0.17.0__tar.gz → 0.18.0__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.
Files changed (72) hide show
  1. libinephany-0.18.0/CODE_VERSION.cfg +1 -0
  2. {libinephany-0.17.0/libinephany.egg-info → libinephany-0.18.0}/PKG-INFO +1 -1
  3. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/observations/observer_pipeline.py +4 -2
  4. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/observations/observers/base_observers.py +12 -3
  5. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/observations/observers/observer_containers.py +8 -4
  6. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/observations/pipeline_coordinator.py +1 -1
  7. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/pydantic_models/schemas/observation_models.py +1 -1
  8. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/pydantic_models/schemas/tensor_statistics.py +18 -0
  9. {libinephany-0.17.0 → libinephany-0.18.0/libinephany.egg-info}/PKG-INFO +1 -1
  10. libinephany-0.17.0/CODE_VERSION.cfg +0 -1
  11. {libinephany-0.17.0 → libinephany-0.18.0}/LICENSE +0 -0
  12. {libinephany-0.17.0 → libinephany-0.18.0}/MANIFEST.in +0 -0
  13. {libinephany-0.17.0 → libinephany-0.18.0}/README.md +0 -0
  14. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/__init__.py +0 -0
  15. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/aws/__init__.py +0 -0
  16. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/aws/s3_functions.py +0 -0
  17. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/observations/__init__.py +0 -0
  18. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/observations/observation_utils.py +0 -0
  19. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/observations/observers/__init__.py +0 -0
  20. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/observations/observers/global_observers/__init__.py +0 -0
  21. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/observations/observers/global_observers/base_classes.py +0 -0
  22. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/observations/observers/global_observers/constants.py +0 -0
  23. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/observations/observers/global_observers/gradient_observers.py +0 -0
  24. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/observations/observers/global_observers/hyperparameter_observers.py +0 -0
  25. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/observations/observers/global_observers/loss_observers.py +0 -0
  26. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/observations/observers/global_observers/model_observers.py +0 -0
  27. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/observations/observers/global_observers/progress_observers.py +0 -0
  28. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/observations/observers/local_observers.py +0 -0
  29. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/observations/post_processors/__init__.py +0 -0
  30. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/observations/post_processors/postprocessors.py +0 -0
  31. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/observations/statistic_manager.py +0 -0
  32. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/observations/statistic_trackers.py +0 -0
  33. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/pydantic_models/__init__.py +0 -0
  34. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/pydantic_models/configs/__init__.py +0 -0
  35. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/pydantic_models/configs/hyperparameter_configs.py +0 -0
  36. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/pydantic_models/configs/observer_config.py +0 -0
  37. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/pydantic_models/configs/outer_model_config.py +0 -0
  38. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/pydantic_models/schemas/__init__.py +0 -0
  39. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/pydantic_models/schemas/agent_info.py +0 -0
  40. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/pydantic_models/schemas/inner_task_profile.py +0 -0
  41. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/pydantic_models/schemas/request_schemas.py +0 -0
  42. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/pydantic_models/schemas/response_schemas.py +0 -0
  43. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/pydantic_models/states/__init__.py +0 -0
  44. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/pydantic_models/states/hyperparameter_states.py +0 -0
  45. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/utils/__init__.py +0 -0
  46. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/utils/agent_utils.py +0 -0
  47. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/utils/asyncio_worker.py +0 -0
  48. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/utils/backend_statuses.py +0 -0
  49. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/utils/constants.py +0 -0
  50. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/utils/directory_utils.py +0 -0
  51. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/utils/dropout_utils.py +0 -0
  52. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/utils/enums.py +0 -0
  53. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/utils/error_severities.py +0 -0
  54. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/utils/exceptions.py +0 -0
  55. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/utils/import_utils.py +0 -0
  56. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/utils/optim_utils.py +0 -0
  57. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/utils/random_seeds.py +0 -0
  58. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/utils/samplers.py +0 -0
  59. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/utils/standardizers.py +0 -0
  60. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/utils/torch_distributed_utils.py +0 -0
  61. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/utils/torch_utils.py +0 -0
  62. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/utils/transforms.py +0 -0
  63. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/utils/typing.py +0 -0
  64. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/web_apps/__init__.py +0 -0
  65. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/web_apps/error_logger.py +0 -0
  66. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany/web_apps/web_app_utils.py +0 -0
  67. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany.egg-info/SOURCES.txt +0 -0
  68. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany.egg-info/dependency_links.txt +0 -0
  69. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany.egg-info/requires.txt +0 -0
  70. {libinephany-0.17.0 → libinephany-0.18.0}/libinephany.egg-info/top_level.txt +0 -0
  71. {libinephany-0.17.0 → libinephany-0.18.0}/pyproject.toml +0 -0
  72. {libinephany-0.17.0 → libinephany-0.18.0}/setup.cfg +0 -0
@@ -0,0 +1 @@
1
+ 0.18.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: libinephany
3
- Version: 0.17.0
3
+ Version: 0.18.0
4
4
  Summary: Inephany library containing code commonly used by multiple subpackages.
5
5
  Author-email: Inephany <info@inephany.com>
6
6
  License: Apache 2.0
@@ -218,7 +218,9 @@ class ObserverPipeline:
218
218
  tracked_statistics: dict[str, dict[str, float | TensorStatistics]],
219
219
  actions_taken: dict[str, float | int | None],
220
220
  return_dict: bool = False,
221
- ) -> tuple[dict[str, list[float | int]], bool, dict[str, dict[str, list[float | int]]] | None]:
221
+ ) -> tuple[
222
+ dict[str, list[float | int]], bool, dict[str, dict[str, list[float | int] | dict[str, float | int]]] | None
223
+ ]:
222
224
  """
223
225
  :param observation_inputs: Observation input metrics not calculated with statistic trackers.
224
226
  :param hyperparameter_states: HyperparameterStates that manages the hyperparameters.
@@ -241,7 +243,7 @@ class ObserverPipeline:
241
243
  )
242
244
 
243
245
  local_obs: dict[str, list[float | int]] = {}
244
- obs_as_dict: dict[str, dict[str, list[float | int]]] = {}
246
+ obs_as_dict: dict[str, dict[str, list[float | int] | dict[str, float | int]]] = {}
245
247
 
246
248
  for agent_id, agent_observers in self.local_observers.items():
247
249
  local_obs[agent_id], local_obs_dict = agent_observers.observe(
@@ -204,16 +204,22 @@ class Observer(ABC):
204
204
  hyperparameter_states: HyperparameterStates,
205
205
  tracked_statistics: dict[str, dict[str, float | TensorStatistics]],
206
206
  action_taken: float | int | None,
207
- ) -> list[float | int]:
207
+ return_dict: bool = False,
208
+ ) -> tuple[list[float | int], dict[str, float] | None]:
208
209
  """
209
210
  :param observation_inputs: Observation input metrics not calculated with statistic trackers.
210
211
  :param hyperparameter_states: HyperparameterStates that manages the hyperparameters.
211
212
  :param tracked_statistics: Dictionary mapping statistic tracker class names to dictionaries mapping module
212
213
  names to floats or TensorStatistic models.
213
214
  :param action_taken: Action taken by the agent this class instance is assigned to.
214
- :return: List of floats or integers to add to the agent's observation vector.
215
+ :param return_dict: Whether to return a dictionary of observations as well as the normal vector.
216
+ :return: Tuple of:
217
+ - List of floats or integers to add to the agent's observation vector.
218
+ - Dictionary of specific observation values if the storage type is TensorStatistics and None otherwise.
215
219
  """
216
220
 
221
+ observations_dict: dict[str, float] | None = None
222
+
217
223
  observations = self._observe(
218
224
  observation_inputs=observation_inputs,
219
225
  hyperparameter_states=hyperparameter_states,
@@ -225,6 +231,9 @@ class Observer(ABC):
225
231
  self._cached_observation = deepcopy(observations)
226
232
 
227
233
  if self.observation_format is StatisticStorageTypes.TENSOR_STATISTICS:
234
+ if return_dict:
235
+ observations_dict = observations.as_observation_dict() # type: ignore
236
+
228
237
  observations = observations.to_list(skip_statistics=self.skip_statistics) # type: ignore
229
238
 
230
239
  observations = [observations] if not isinstance(observations, list) else observations # type: ignore
@@ -241,7 +250,7 @@ class Observer(ABC):
241
250
  if not self._validated_observation:
242
251
  self._validate_observation(observations=observations)
243
252
 
244
- return observations
253
+ return observations, observations_dict
245
254
 
246
255
  @final
247
256
  def inform(self) -> float | int | dict[str, float] | None:
@@ -135,7 +135,7 @@ class ObserverContainer(ABC):
135
135
  tracked_statistics: dict[str, dict[str, float | TensorStatistics]],
136
136
  action_taken: float | int | None,
137
137
  return_dict: bool = False,
138
- ) -> tuple[list[float | int], dict[str, list[float | int]] | None]:
138
+ ) -> tuple[list[float | int], dict[str, list[float | int] | dict[str, float | int]] | None]:
139
139
  """
140
140
  :param observation_inputs: Observation input metrics not calculated with statistic trackers.
141
141
  :param hyperparameter_states: HyperparameterStates that manages the hyperparameters.
@@ -148,17 +148,21 @@ class ObserverContainer(ABC):
148
148
  """
149
149
 
150
150
  observations = []
151
- observations_dict = {}
151
+ observations_dict: dict[str, list[float | int] | dict[str, float | int]] = {}
152
152
 
153
153
  for observer in self._observers:
154
- observer_obs = observer.observe(
154
+ observer_obs, observer_obs_dict = observer.observe(
155
155
  observation_inputs=observation_inputs,
156
156
  hyperparameter_states=hyperparameter_states,
157
157
  tracked_statistics=tracked_statistics,
158
158
  action_taken=action_taken,
159
+ return_dict=return_dict,
159
160
  )
160
161
 
161
- if return_dict:
162
+ if return_dict and observer_obs_dict is not None:
163
+ observations_dict[observer.__class__.__name__] = observer_obs_dict
164
+
165
+ elif return_dict:
162
166
  observations_dict[observer.__class__.__name__] = observer_obs
163
167
 
164
168
  observations += observer_obs
@@ -134,7 +134,7 @@ class ObserverPipelineCoordinator:
134
134
 
135
135
  clipped_observations = False
136
136
  observations = {}
137
- observations_as_dict: dict[str, dict[str, list[float | int]]] = {}
137
+ observations_as_dict: dict[str, dict[str, list[float | int] | dict[str, float | int]]] = {}
138
138
 
139
139
  for pipeline in self.pipelines:
140
140
  pipeline_observations, pipeline_clipped_observations, pipeline_observations_dict = pipeline.observe(
@@ -51,7 +51,7 @@ 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
+ observations_as_dict: dict[str, dict[str, list[float | int] | dict[str, float]]] | None = None
55
55
 
56
56
  def observations_as_arrays(self, dtype: DTypeLike = np.float32) -> dict[str, np.ndarray]:
57
57
  """
@@ -7,6 +7,14 @@
7
7
  import torch
8
8
  from pydantic import BaseModel
9
9
 
10
+ # ======================================================================================================================
11
+ #
12
+ # CONSTANTS
13
+ #
14
+ # ======================================================================================================================
15
+
16
+ STRIP_SUFFIX = "_"
17
+
10
18
  # ======================================================================================================================
11
19
  #
12
20
  # CLASSES
@@ -252,3 +260,13 @@ class TensorStatistics(BaseModel):
252
260
  self.inter_quartile_range,
253
261
  ]
254
262
  )
263
+
264
+ def as_observation_dict(self) -> dict[str, float]:
265
+ """
266
+ :return: Dictionary of observation values.
267
+ """
268
+
269
+ return {
270
+ field[:-1] if field.endswith(STRIP_SUFFIX) else field: field_value
271
+ for field, field_value in self.model_dump().items()
272
+ }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: libinephany
3
- Version: 0.17.0
3
+ Version: 0.18.0
4
4
  Summary: Inephany library containing code commonly used by multiple subpackages.
5
5
  Author-email: Inephany <info@inephany.com>
6
6
  License: Apache 2.0
@@ -1 +0,0 @@
1
- 0.17.0
File without changes
File without changes
File without changes
File without changes