code-loader 1.0.193.dev3__tar.gz → 1.0.194__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.
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/PKG-INFO +1 -1
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/inner_leap_binder/leapbinder_decorators.py +36 -21
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/leaploader.py +33 -9
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/leaploaderbase.py +7 -2
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/pyproject.toml +1 -1
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/LICENSE +0 -0
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/README.md +0 -0
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/__init__.py +0 -0
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/contract/__init__.py +0 -0
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/contract/datasetclasses.py +0 -0
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/contract/enums.py +0 -0
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/contract/exceptions.py +0 -0
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/contract/mapping.py +0 -0
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/contract/responsedataclasses.py +0 -0
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/contract/sim_config.py +0 -0
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/contract/visualizer_classes.py +0 -0
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/default_losses.py +0 -0
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/default_metrics.py +0 -0
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/experiment_api/__init__.py +0 -0
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/experiment_api/api.py +0 -0
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/experiment_api/cli_config_utils.py +0 -0
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/experiment_api/client.py +0 -0
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/experiment_api/epoch.py +0 -0
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/experiment_api/experiment.py +0 -0
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/experiment_api/experiment_context.py +0 -0
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/experiment_api/types.py +0 -0
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/experiment_api/utils.py +0 -0
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/experiment_api/workingspace_config_utils.py +0 -0
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/inner_leap_binder/__init__.py +0 -0
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/inner_leap_binder/leapbinder.py +0 -0
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/mixpanel_tracker.py +0 -0
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/plot_functions/__init__.py +0 -0
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/plot_functions/plot_functions.py +0 -0
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/plot_functions/visualize.py +0 -0
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/utils.py +0 -0
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/visualizers/__init__.py +0 -0
- {code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/visualizers/default_visualizers.py +0 -0
|
@@ -299,8 +299,19 @@ def tensorleap_integration_test():
|
|
|
299
299
|
def inner(*args, **kwargs):
|
|
300
300
|
if not _call_from_tl_platform:
|
|
301
301
|
set_current('tensorleap_integration_test')
|
|
302
|
+
# Keyword calls must work with the user function's OWN parameter names — the local
|
|
303
|
+
# run template calls integration_test(sample_id=..., preprocess=...) against a
|
|
304
|
+
# signature the user chose, not the canonical placeholder names.
|
|
305
|
+
expected_names = inspect.getfullargspec(integration_test_function)[0][:2]
|
|
306
|
+
if len(expected_names) < 2:
|
|
307
|
+
expected_names = ['idx', 'preprocess']
|
|
302
308
|
validate_args_structure(*args, types_order=[Union[int, str], PreprocessResponse],
|
|
303
|
-
func_name='integration_test', expected_names=
|
|
309
|
+
func_name='integration_test', expected_names=expected_names,
|
|
310
|
+
**kwargs)
|
|
311
|
+
sample_id, preprocess_response = (
|
|
312
|
+
args[i] if i < len(args) else kwargs[name]
|
|
313
|
+
for i, name in enumerate(expected_names))
|
|
314
|
+
args, kwargs = (sample_id, preprocess_response), {}
|
|
304
315
|
_validate_input_args(*args, **kwargs)
|
|
305
316
|
|
|
306
317
|
global _called_from_inside_tl_integration_test_decorator, _integration_test_started
|
|
@@ -433,7 +444,7 @@ def tensorleap_load_model(prediction_types: Optional[List[PredictionTypeHandler]
|
|
|
433
444
|
pass
|
|
434
445
|
|
|
435
446
|
@lru_cache()
|
|
436
|
-
def
|
|
447
|
+
def _cached_inner(*args, **kwargs):
|
|
437
448
|
if not _call_from_tl_platform:
|
|
438
449
|
set_current('tensorleap_load_model')
|
|
439
450
|
validate_args_structure(*args, types_order=[],
|
|
@@ -587,12 +598,20 @@ def tensorleap_load_model(prediction_types: Optional[List[PredictionTypeHandler]
|
|
|
587
598
|
return self.model.get_inputs()
|
|
588
599
|
|
|
589
600
|
model_placeholder = ModelPlaceholder(prediction_types)
|
|
590
|
-
global _last_loaded_model
|
|
591
|
-
_last_loaded_model = model_placeholder
|
|
592
601
|
if not _call_from_tl_platform:
|
|
593
602
|
update_env_params_func("tensorleap_load_model", "v")
|
|
594
603
|
return model_placeholder
|
|
595
604
|
|
|
605
|
+
def inner(*args, **kwargs):
|
|
606
|
+
model_placeholder = _cached_inner(*args, **kwargs)
|
|
607
|
+
# Re-assert on every call, outside the cache: each mapping rerun's load_model
|
|
608
|
+
# overwrites this global with its mapping placeholder, and on a cache hit the
|
|
609
|
+
# body above never runs — a second integration test would otherwise fail the
|
|
610
|
+
# model loop's identity check against the stale mapping placeholder.
|
|
611
|
+
global _last_loaded_model
|
|
612
|
+
_last_loaded_model = model_placeholder
|
|
613
|
+
return model_placeholder
|
|
614
|
+
|
|
596
615
|
def mapping_inner():
|
|
597
616
|
class ModelOutputPlaceholder:
|
|
598
617
|
def __init__(self):
|
|
@@ -1711,6 +1730,8 @@ def _ndarray_leaves(value):
|
|
|
1711
1730
|
|
|
1712
1731
|
|
|
1713
1732
|
def _squeeze_leading_batch_axis(tensors_dict):
|
|
1733
|
+
if tensors_dict is None:
|
|
1734
|
+
return None
|
|
1714
1735
|
squeezed = {}
|
|
1715
1736
|
for key, value in tensors_dict.items():
|
|
1716
1737
|
if isinstance(value, np.ndarray) and value.ndim > 0 and value.shape[0] == 1:
|
|
@@ -2058,21 +2079,6 @@ def tensorleap_autoregressive_step(latent_space_aggregation: str = 'last_step'):
|
|
|
2058
2079
|
assert _nest_equal(value, second_inputs[key]), error_message
|
|
2059
2080
|
assert _nest_equal(first_state, second_state), error_message
|
|
2060
2081
|
|
|
2061
|
-
def _squeeze_test_batch_dim(tensors_dict):
|
|
2062
|
-
# Inside the integration test the model works on batch-1 tensors (this wrapper adds the
|
|
2063
|
-
# batch axis to returned inputs, and model outputs come back batched). The user's hook
|
|
2064
|
-
# body must see the same unbatched per-sample tensors it will see at engine runtime, so
|
|
2065
|
-
# strip the leading batch-1 axis before calling it.
|
|
2066
|
-
if tensors_dict is None:
|
|
2067
|
-
return None
|
|
2068
|
-
squeezed = {}
|
|
2069
|
-
for key, value in tensors_dict.items():
|
|
2070
|
-
if isinstance(value, np.ndarray) and value.ndim > 0 and value.shape[0] == 1:
|
|
2071
|
-
squeezed[key] = value[0]
|
|
2072
|
-
else:
|
|
2073
|
-
squeezed[key] = value
|
|
2074
|
-
return squeezed
|
|
2075
|
-
|
|
2076
2082
|
def inner_without_validate(sample_id, prev_inputs, prev_outputs, state, preprocess_response):
|
|
2077
2083
|
global _called_from_inside_tl_decorator
|
|
2078
2084
|
_called_from_inside_tl_decorator += 1
|
|
@@ -2110,8 +2116,11 @@ def tensorleap_autoregressive_step(latent_space_aggregation: str = 'last_step'):
|
|
|
2110
2116
|
loop_context.on_hook_call(sample_id, prev_inputs, prev_outputs, state,
|
|
2111
2117
|
preprocess_response)
|
|
2112
2118
|
if is_top_level_in_test:
|
|
2113
|
-
|
|
2114
|
-
|
|
2119
|
+
# The wrapper adds the batch axis to returned inputs and model outputs come back
|
|
2120
|
+
# batched; the hook body must see the same unbatched per-sample tensors it will
|
|
2121
|
+
# see at engine runtime.
|
|
2122
|
+
prev_inputs = _squeeze_leading_batch_axis(prev_inputs)
|
|
2123
|
+
prev_outputs = _squeeze_leading_batch_axis(prev_outputs)
|
|
2115
2124
|
|
|
2116
2125
|
_validate_input_args(sample_id, prev_inputs, prev_outputs, state, preprocess_response)
|
|
2117
2126
|
|
|
@@ -3376,6 +3385,12 @@ def tensorleap_status_table():
|
|
|
3376
3385
|
if not started_from("leap_integration.py"):
|
|
3377
3386
|
return
|
|
3378
3387
|
|
|
3388
|
+
if leap_binder.setup_container.autoregressive_step is not None:
|
|
3389
|
+
# Input encoders are forbidden in autoregressive integrations — the step hook is
|
|
3390
|
+
# the sole source of model inputs — so the row is not applicable: it must not be
|
|
3391
|
+
# printed, gate readiness, or be recommended as a next step.
|
|
3392
|
+
table[:] = [row for row in table if row["name"] != "tensorleap_input_encoder"]
|
|
3393
|
+
|
|
3379
3394
|
ready_mess = "\nAll parts have been successfully set. If no errors accured, you can now push the project to the Tensorleap system."
|
|
3380
3395
|
not_ready_mess = "\nSome mandatory components have not yet been added to the Integration test. Recommended next interface to add is: "
|
|
3381
3396
|
mandatory_ready_mess = "\nAll mandatory parts have been successfully set. If no errors accured, you can now push the project to the Tensorleap system or continue to the next optional reccomeded interface,adding: "
|
|
@@ -581,8 +581,8 @@ class LeapLoader(LeapLoaderBase):
|
|
|
581
581
|
return handler.input_shapes
|
|
582
582
|
|
|
583
583
|
def run_simulation(self, sim_name, params=None, n_samples=1, seed=0,
|
|
584
|
-
sample_ids=None, extend_preprocess=True):
|
|
585
|
-
# type: (str, Optional[Dict[str, Any]], int, int, Optional[List[str]], bool) -> Dict[str, Any]
|
|
584
|
+
sample_ids=None, extend_preprocess=True, allow_partial=False):
|
|
585
|
+
# type: (str, Optional[Dict[str, Any]], int, int, Optional[List[str]], bool, bool) -> Dict[str, Any]
|
|
586
586
|
# extend_preprocess=True (default): also extend preprocess_result[additional] with the
|
|
587
587
|
# new synthetic sample_ids (producer-side behavior — synthetic worker needs this for
|
|
588
588
|
# enumeration / data_length tracking). Pass False from consumer-side populators that
|
|
@@ -609,19 +609,30 @@ class LeapLoader(LeapLoaderBase):
|
|
|
609
609
|
for sample_id in original_sample_ids:
|
|
610
610
|
for handler in global_leap_binder.setup_container.inputs:
|
|
611
611
|
per_encoder[handler.name].append(handler.function(sample_id, sim_preprocess))
|
|
612
|
-
encoded = {
|
|
612
|
+
encoded = {
|
|
613
|
+
name: np.stack(arrays) if arrays else np.empty((0,), dtype=np.float32)
|
|
614
|
+
for name, arrays in per_encoder.items()
|
|
615
|
+
}
|
|
613
616
|
if sample_ids is not None:
|
|
614
|
-
if len(sample_ids) != len(original_sample_ids):
|
|
615
|
-
raise ValueError(
|
|
616
|
-
"sample_ids length ({}) does not match simulation output length ({})".format(
|
|
617
|
-
len(sample_ids), len(original_sample_ids)
|
|
618
|
-
)
|
|
619
|
-
)
|
|
620
617
|
for sid in sample_ids:
|
|
621
618
|
if not isinstance(sid, str):
|
|
622
619
|
raise TypeError(
|
|
623
620
|
"All sample_ids must be of type str. Got: {}".format(type(sid))
|
|
624
621
|
)
|
|
622
|
+
if len(sample_ids) != len(original_sample_ids):
|
|
623
|
+
if not allow_partial:
|
|
624
|
+
raise ValueError(
|
|
625
|
+
"sample_ids length ({}) does not match simulation output length ({})".format(
|
|
626
|
+
len(sample_ids), len(original_sample_ids)
|
|
627
|
+
)
|
|
628
|
+
)
|
|
629
|
+
n_bound = min(len(sample_ids), len(original_sample_ids))
|
|
630
|
+
sample_ids = list(sample_ids)[:n_bound]
|
|
631
|
+
original_sample_ids = original_sample_ids[:n_bound]
|
|
632
|
+
# Over-generation trims sample_ids/original_sample_ids above but encoded was
|
|
633
|
+
# stacked from the full simulation output; slice it too so the encoded batch dim
|
|
634
|
+
# stays 1:1 with the returned sample_ids.
|
|
635
|
+
encoded = {name: arr[:n_bound] for name, arr in encoded.items()}
|
|
625
636
|
for synth_id, original_local_id in zip(sample_ids, original_sample_ids):
|
|
626
637
|
self._synthetic_lookup[synth_id] = (sim_preprocess, original_local_id)
|
|
627
638
|
if extend_preprocess:
|
|
@@ -631,6 +642,19 @@ class LeapLoader(LeapLoaderBase):
|
|
|
631
642
|
returned_sample_ids = original_sample_ids
|
|
632
643
|
return {"encoded": encoded, "sample_ids": returned_sample_ids}
|
|
633
644
|
|
|
645
|
+
def prune_synthetic_lookup(self, keep_ids):
|
|
646
|
+
# type: (List[str]) -> None
|
|
647
|
+
# Keep only the given synthetic sample_ids in the in-memory lookup and
|
|
648
|
+
# drop the rest, so preprocess responses don't accumulate across many
|
|
649
|
+
# run_simulation calls (e.g. a synthetic calibration loop keeps only its
|
|
650
|
+
# running top-K trials). Keep-set semantics (rather than evict-list) so
|
|
651
|
+
# the caller can bound the lookup to a known-good set each iteration
|
|
652
|
+
# without tracking everything it ever generated.
|
|
653
|
+
keep = set(keep_ids)
|
|
654
|
+
self._synthetic_lookup = {
|
|
655
|
+
sid: entry for sid, entry in self._synthetic_lookup.items() if sid in keep
|
|
656
|
+
}
|
|
657
|
+
|
|
634
658
|
def _extend_additional_preprocess(self, new_sample_ids: List[str]) -> None:
|
|
635
659
|
if self._preprocess_result_cached is None:
|
|
636
660
|
self._preprocess_result()
|
|
@@ -223,8 +223,13 @@ class LeapLoaderBase:
|
|
|
223
223
|
pass
|
|
224
224
|
|
|
225
225
|
@abstractmethod
|
|
226
|
-
def run_simulation(self, sim_name, params=None, n_samples=1, seed=0, sample_ids=None
|
|
227
|
-
|
|
226
|
+
def run_simulation(self, sim_name, params=None, n_samples=1, seed=0, sample_ids=None,
|
|
227
|
+
extend_preprocess=True, allow_partial=False):
|
|
228
|
+
# type: (str, Optional[Dict[str, Any]], int, int, Optional[List[str]], bool, bool) -> Dict[str, Any]
|
|
229
|
+
pass
|
|
230
|
+
|
|
231
|
+
def prune_synthetic_lookup(self, keep_ids):
|
|
232
|
+
# type: (List[str]) -> None
|
|
228
233
|
pass
|
|
229
234
|
|
|
230
235
|
def is_custom_latent_space(self) -> bool:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/contract/responsedataclasses.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/experiment_api/cli_config_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/experiment_api/experiment_context.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/inner_leap_binder/leapbinder.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/plot_functions/plot_functions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_loader-1.0.193.dev3 → code_loader-1.0.194}/code_loader/visualizers/default_visualizers.py
RENAMED
|
File without changes
|