code-loader 1.0.184.dev2__py3-none-any.whl → 1.0.184.dev3__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/leaploader.py +31 -11
- {code_loader-1.0.184.dev2.dist-info → code_loader-1.0.184.dev3.dist-info}/METADATA +1 -1
- {code_loader-1.0.184.dev2.dist-info → code_loader-1.0.184.dev3.dist-info}/RECORD +5 -5
- {code_loader-1.0.184.dev2.dist-info → code_loader-1.0.184.dev3.dist-info}/LICENSE +0 -0
- {code_loader-1.0.184.dev2.dist-info → code_loader-1.0.184.dev3.dist-info}/WHEEL +0 -0
code_loader/leaploader.py
CHANGED
|
@@ -45,6 +45,7 @@ class LeapLoader(LeapLoaderBase):
|
|
|
45
45
|
|
|
46
46
|
self._preprocess_result_cached = None
|
|
47
47
|
self._synthetic_lookup: Dict[str, Tuple[PreprocessResponse, Any]] = {}
|
|
48
|
+
self._synthetic_populator: Optional[Callable[[str], None]] = None
|
|
48
49
|
|
|
49
50
|
try:
|
|
50
51
|
from code_loader.mixpanel_tracker import track_code_loader_loaded
|
|
@@ -188,11 +189,30 @@ class LeapLoader(LeapLoaderBase):
|
|
|
188
189
|
for prediction_type in setup.prediction_types
|
|
189
190
|
}
|
|
190
191
|
|
|
192
|
+
def set_synthetic_populator(self, populator: Optional[Callable[[str], None]]) -> None:
|
|
193
|
+
# Hook called by `_resolve_synthetic` when a synthetic sample_id is requested
|
|
194
|
+
# but not yet in `_synthetic_lookup`. The populator should call `run_simulation`
|
|
195
|
+
# for the recipe that produced sample_id, or raise if the recipe can't be
|
|
196
|
+
# resolved. After the call, the entire batch the recipe produced is in
|
|
197
|
+
# `_synthetic_lookup`, so subsequent lookups for sibling sample_ids skip the hook.
|
|
198
|
+
self._synthetic_populator = populator
|
|
199
|
+
|
|
200
|
+
def _resolve_synthetic(self, sample_id: Union[int, str]) -> Optional[Tuple[PreprocessResponse, Any]]:
|
|
201
|
+
if not isinstance(sample_id, str):
|
|
202
|
+
return None
|
|
203
|
+
if sample_id in self._synthetic_lookup:
|
|
204
|
+
return self._synthetic_lookup[sample_id]
|
|
205
|
+
if self._synthetic_populator is not None:
|
|
206
|
+
self._synthetic_populator(sample_id)
|
|
207
|
+
return self._synthetic_lookup.get(sample_id)
|
|
208
|
+
return None
|
|
209
|
+
|
|
191
210
|
def get_sample(self, state: DataStateEnum, sample_id: Union[int, str], instance_id: int = None) -> DatasetSample:
|
|
192
211
|
self.exec_script()
|
|
193
212
|
|
|
194
|
-
|
|
195
|
-
|
|
213
|
+
resolved = self._resolve_synthetic(sample_id)
|
|
214
|
+
if resolved is not None:
|
|
215
|
+
sim_preprocess, original_local_id = resolved
|
|
196
216
|
return self._get_sample_from_preprocess(
|
|
197
217
|
sim_preprocess, original_local_id, synthetic_index=sample_id
|
|
198
218
|
)
|
|
@@ -674,9 +694,9 @@ class LeapLoader(LeapLoaderBase):
|
|
|
674
694
|
state: DataStateEnum, sample_id: Union[int, str]) -> Dict[str, npt.NDArray[np.float32]]:
|
|
675
695
|
result_agg = {}
|
|
676
696
|
preprocess_result = self._preprocess_result()
|
|
677
|
-
if
|
|
678
|
-
|
|
679
|
-
sim_preprocess, original_local_id =
|
|
697
|
+
resolved = self._resolve_synthetic(sample_id) if state == DataStateEnum.additional else None
|
|
698
|
+
if resolved is not None:
|
|
699
|
+
sim_preprocess, original_local_id = resolved
|
|
680
700
|
preprocess_state = sim_preprocess
|
|
681
701
|
sample_id = original_local_id
|
|
682
702
|
else:
|
|
@@ -694,9 +714,9 @@ class LeapLoader(LeapLoaderBase):
|
|
|
694
714
|
if instance_id is None:
|
|
695
715
|
return None
|
|
696
716
|
preprocess_result = self._preprocess_result()
|
|
697
|
-
if
|
|
698
|
-
|
|
699
|
-
sim_preprocess, original_local_id =
|
|
717
|
+
resolved = self._resolve_synthetic(sample_id) if state == DataStateEnum.additional else None
|
|
718
|
+
if resolved is not None:
|
|
719
|
+
sim_preprocess, original_local_id = resolved
|
|
700
720
|
preprocess_state = sim_preprocess
|
|
701
721
|
sample_id = original_local_id
|
|
702
722
|
else:
|
|
@@ -760,9 +780,9 @@ class LeapLoader(LeapLoaderBase):
|
|
|
760
780
|
result_agg = {}
|
|
761
781
|
is_none = {}
|
|
762
782
|
preprocess_result = self._preprocess_result()
|
|
763
|
-
if
|
|
764
|
-
|
|
765
|
-
sim_preprocess, original_local_id =
|
|
783
|
+
resolved = self._resolve_synthetic(sample_id) if state == DataStateEnum.additional else None
|
|
784
|
+
if resolved is not None:
|
|
785
|
+
sim_preprocess, original_local_id = resolved
|
|
766
786
|
preprocess_state = sim_preprocess
|
|
767
787
|
sample_id = original_local_id
|
|
768
788
|
else:
|
|
@@ -23,7 +23,7 @@ code_loader/experiment_api/workingspace_config_utils.py,sha256=DLzXQCg4dgTV_YgaS
|
|
|
23
23
|
code_loader/inner_leap_binder/__init__.py,sha256=koOlJyMNYzGbEsoIbXathSmQ-L38N_pEXH_HvL7beXU,99
|
|
24
24
|
code_loader/inner_leap_binder/leapbinder.py,sha256=XLYYcV50qjMvoC1S6WW0tLBch_0g5gl1UyHiVSWYbvg,40491
|
|
25
25
|
code_loader/inner_leap_binder/leapbinder_decorators.py,sha256=YlK51b5Ryo396f7tOA7Ole3vYCLs3f5ZLm2qDQ9K1NE,105781
|
|
26
|
-
code_loader/leaploader.py,sha256=
|
|
26
|
+
code_loader/leaploader.py,sha256=OuN53z2KCO-I0FRxwjB_mfyzNZizH5Ud4vrZyFNn1wc,42595
|
|
27
27
|
code_loader/leaploaderbase.py,sha256=l36qDA00GhZEG5NLKpEtAXgWJA-UQQIhNFGxywK7mUA,6530
|
|
28
28
|
code_loader/mixpanel_tracker.py,sha256=rNwRmFifNbdUoqLQvvhhgpKczWpWiEmd8MfyJe27sxw,9131
|
|
29
29
|
code_loader/plot_functions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -32,7 +32,7 @@ code_loader/plot_functions/visualize.py,sha256=gsBAYYkwMh7jIpJeDMPS8G4CW-pxwx6Lz
|
|
|
32
32
|
code_loader/utils.py,sha256=YecipkdTA-VcE9F0RQcY9cFnY8P3AksPnHM2Db7xUSk,3972
|
|
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.184.
|
|
36
|
-
code_loader-1.0.184.
|
|
37
|
-
code_loader-1.0.184.
|
|
38
|
-
code_loader-1.0.184.
|
|
35
|
+
code_loader-1.0.184.dev3.dist-info/LICENSE,sha256=qIwWjdspQeSMTtnFZBC8MuT-95L02FPvzRUdWFxrwJY,1067
|
|
36
|
+
code_loader-1.0.184.dev3.dist-info/METADATA,sha256=lH0fmNWqwyUFhJXXu8ATIV8vhwOhU7y6u6WfWS3ckfw,1095
|
|
37
|
+
code_loader-1.0.184.dev3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
38
|
+
code_loader-1.0.184.dev3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|