code-loader 1.0.193.dev4__py3-none-any.whl → 1.0.193.dev5__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.
- code_loader/contract/datasetclasses.py +64 -51
- code_loader/inner_leap_binder/leapbinder.py +24 -101
- code_loader/inner_leap_binder/leapbinder_decorators.py +260 -895
- code_loader/leaploader.py +255 -203
- code_loader/leaploaderbase.py +3 -67
- code_loader/utils.py +5 -45
- {code_loader-1.0.193.dev4.dist-info → code_loader-1.0.193.dev5.dist-info}/METADATA +1 -1
- {code_loader-1.0.193.dev4.dist-info → code_loader-1.0.193.dev5.dist-info}/RECORD +10 -10
- {code_loader-1.0.193.dev4.dist-info → code_loader-1.0.193.dev5.dist-info}/LICENSE +0 -0
- {code_loader-1.0.193.dev4.dist-info → code_loader-1.0.193.dev5.dist-info}/WHEEL +0 -0
code_loader/leaploaderbase.py
CHANGED
|
@@ -149,74 +149,10 @@ class LeapLoaderBase:
|
|
|
149
149
|
def has_custom_latent_space_decorator(self) -> bool:
|
|
150
150
|
pass
|
|
151
151
|
|
|
152
|
-
# The autoregressive entry points raise instead of `pass`-ing like the abstract methods
|
|
153
|
-
# above: this class has no ABCMeta, so @abstractmethod is not enforced at runtime and an
|
|
154
|
-
# un-overridden `pass` body would return None — has_autoregressive_step would silently
|
|
155
|
-
# report False for an AR integration and the engine would skip the chain rollout with no
|
|
156
|
-
# error. A stale loader subclass keeps working for non-AR flows and fails loudly here the
|
|
157
|
-
# moment an AR flow reaches it.
|
|
158
|
-
@abstractmethod
|
|
159
152
|
def has_autoregressive_step(self) -> bool:
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
@abstractmethod
|
|
165
|
-
def get_gt(self, state: DataStateEnum, sample_id: Union[int, str]
|
|
166
|
-
) -> Dict[str, npt.NDArray[np.float32]]:
|
|
167
|
-
raise NotImplementedError(f'{type(self).__name__} does not implement get_gt.')
|
|
168
|
-
|
|
169
|
-
@abstractmethod
|
|
170
|
-
def get_prediction_names_in_order(self) -> List[str]:
|
|
171
|
-
raise NotImplementedError(f'{type(self).__name__} does not implement '
|
|
172
|
-
'get_prediction_names_in_order.')
|
|
173
|
-
|
|
174
|
-
@abstractmethod
|
|
175
|
-
def get_autoregressive_latent_space_aggregation(self) -> str:
|
|
176
|
-
raise NotImplementedError(f'{type(self).__name__} does not implement '
|
|
177
|
-
'get_autoregressive_latent_space_aggregation.')
|
|
178
|
-
|
|
179
|
-
@abstractmethod
|
|
180
|
-
def get_autoregressive_decorator_names(self) -> Dict[str, List[str]]:
|
|
181
|
-
raise NotImplementedError(f'{type(self).__name__} does not implement '
|
|
182
|
-
'get_autoregressive_decorator_names.')
|
|
183
|
-
|
|
184
|
-
@abstractmethod
|
|
185
|
-
def run_autoregressive_step(self, sample_id: Union[int, str],
|
|
186
|
-
prev_inputs: Optional[Dict[str, npt.NDArray[np.float32]]],
|
|
187
|
-
prev_outputs: Optional[Dict[str, npt.NDArray[np.float32]]],
|
|
188
|
-
chain_state: Any,
|
|
189
|
-
state: DataStateEnum
|
|
190
|
-
) -> Tuple[Optional[Dict[str, npt.NDArray[np.float32]]], Any]:
|
|
191
|
-
raise NotImplementedError(f'{type(self).__name__} does not implement '
|
|
192
|
-
'run_autoregressive_step.')
|
|
193
|
-
|
|
194
|
-
@abstractmethod
|
|
195
|
-
def run_autoregressive_metric(self, name: str, inputs: Dict[str, npt.NDArray[np.float32]],
|
|
196
|
-
outputs: Dict[str, npt.NDArray[np.float32]], chain_state: Any,
|
|
197
|
-
wired_args: Dict[str, npt.NDArray[np.float32]]) -> Any:
|
|
198
|
-
raise NotImplementedError(f'{type(self).__name__} does not implement '
|
|
199
|
-
'run_autoregressive_metric.')
|
|
200
|
-
|
|
201
|
-
@abstractmethod
|
|
202
|
-
def run_autoregressive_loss(self, name: str, inputs: Dict[str, npt.NDArray[np.float32]],
|
|
203
|
-
outputs: Dict[str, npt.NDArray[np.float32]], chain_state: Any,
|
|
204
|
-
wired_args: Dict[str, npt.NDArray[np.float32]]) -> Any:
|
|
205
|
-
raise NotImplementedError(f'{type(self).__name__} does not implement '
|
|
206
|
-
'run_autoregressive_loss.')
|
|
207
|
-
|
|
208
|
-
@abstractmethod
|
|
209
|
-
def run_autoregressive_visualizer(self, name: str, inputs: Dict[str, npt.NDArray[np.float32]],
|
|
210
|
-
outputs: Dict[str, npt.NDArray[np.float32]],
|
|
211
|
-
chain_state: Any,
|
|
212
|
-
wired_args: Dict[str, npt.NDArray[np.float32]]) -> Any:
|
|
213
|
-
raise NotImplementedError(f'{type(self).__name__} does not implement '
|
|
214
|
-
'run_autoregressive_visualizer.')
|
|
215
|
-
|
|
216
|
-
@abstractmethod
|
|
217
|
-
def autoregressive_visualizer_by_name(self) -> Dict[str, VisualizerHandlerData]:
|
|
218
|
-
raise NotImplementedError(f'{type(self).__name__} does not implement '
|
|
219
|
-
'autoregressive_visualizer_by_name.')
|
|
153
|
+
# Default False so existing LeapLoaderBase implementations stay valid; the concrete
|
|
154
|
+
# loaders that can answer (LeapLoader in-process, LeapLoaderWithRedis via RPC) override.
|
|
155
|
+
return False
|
|
220
156
|
|
|
221
157
|
@abstractmethod
|
|
222
158
|
def get_heatmap_visualizer_raw_vis_input_arg_name(self, visualizer_name: str) -> Optional[str]:
|
code_loader/utils.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import math
|
|
2
1
|
import sys
|
|
3
2
|
from pathlib import Path
|
|
4
3
|
from types import TracebackType
|
|
@@ -15,6 +14,11 @@ from code_loader.contract.enums import DatasetMetadataType
|
|
|
15
14
|
def to_numpy_return_wrapper(encoder_function: SectionCallableInterface) -> SectionCallableInterface:
|
|
16
15
|
def numpy_encoder_function(idx: Union[int, str], samples: PreprocessResponse) -> npt.NDArray[np.float32]:
|
|
17
16
|
result = encoder_function(idx, samples)
|
|
17
|
+
if isinstance(result, list) and len(result) > 0 and all(isinstance(sample, np.ndarray) for sample in result):
|
|
18
|
+
# A list of per-sample arrays only comes from a grouped encoder (a flat encoder returns
|
|
19
|
+
# a single array). Never stack it into a (B, *) batch — grouping is only a storage
|
|
20
|
+
# read-unit; batching the group to the model's B is the engine's single responsibility.
|
|
21
|
+
return result
|
|
18
22
|
numpy_result: npt.NDArray[np.float32] = np.array(result)
|
|
19
23
|
return numpy_result
|
|
20
24
|
|
|
@@ -102,47 +106,3 @@ def get_metadata_type_from_variable(variable: Union[Optional[str], int, bool, Op
|
|
|
102
106
|
f"The return type should be one of [int, float, str, bool]. Got {metadata_type}")
|
|
103
107
|
return dataset_metadata_type
|
|
104
108
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
AUTOREGRESSIVE_STATE_LEAF_TYPES = (np.ndarray, np.generic, int, float, str, bool, type(None))
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
def validate_autoregressive_state_types(value: Any, path: str = 'state') -> None:
|
|
111
|
-
if isinstance(value, dict):
|
|
112
|
-
for key, item in value.items():
|
|
113
|
-
if not isinstance(key, str):
|
|
114
|
-
raise AssertionError(
|
|
115
|
-
f'autoregressive state validation failed: dict key {key!r} at {path} must be '
|
|
116
|
-
f'a string. Got {type(key).__name__}.')
|
|
117
|
-
validate_autoregressive_state_types(item, f'{path}[{key!r}]')
|
|
118
|
-
return
|
|
119
|
-
if isinstance(value, (list, tuple)):
|
|
120
|
-
for i, item in enumerate(value):
|
|
121
|
-
validate_autoregressive_state_types(item, f'{path}[{i}]')
|
|
122
|
-
return
|
|
123
|
-
if not isinstance(value, AUTOREGRESSIVE_STATE_LEAF_TYPES):
|
|
124
|
-
raise AssertionError(
|
|
125
|
-
f'autoregressive state validation failed: {path} holds a {type(value).__name__}. '
|
|
126
|
-
f'State must be built only from numpy arrays, numbers, strings, bools and nests of '
|
|
127
|
-
f'dicts/lists of those — it is serialized to the platform queue on every chain step.')
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
def autoregressive_nests_equal(a: Any, b: Any) -> bool:
|
|
131
|
-
if isinstance(a, dict) or isinstance(b, dict):
|
|
132
|
-
return isinstance(a, dict) and isinstance(b, dict) and set(a) == set(b) and \
|
|
133
|
-
all(autoregressive_nests_equal(a[key], b[key]) for key in a)
|
|
134
|
-
if isinstance(a, (list, tuple)) or isinstance(b, (list, tuple)):
|
|
135
|
-
return isinstance(a, (list, tuple)) and isinstance(b, (list, tuple)) and \
|
|
136
|
-
len(a) == len(b) and all(autoregressive_nests_equal(x, y) for x, y in zip(a, b))
|
|
137
|
-
if isinstance(a, np.ndarray) or isinstance(b, np.ndarray):
|
|
138
|
-
if not (isinstance(a, np.ndarray) and isinstance(b, np.ndarray) and a.shape == b.shape):
|
|
139
|
-
return False
|
|
140
|
-
# NaN leaves must equal themselves: this comparison backs the determinism checks, where
|
|
141
|
-
# NaN padding / running stats in a perfectly deterministic hook are legitimate.
|
|
142
|
-
if a.dtype.kind in 'fc' and b.dtype.kind in 'fc':
|
|
143
|
-
return bool(np.array_equal(a, b, equal_nan=True))
|
|
144
|
-
return bool(np.array_equal(a, b))
|
|
145
|
-
if isinstance(a, (float, np.floating)) and isinstance(b, (float, np.floating)) and \
|
|
146
|
-
math.isnan(a) and math.isnan(b):
|
|
147
|
-
return True
|
|
148
|
-
return bool(a == b)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
LICENSE,sha256=qIwWjdspQeSMTtnFZBC8MuT-95L02FPvzRUdWFxrwJY,1067
|
|
2
2
|
code_loader/__init__.py,sha256=outxRQ0M-zMfV0QGVJmAed5qWfRmyD0TV6-goEGAzBw,406
|
|
3
3
|
code_loader/contract/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
code_loader/contract/datasetclasses.py,sha256=
|
|
4
|
+
code_loader/contract/datasetclasses.py,sha256=USxsP1ax2knqO1DXNMsmzzNCxWVdp5PtSdL1axVT330,14382
|
|
5
5
|
code_loader/contract/enums.py,sha256=2q-IV_5g9lLE306DIbWA1c0tn5IhDtxsKxyV1x_Lreg,1671
|
|
6
6
|
code_loader/contract/exceptions.py,sha256=jWqu5i7t-0IG0jGRsKF4DjJdrsdpJjIYpUkN1F4RiyQ,51
|
|
7
7
|
code_loader/contract/mapping.py,sha256=sWJhpng-IkOzQnWQdMT5w2ZZ3X1Z_OOzSwCLXIS7oxE,1446
|
|
@@ -21,18 +21,18 @@ code_loader/experiment_api/types.py,sha256=MY8xFARHwdVA7p4dxyhD60ShmttgTvb4qdp1o
|
|
|
21
21
|
code_loader/experiment_api/utils.py,sha256=XZHtxge12TS4H4-8PjV3sKuhp8Ud6ojAiIzTZJEqBqc,3304
|
|
22
22
|
code_loader/experiment_api/workingspace_config_utils.py,sha256=DLzXQCg4dgTV_YgaSbeTVzq-2ja_SQw4zi7LXwKL9cY,990
|
|
23
23
|
code_loader/inner_leap_binder/__init__.py,sha256=koOlJyMNYzGbEsoIbXathSmQ-L38N_pEXH_HvL7beXU,99
|
|
24
|
-
code_loader/inner_leap_binder/leapbinder.py,sha256=
|
|
25
|
-
code_loader/inner_leap_binder/leapbinder_decorators.py,sha256=
|
|
26
|
-
code_loader/leaploader.py,sha256=
|
|
27
|
-
code_loader/leaploaderbase.py,sha256=
|
|
24
|
+
code_loader/inner_leap_binder/leapbinder.py,sha256=D-ahDW-1ZiB9wqPkiIMz8eOD6p_Z3spm5b_Mi8y0af0,48340
|
|
25
|
+
code_loader/inner_leap_binder/leapbinder_decorators.py,sha256=7hUDsG2YrRh_HgLmVidTvwi8xr4eH70r2MWmSWfY6aY,143870
|
|
26
|
+
code_loader/leaploader.py,sha256=Q2f_NE81tjdY97DlxiMEiXDQ3rY1PgqVLKb_Liuk5g0,69634
|
|
27
|
+
code_loader/leaploaderbase.py,sha256=2UPunTcEZRs99cbFXkNDWdFrs5nQ7EG_T2qwZBepEXY,6788
|
|
28
28
|
code_loader/mixpanel_tracker.py,sha256=rNwRmFifNbdUoqLQvvhhgpKczWpWiEmd8MfyJe27sxw,9131
|
|
29
29
|
code_loader/plot_functions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
30
30
|
code_loader/plot_functions/plot_functions.py,sha256=2DC-zlVaN13P4VNx5d8csgs80C6SisaeP1-Kq2LW7iM,16075
|
|
31
31
|
code_loader/plot_functions/visualize.py,sha256=gsBAYYkwMh7jIpJeDMPS8G4CW-pxwx6LznoQIvi4vpo,657
|
|
32
|
-
code_loader/utils.py,sha256=
|
|
32
|
+
code_loader/utils.py,sha256=SPDQ4_f67hOIOgTfaTGlwBfbnusPrzH1OBYDLEndyr8,4413
|
|
33
33
|
code_loader/visualizers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
34
34
|
code_loader/visualizers/default_visualizers.py,sha256=onRnLE_TXfgLN4o52hQIOOhUcFexGlqJ3xSpQDVLuZM,2604
|
|
35
|
-
code_loader-1.0.193.
|
|
36
|
-
code_loader-1.0.193.
|
|
37
|
-
code_loader-1.0.193.
|
|
38
|
-
code_loader-1.0.193.
|
|
35
|
+
code_loader-1.0.193.dev5.dist-info/LICENSE,sha256=qIwWjdspQeSMTtnFZBC8MuT-95L02FPvzRUdWFxrwJY,1067
|
|
36
|
+
code_loader-1.0.193.dev5.dist-info/METADATA,sha256=E1TUgiZTHN72FSPmsNeAW0oEMaq6kejhO4mIUO_YOmU,1095
|
|
37
|
+
code_loader-1.0.193.dev5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
38
|
+
code_loader-1.0.193.dev5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|