code-loader 1.0.174.dev4__tar.gz → 1.0.175.dev1__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.174.dev4 → code_loader-1.0.175.dev1}/PKG-INFO +3 -3
- {code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/contract/datasetclasses.py +0 -7
- {code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/contract/responsedataclasses.py +1 -0
- {code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/inner_leap_binder/leapbinder.py +45 -44
- {code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/inner_leap_binder/leapbinder_decorators.py +0 -209
- {code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/leaploader.py +1 -0
- {code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/pyproject.toml +1 -1
- {code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/LICENSE +0 -0
- {code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/README.md +0 -0
- {code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/__init__.py +0 -0
- {code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/contract/__init__.py +0 -0
- {code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/contract/enums.py +0 -0
- {code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/contract/exceptions.py +0 -0
- {code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/contract/mapping.py +0 -0
- {code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/contract/visualizer_classes.py +0 -0
- {code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/default_losses.py +0 -0
- {code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/default_metrics.py +0 -0
- {code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/experiment_api/__init__.py +0 -0
- {code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/experiment_api/api.py +0 -0
- {code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/experiment_api/cli_config_utils.py +0 -0
- {code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/experiment_api/client.py +0 -0
- {code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/experiment_api/epoch.py +0 -0
- {code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/experiment_api/experiment.py +0 -0
- {code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/experiment_api/experiment_context.py +0 -0
- {code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/experiment_api/types.py +0 -0
- {code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/experiment_api/utils.py +0 -0
- {code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/experiment_api/workingspace_config_utils.py +0 -0
- {code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/inner_leap_binder/__init__.py +0 -0
- {code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/leaploaderbase.py +0 -0
- {code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/mixpanel_tracker.py +0 -0
- {code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/plot_functions/__init__.py +0 -0
- {code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/plot_functions/plot_functions.py +0 -0
- {code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/plot_functions/visualize.py +0 -0
- {code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/utils.py +0 -0
- {code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/visualizers/__init__.py +0 -0
- {code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/visualizers/default_visualizers.py +0 -0
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: code-loader
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.175.dev1
|
|
4
4
|
Summary:
|
|
5
|
-
Home-page: https://github.com/tensorleap/code-loader
|
|
6
5
|
License: MIT
|
|
7
6
|
Author: dorhar
|
|
8
7
|
Author-email: doron.harnoy@tensorleap.ai
|
|
@@ -20,6 +19,7 @@ Requires-Dist: numpy (>=2.3.2,<3.0.0) ; python_version >= "3.11" and python_vers
|
|
|
20
19
|
Requires-Dist: psutil (>=5.9.5,<6.0.0)
|
|
21
20
|
Requires-Dist: pyyaml (>=6.0.2,<7.0.0)
|
|
22
21
|
Requires-Dist: requests (>=2.32.3,<3.0.0)
|
|
22
|
+
Project-URL: Homepage, https://github.com/tensorleap/code-loader
|
|
23
23
|
Project-URL: Repository, https://github.com/tensorleap/code-loader
|
|
24
24
|
Description-Content-Type: text/markdown
|
|
25
25
|
|
{code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/contract/datasetclasses.py
RENAMED
|
@@ -171,12 +171,6 @@ class MetricHandler:
|
|
|
171
171
|
function: Union[CustomCallableInterfaceMultiArgs, ConfusionMatrixCallableInterfaceMultiArgs]
|
|
172
172
|
|
|
173
173
|
|
|
174
|
-
@dataclass
|
|
175
|
-
class InstanceMetricHandler:
|
|
176
|
-
metric_handler_data: MetricHandlerData
|
|
177
|
-
function: CustomMultipleReturnCallableInterfaceMultiArgs
|
|
178
|
-
|
|
179
|
-
|
|
180
174
|
@dataclass
|
|
181
175
|
class RawInputsForHeatmap:
|
|
182
176
|
raw_input_by_vizualizer_arg_name: Dict[str, npt.NDArray[np.float32]]
|
|
@@ -264,7 +258,6 @@ class DatasetIntegrationSetup:
|
|
|
264
258
|
prediction_types: List[PredictionTypeHandler] = field(default_factory=list)
|
|
265
259
|
custom_loss_handlers: List[CustomLossHandler] = field(default_factory=list)
|
|
266
260
|
metrics: List[MetricHandler] = field(default_factory=list)
|
|
267
|
-
instance_metrics: List[InstanceMetricHandler] = field(default_factory=list)
|
|
268
261
|
custom_layers: Dict[str, CustomLayerHandler] = field(default_factory=dict)
|
|
269
262
|
custom_latent_space: Optional[CustomLatentSpaceHandler] = None
|
|
270
263
|
|
{code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/contract/responsedataclasses.py
RENAMED
|
@@ -128,6 +128,7 @@ class LeapAnalysisConfiguration:
|
|
|
128
128
|
domain_gap_metadata: Optional[List[str]] = None
|
|
129
129
|
feature_flags: Optional[List[str]] = None
|
|
130
130
|
deterministic_results: Optional[bool] = None # if true, results will be deterministic but will increase memory usage and runtime
|
|
131
|
+
ignore_latent_spaces: Optional[List[str]] = None # names of latent spaces to skip during extraction; see LeapBinder.check for validation rules
|
|
131
132
|
|
|
132
133
|
|
|
133
134
|
@dataclass
|
{code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/inner_leap_binder/leapbinder.py
RENAMED
|
@@ -12,7 +12,7 @@ from code_loader.contract.datasetclasses import SectionCallableInterface, InputH
|
|
|
12
12
|
CustomCallableInterfaceMultiArgs, ConfusionMatrixCallableInterfaceMultiArgs, LeapData, \
|
|
13
13
|
CustomMultipleReturnCallableInterfaceMultiArgs, DatasetBaseHandler, custom_latent_space_attribute, \
|
|
14
14
|
RawInputsForHeatmap, VisualizerHandlerData, MetricHandlerData, CustomLossHandlerData, SamplePreprocessResponse, \
|
|
15
|
-
ElementInstanceMasksHandler, InstanceCallableInterface, CustomLatentSpaceHandler
|
|
15
|
+
ElementInstanceMasksHandler, InstanceCallableInterface, CustomLatentSpaceHandler
|
|
16
16
|
from code_loader.contract.enums import LeapDataType, DataStateEnum, DataStateType, MetricDirection, DatasetMetadataType
|
|
17
17
|
from code_loader.contract.mapping import NodeConnection, NodeMapping, NodeMappingType
|
|
18
18
|
from code_loader.contract.responsedataclasses import DatasetTestResultPayload, LeapAnalysisConfiguration
|
|
@@ -335,49 +335,6 @@ class LeapBinder:
|
|
|
335
335
|
metric_handler_data = MetricHandlerData(name, regular_arg_names, direction, compute_insights)
|
|
336
336
|
self.setup_container.metrics.append(MetricHandler(metric_handler_data, function))
|
|
337
337
|
|
|
338
|
-
def add_custom_instance_metric(self,
|
|
339
|
-
function: Union[CustomCallableInterfaceMultiArgs,
|
|
340
|
-
CustomMultipleReturnCallableInterfaceMultiArgs,
|
|
341
|
-
ConfusionMatrixCallableInterfaceMultiArgs],
|
|
342
|
-
name: str,
|
|
343
|
-
direction: Optional[
|
|
344
|
-
Union[MetricDirection, Dict[str, MetricDirection]]] = MetricDirection.Downward,
|
|
345
|
-
compute_insights: Optional[Union[bool, Dict[str, bool]]] = None) -> None:
|
|
346
|
-
"""
|
|
347
|
-
Add a custom metric to the setup.
|
|
348
|
-
|
|
349
|
-
Args:
|
|
350
|
-
function (Union[CustomCallableInterfaceMultiArgs, CustomMultipleReturnCallableInterfaceMultiArgs, ConfusionMatrixCallableInterfaceMultiArgs]): The custom metric function.
|
|
351
|
-
name (str): The name of the custom metric.
|
|
352
|
-
direction (Optional[Union[MetricDirection, Dict[str, MetricDirection]]]): The direction of the metric, either
|
|
353
|
-
MetricDirection.Upward or MetricDirection.Downward, in case custom metric return a dictionary of metrics we can
|
|
354
|
-
supply a dictionary of directions correspondingly.
|
|
355
|
-
- MetricDirection.Upward: Indicates that higher values of the metric are better and should be maximized.
|
|
356
|
-
- MetricDirection.Downward: Indicates that lower values of the metric are better and should be minimized.
|
|
357
|
-
compute_insights (Union[bool, Dict[str, bool]]): Whether to compute insights or not. in case custom metric
|
|
358
|
-
return a dictionary of metrics we can supply a dictionary of values correspondingly
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
Example:
|
|
363
|
-
def custom_metric_function(y_true, y_pred):
|
|
364
|
-
return np.mean(np.abs(y_true - y_pred))
|
|
365
|
-
|
|
366
|
-
leap_binder.add_custom_metric(custom_metric_function, name='custom_metric', direction=MetricDirection.Downward)
|
|
367
|
-
"""
|
|
368
|
-
|
|
369
|
-
regular_arg_names = inspect.getfullargspec(function)[0]
|
|
370
|
-
preprocess_response_arg_name = None
|
|
371
|
-
for arg_name, arg_type in inspect.getfullargspec(function).annotations.items():
|
|
372
|
-
if arg_type == SamplePreprocessResponse:
|
|
373
|
-
if preprocess_response_arg_name is not None:
|
|
374
|
-
raise Exception("only one argument can be of type SamplePreprocessResponse")
|
|
375
|
-
preprocess_response_arg_name = arg_name
|
|
376
|
-
regular_arg_names.remove(arg_name)
|
|
377
|
-
|
|
378
|
-
metric_handler_data = MetricHandlerData(name, regular_arg_names, direction, compute_insights)
|
|
379
|
-
self.setup_container.instance_metrics.append(InstanceMetricHandler(metric_handler_data, function))
|
|
380
|
-
|
|
381
338
|
def add_prediction(self, name: str, labels: List[str], channel_dim: int = -1, prediction_index: Optional[int]=None) -> None:
|
|
382
339
|
"""
|
|
383
340
|
Add prediction labels to the setup.
|
|
@@ -659,7 +616,51 @@ class LeapBinder:
|
|
|
659
616
|
preprocess_result = self.get_preprocess_result()
|
|
660
617
|
self.check_preprocess(preprocess_result)
|
|
661
618
|
self.check_handlers(preprocess_result)
|
|
619
|
+
self.validate_ignore_latent_spaces()
|
|
662
620
|
print("Successful!")
|
|
663
621
|
|
|
622
|
+
def validate_ignore_latent_spaces(self) -> None:
|
|
623
|
+
"""Validate leap_analysis_configuration.ignore_latent_spaces against this binder.
|
|
624
|
+
|
|
625
|
+
Each entry must be one of:
|
|
626
|
+
- "foreground" (the friendly name for the max-pooled default LS)
|
|
627
|
+
- An input name registered via set_input(name=...)
|
|
628
|
+
- A prediction name registered via add_prediction(name=...)
|
|
629
|
+
|
|
630
|
+
Forbidden tokens (raise with a clear message):
|
|
631
|
+
- "balanced" — the friendly name for the universal fallback default
|
|
632
|
+
LS; cannot be disabled.
|
|
633
|
+
- "user_custom" — populated by set_custom_latent_space; if the user
|
|
634
|
+
registered a custom LS they should use it, not ignore it.
|
|
635
|
+
|
|
636
|
+
Order-independent: this runs after all set_input / add_prediction calls
|
|
637
|
+
because it consults setup_container.inputs and prediction_types.
|
|
638
|
+
"""
|
|
639
|
+
if not self.leap_analysis_configuration:
|
|
640
|
+
return
|
|
641
|
+
names = self.leap_analysis_configuration.ignore_latent_spaces
|
|
642
|
+
if not names:
|
|
643
|
+
return
|
|
644
|
+
|
|
645
|
+
forbidden = {"balanced", "user_custom"}
|
|
646
|
+
input_names = {h.name for h in self.setup_container.inputs}
|
|
647
|
+
prediction_names = {h.name for h in self.setup_container.prediction_types}
|
|
648
|
+
allowed_tokens = {"foreground"} | input_names | prediction_names
|
|
649
|
+
|
|
650
|
+
for name in names:
|
|
651
|
+
if name in forbidden:
|
|
652
|
+
raise Exception(
|
|
653
|
+
f"Latent space '{name}' cannot be ignored. "
|
|
654
|
+
f"'balanced' is the universal fallback default LS and 'user_custom' is "
|
|
655
|
+
f"reserved for set_custom_latent_space."
|
|
656
|
+
)
|
|
657
|
+
if name not in allowed_tokens:
|
|
658
|
+
raise Exception(
|
|
659
|
+
f"Latent space name '{name}' in ignore_latent_spaces did not match "
|
|
660
|
+
f"any registered input or prediction. Available names: "
|
|
661
|
+
f"inputs={sorted(input_names)}, predictions={sorted(prediction_names)}, "
|
|
662
|
+
f"tokens=['foreground']."
|
|
663
|
+
)
|
|
664
|
+
|
|
664
665
|
def set_batch_size_to_validate(self, batch_size: int) -> None:
|
|
665
666
|
self.batch_size_to_validate = batch_size
|
|
@@ -877,215 +877,6 @@ def tensorleap_custom_metric(name: str,
|
|
|
877
877
|
return decorating_function
|
|
878
878
|
|
|
879
879
|
|
|
880
|
-
def tensorleap_custom_instances_metric(name: str,
|
|
881
|
-
direction: Union[MetricDirection, Dict[str, MetricDirection]] = _UNSET,
|
|
882
|
-
compute_insights: Optional[Union[bool, Dict[str, bool]]] = None,
|
|
883
|
-
connects_to=None):
|
|
884
|
-
name_to_unique_name = defaultdict(set)
|
|
885
|
-
|
|
886
|
-
def decorating_function(
|
|
887
|
-
user_function: CustomMultipleReturnCallableInterfaceMultiArgs):
|
|
888
|
-
nonlocal direction
|
|
889
|
-
|
|
890
|
-
direction_was_provided = direction is not _UNSET
|
|
891
|
-
|
|
892
|
-
def _validate_decorators_signature():
|
|
893
|
-
err_message = f"{user_function.__name__} validation failed.\n"
|
|
894
|
-
if not isinstance(name, str):
|
|
895
|
-
raise TypeError(err_message + f"`name` must be a string, got type {type(name).__name__}.")
|
|
896
|
-
valid_directions = {MetricDirection.Upward, MetricDirection.Downward}
|
|
897
|
-
if direction is _UNSET:
|
|
898
|
-
pass
|
|
899
|
-
elif isinstance(direction, MetricDirection):
|
|
900
|
-
if direction not in valid_directions:
|
|
901
|
-
raise ValueError(
|
|
902
|
-
err_message +
|
|
903
|
-
f"Invalid MetricDirection: {direction}. Must be one of {valid_directions}, "
|
|
904
|
-
f"got type {type(direction).__name__}."
|
|
905
|
-
)
|
|
906
|
-
elif isinstance(direction, dict):
|
|
907
|
-
if not all(isinstance(k, str) for k in direction.keys()):
|
|
908
|
-
invalid_keys = {k: type(k).__name__ for k in direction.keys() if not isinstance(k, str)}
|
|
909
|
-
raise TypeError(
|
|
910
|
-
err_message +
|
|
911
|
-
f"All keys in `direction` must be strings, got invalid key types: {invalid_keys}."
|
|
912
|
-
)
|
|
913
|
-
for k, v in direction.items():
|
|
914
|
-
if v not in valid_directions:
|
|
915
|
-
raise ValueError(
|
|
916
|
-
err_message +
|
|
917
|
-
f"Invalid direction for key '{k}': {v}. Must be one of {valid_directions}, "
|
|
918
|
-
f"got type {type(v).__name__}."
|
|
919
|
-
)
|
|
920
|
-
else:
|
|
921
|
-
raise TypeError(
|
|
922
|
-
err_message +
|
|
923
|
-
f"`direction` must be a MetricDirection or a Dict[str, MetricDirection], "
|
|
924
|
-
f"got type {type(direction).__name__}."
|
|
925
|
-
)
|
|
926
|
-
if compute_insights is not None:
|
|
927
|
-
if not isinstance(compute_insights, (bool, dict)):
|
|
928
|
-
raise TypeError(
|
|
929
|
-
err_message +
|
|
930
|
-
f"`compute_insights` must be a bool or a Dict[str, bool], "
|
|
931
|
-
f"got type {type(compute_insights).__name__}."
|
|
932
|
-
)
|
|
933
|
-
if isinstance(compute_insights, dict):
|
|
934
|
-
if not all(isinstance(k, str) for k in compute_insights.keys()):
|
|
935
|
-
invalid_keys = {k: type(k).__name__ for k in compute_insights.keys() if not isinstance(k, str)}
|
|
936
|
-
raise TypeError(
|
|
937
|
-
err_message +
|
|
938
|
-
f"All keys in `compute_insights` must be strings, got invalid key types: {invalid_keys}."
|
|
939
|
-
)
|
|
940
|
-
for k, v in compute_insights.items():
|
|
941
|
-
if not isinstance(v, bool):
|
|
942
|
-
raise TypeError(
|
|
943
|
-
err_message +
|
|
944
|
-
f"Invalid type for compute_insights['{k}']: expected bool, got type {type(v).__name__}."
|
|
945
|
-
)
|
|
946
|
-
if connects_to is not None:
|
|
947
|
-
valid_types = (str, list, tuple, set)
|
|
948
|
-
if not isinstance(connects_to, valid_types):
|
|
949
|
-
raise TypeError(
|
|
950
|
-
err_message +
|
|
951
|
-
f"`connects_to` must be one of {valid_types}, got type {type(connects_to).__name__}."
|
|
952
|
-
)
|
|
953
|
-
if isinstance(connects_to, (list, tuple, set)):
|
|
954
|
-
invalid_elems = [f"{type(e).__name__}" for e in connects_to if not isinstance(e, str)]
|
|
955
|
-
if invalid_elems:
|
|
956
|
-
raise TypeError(
|
|
957
|
-
err_message +
|
|
958
|
-
f"All elements in `connects_to` must be strings, "
|
|
959
|
-
f"but found element types: {invalid_elems}."
|
|
960
|
-
)
|
|
961
|
-
|
|
962
|
-
_validate_decorators_signature()
|
|
963
|
-
|
|
964
|
-
for metric_handler in leap_binder.setup_container.instance_metrics:
|
|
965
|
-
if metric_handler.metric_handler_data.name == name:
|
|
966
|
-
raise Exception(f'Metric with name {name} already exists. '
|
|
967
|
-
f'Please choose another')
|
|
968
|
-
|
|
969
|
-
def _validate_input_args(*args, **kwargs) -> None:
|
|
970
|
-
assert len(args) + len(kwargs) > 0, (
|
|
971
|
-
f"{user_function.__name__}() validation failed: "
|
|
972
|
-
f"Expected at least one positional|key-word argument of type np.ndarray, "
|
|
973
|
-
f"but received none. "
|
|
974
|
-
f"Correct usage example: tensorleap_custom_metric(input_array: np.ndarray, ...)"
|
|
975
|
-
)
|
|
976
|
-
for i, arg in enumerate(args):
|
|
977
|
-
assert isinstance(arg, (np.ndarray, SamplePreprocessResponse)), (
|
|
978
|
-
f'{user_function.__name__}() validation failed: '
|
|
979
|
-
f'Argument #{i} should be a numpy array. Got {type(arg)}.')
|
|
980
|
-
if leap_binder.batch_size_to_validate and isinstance(arg, np.ndarray):
|
|
981
|
-
assert arg.shape[0] == leap_binder.batch_size_to_validate, \
|
|
982
|
-
(f'{user_function.__name__}() validation failed: Argument #{i} '
|
|
983
|
-
f'first dim should be as the batch size. Got {arg.shape[0]} '
|
|
984
|
-
f'instead of {leap_binder.batch_size_to_validate}')
|
|
985
|
-
|
|
986
|
-
for _arg_name, arg in kwargs.items():
|
|
987
|
-
assert isinstance(arg, (np.ndarray, SamplePreprocessResponse)), (
|
|
988
|
-
f'{user_function.__name__}() validation failed: '
|
|
989
|
-
f'Argument {_arg_name} should be a numpy array. Got {type(arg)}.')
|
|
990
|
-
if leap_binder.batch_size_to_validate and isinstance(arg, np.ndarray):
|
|
991
|
-
assert arg.shape[0] == leap_binder.batch_size_to_validate, \
|
|
992
|
-
(f'{user_function.__name__}() validation failed: Argument {_arg_name} '
|
|
993
|
-
f'first dim should be as the batch size. Got {arg.shape[0]} '
|
|
994
|
-
f'instead of {leap_binder.batch_size_to_validate}')
|
|
995
|
-
|
|
996
|
-
def _validate_result(result) -> None:
|
|
997
|
-
nonlocal direction
|
|
998
|
-
supported_types_message = (f'{user_function.__name__}() validation failed: '
|
|
999
|
-
f'{user_function.__name__}() has returned unsupported type.\nSupported type is Dict[List[NDArray[np.float32]]]')
|
|
1000
|
-
|
|
1001
|
-
def _validate_single_metric(single_metric_result, key=None):
|
|
1002
|
-
assert isinstance(single_metric_result,
|
|
1003
|
-
np.ndarray), f'{supported_types_message}\nGot {type(single_metric_result)}.'
|
|
1004
|
-
assert len(single_metric_result.shape) == 1, (f'{user_function.__name__}() validation failed: '
|
|
1005
|
-
f'The return shape should be 1D. Got {len(single_metric_result.shape)}D.')
|
|
1006
|
-
|
|
1007
|
-
if leap_binder.batch_size_to_validate:
|
|
1008
|
-
assert len(single_metric_result) == leap_binder.batch_size_to_validate, \
|
|
1009
|
-
f'{user_function.__name__}() validation failed: The return len {f"of srt{key} value" if key is not None else ""} should be as the batch size.'
|
|
1010
|
-
|
|
1011
|
-
assert isinstance(result, dict), f'{supported_types_message}\nGot {type(result)}.'
|
|
1012
|
-
|
|
1013
|
-
result_keys = set(result.keys())
|
|
1014
|
-
for key, value in result.items():
|
|
1015
|
-
_validate_single_metric(value, key)
|
|
1016
|
-
|
|
1017
|
-
assert isinstance(key, int), \
|
|
1018
|
-
(f'{user_function.__name__}() validation failed: '
|
|
1019
|
-
f'Keys in the return dict should be of type int (instance number). Got {type(key)}.')
|
|
1020
|
-
|
|
1021
|
-
leap_binder.setup_container.instance_metrics[-1].metric_handler_data.direction = direction
|
|
1022
|
-
|
|
1023
|
-
@functools.wraps(user_function)
|
|
1024
|
-
def inner_without_validate(*args, **kwargs):
|
|
1025
|
-
global _called_from_inside_tl_decorator
|
|
1026
|
-
_called_from_inside_tl_decorator += 1
|
|
1027
|
-
|
|
1028
|
-
try:
|
|
1029
|
-
result = user_function(*args, **kwargs)
|
|
1030
|
-
finally:
|
|
1031
|
-
_called_from_inside_tl_decorator -= 1
|
|
1032
|
-
|
|
1033
|
-
return result
|
|
1034
|
-
|
|
1035
|
-
try:
|
|
1036
|
-
inner_without_validate.__signature__ = inspect.signature(user_function)
|
|
1037
|
-
except (TypeError, ValueError):
|
|
1038
|
-
pass
|
|
1039
|
-
|
|
1040
|
-
leap_binder.add_custom_instance_metric(inner_without_validate, name, direction, compute_insights)
|
|
1041
|
-
|
|
1042
|
-
if connects_to is not None:
|
|
1043
|
-
arg_names = leap_binder.setup_container.metrics[-1].metric_handler_data.arg_names
|
|
1044
|
-
_add_mapping_connections(connects_to, arg_names, NodeMappingType.Metric, name)
|
|
1045
|
-
|
|
1046
|
-
def inner(*args, **kwargs):
|
|
1047
|
-
if not _call_from_tl_platform:
|
|
1048
|
-
set_current('tensorleap_custom_instances_metric')
|
|
1049
|
-
_validate_input_args(*args, **kwargs)
|
|
1050
|
-
|
|
1051
|
-
result = inner_without_validate(*args, **kwargs)
|
|
1052
|
-
|
|
1053
|
-
_validate_result(result)
|
|
1054
|
-
if not _call_from_tl_platform:
|
|
1055
|
-
update_env_params_func("tensorleap_custom_instances_metric", "v")
|
|
1056
|
-
return result
|
|
1057
|
-
|
|
1058
|
-
def mapping_inner(*args, **kwargs):
|
|
1059
|
-
user_unique_name = mapping_inner.name
|
|
1060
|
-
if 'user_unique_name' in kwargs:
|
|
1061
|
-
user_unique_name = kwargs['user_unique_name']
|
|
1062
|
-
|
|
1063
|
-
ordered_connections = [kwargs[n] for n in mapping_inner.arg_names if n in kwargs]
|
|
1064
|
-
ordered_connections = list(args) + ordered_connections
|
|
1065
|
-
|
|
1066
|
-
if user_unique_name in name_to_unique_name[mapping_inner.name]:
|
|
1067
|
-
user_unique_name = f'{user_unique_name}_{len(name_to_unique_name[mapping_inner.name])}'
|
|
1068
|
-
name_to_unique_name[mapping_inner.name].add(user_unique_name)
|
|
1069
|
-
|
|
1070
|
-
_add_mapping_connection(user_unique_name, ordered_connections, mapping_inner.arg_names,
|
|
1071
|
-
mapping_inner.name, NodeMappingType.Metric)
|
|
1072
|
-
|
|
1073
|
-
return None
|
|
1074
|
-
|
|
1075
|
-
mapping_inner.arg_names = leap_binder.setup_container.metrics[-1].metric_handler_data.arg_names
|
|
1076
|
-
mapping_inner.name = name
|
|
1077
|
-
|
|
1078
|
-
def final_inner(*args, **kwargs):
|
|
1079
|
-
if os.environ.get(mapping_runtime_mode_env_var_mame):
|
|
1080
|
-
return mapping_inner(*args, **kwargs)
|
|
1081
|
-
else:
|
|
1082
|
-
return inner(*args, **kwargs)
|
|
1083
|
-
|
|
1084
|
-
return final_inner
|
|
1085
|
-
|
|
1086
|
-
return decorating_function
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
880
|
def tensorleap_custom_visualizer(name: str, visualizer_type: LeapDataType,
|
|
1090
881
|
heatmap_function: Optional[Callable[..., npt.NDArray[np.float32]]] = None,
|
|
1091
882
|
connects_to=None):
|
|
@@ -205,6 +205,7 @@ class LeapLoader(LeapLoaderBase):
|
|
|
205
205
|
for metadata_name in global_leap_binder.leap_analysis_configuration.domain_gap_metadata:
|
|
206
206
|
if metadata_name not in m_names:
|
|
207
207
|
raise Exception(f"Domain gap metadata '{metadata_name}' is not found in dataset metadata list.")
|
|
208
|
+
global_leap_binder.validate_ignore_latent_spaces()
|
|
208
209
|
except DatasetScriptException as e:
|
|
209
210
|
line_number, file_name, stacktrace = get_root_exception_file_and_line_number()
|
|
210
211
|
general_error = f"Something went wrong. {repr(e.__cause__)} in file {file_name}, line_number: {line_number}\nStacktrace:\n{stacktrace}"
|
|
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.174.dev4 → code_loader-1.0.175.dev1}/code_loader/contract/visualizer_classes.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/experiment_api/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/experiment_api/cli_config_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/experiment_api/experiment.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/inner_leap_binder/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/plot_functions/__init__.py
RENAMED
|
File without changes
|
{code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/plot_functions/plot_functions.py
RENAMED
|
File without changes
|
{code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/plot_functions/visualize.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_loader-1.0.174.dev4 → code_loader-1.0.175.dev1}/code_loader/visualizers/default_visualizers.py
RENAMED
|
File without changes
|