code-loader 1.0.196.dev1__tar.gz → 1.0.197.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.196.dev1 → code_loader-1.0.197.dev1}/PKG-INFO +1 -1
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/code_loader/contract/datasetclasses.py +12 -59
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/code_loader/inner_leap_binder/leapbinder.py +49 -77
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/code_loader/inner_leap_binder/leapbinder_decorators.py +69 -191
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/code_loader/leaploader.py +44 -255
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/code_loader/leaploaderbase.py +8 -0
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/code_loader/utils.py +0 -7
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/pyproject.toml +2 -1
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/LICENSE +0 -0
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/README.md +0 -0
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/code_loader/__init__.py +0 -0
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/code_loader/contract/__init__.py +0 -0
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/code_loader/contract/enums.py +0 -0
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/code_loader/contract/exceptions.py +0 -0
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/code_loader/contract/mapping.py +0 -0
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/code_loader/contract/responsedataclasses.py +0 -0
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/code_loader/contract/sim_config.py +0 -0
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/code_loader/contract/visualizer_classes.py +0 -0
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/code_loader/default_losses.py +0 -0
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/code_loader/default_metrics.py +0 -0
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/code_loader/experiment_api/__init__.py +0 -0
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/code_loader/experiment_api/api.py +0 -0
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/code_loader/experiment_api/cli_config_utils.py +0 -0
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/code_loader/experiment_api/client.py +0 -0
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/code_loader/experiment_api/epoch.py +0 -0
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/code_loader/experiment_api/experiment.py +0 -0
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/code_loader/experiment_api/experiment_context.py +0 -0
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/code_loader/experiment_api/types.py +0 -0
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/code_loader/experiment_api/utils.py +0 -0
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/code_loader/experiment_api/workingspace_config_utils.py +0 -0
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/code_loader/inner_leap_binder/__init__.py +0 -0
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/code_loader/mixpanel_tracker.py +0 -0
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/code_loader/plot_functions/__init__.py +0 -0
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/code_loader/plot_functions/plot_functions.py +0 -0
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/code_loader/plot_functions/visualize.py +0 -0
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/code_loader/visualizers/__init__.py +0 -0
- {code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/code_loader/visualizers/default_visualizers.py +0 -0
{code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/code_loader/contract/datasetclasses.py
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import warnings
|
|
2
2
|
from dataclasses import dataclass, field
|
|
3
|
-
from typing import Any, Callable, List, Optional, Dict, Union, Type, Literal, Tuple
|
|
3
|
+
from typing import Any, Callable, List, Optional, Dict, Union, Type, Literal, Tuple
|
|
4
4
|
import re
|
|
5
5
|
import numpy as np
|
|
6
6
|
import numpy.typing as npt
|
|
@@ -15,8 +15,6 @@ custom_latent_space_attribute = "custom_latent_space"
|
|
|
15
15
|
|
|
16
16
|
_simulation_context: Dict[str, bool] = {"active": False}
|
|
17
17
|
|
|
18
|
-
SampleId = Union[int, str]
|
|
19
|
-
|
|
20
18
|
|
|
21
19
|
@dataclass
|
|
22
20
|
class PreprocessResponse:
|
|
@@ -41,46 +39,27 @@ class PreprocessResponse:
|
|
|
41
39
|
"""
|
|
42
40
|
length: Optional[int] = None # Deprecated. Please use sample_ids instead
|
|
43
41
|
data: Any = None
|
|
44
|
-
sample_ids: Optional[Union[List[
|
|
42
|
+
sample_ids: Optional[Union[List[str], List[int]]] = None
|
|
45
43
|
state: Optional[DataStateType] = None
|
|
46
44
|
sample_id_type: Optional[Union[Type[str], Type[int]]] = None
|
|
47
45
|
sample_ids_to_instance_mappings: Optional[Dict[str, List[str]]] = None # in use only for element instance
|
|
48
46
|
instance_to_sample_ids_mappings: Optional[Dict[str, str]] = None # in use only for element instance
|
|
49
47
|
tl_generated: bool = False
|
|
50
|
-
_grouped: bool = field(default=False, init=False, repr=False, compare=False)
|
|
51
|
-
_group_pos_cache: Optional[Dict[SampleId, Tuple[List[SampleId], int]]] = field(
|
|
52
|
-
default=None, init=False, repr=False, compare=False)
|
|
53
48
|
|
|
54
49
|
def __post_init__(self) -> None:
|
|
55
50
|
assert self.sample_ids_to_instance_mappings is None, f"Keep sample_ids_to_instance_mappings None when initializing PreprocessResponse"
|
|
56
51
|
assert self.instance_to_sample_ids_mappings is None, f"Keep instance_to_sample_ids_mappings None when initializing PreprocessResponse"
|
|
57
52
|
|
|
58
53
|
if self.length is not None and self.sample_ids is None:
|
|
59
|
-
self.sample_ids =
|
|
54
|
+
self.sample_ids = [i for i in range(self.length)]
|
|
60
55
|
self.sample_id_type = int
|
|
61
|
-
self._grouped = False
|
|
62
56
|
elif self.length is None and self.sample_ids is not None:
|
|
63
|
-
self.
|
|
64
|
-
if self.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
for
|
|
68
|
-
assert isinstance(
|
|
69
|
-
"Each group in a grouped PreprocessResponse must be a non-empty list."
|
|
70
|
-
self.sample_id_type = type(groups[0][0])
|
|
71
|
-
for group in groups:
|
|
72
|
-
for sample_id in group:
|
|
73
|
-
assert isinstance(sample_id, self.sample_id_type), \
|
|
74
|
-
f"Sample id should be of type {self.sample_id_type.__name__}. Got: {type(sample_id)}"
|
|
75
|
-
self.length = sum(len(group) for group in groups)
|
|
76
|
-
else:
|
|
77
|
-
flat_ids = cast(List[SampleId], self.sample_ids)
|
|
78
|
-
self.length = len(flat_ids)
|
|
79
|
-
if self.sample_id_type is None:
|
|
80
|
-
self.sample_id_type = str
|
|
81
|
-
if self.sample_id_type == str:
|
|
82
|
-
for sample_id in flat_ids:
|
|
83
|
-
assert isinstance(sample_id, str), f"Sample id should be of type str. Got: {type(sample_id)}"
|
|
57
|
+
self.length = len(self.sample_ids)
|
|
58
|
+
if self.sample_id_type is None:
|
|
59
|
+
self.sample_id_type = str
|
|
60
|
+
if self.sample_id_type == str:
|
|
61
|
+
for sample_id in self.sample_ids:
|
|
62
|
+
assert isinstance(sample_id, str), f"Sample id should be of type str. Got: {type(sample_id)}"
|
|
84
63
|
else:
|
|
85
64
|
raise Exception("length is deprecated, please use sample_ids instead.")
|
|
86
65
|
|
|
@@ -100,36 +79,9 @@ class PreprocessResponse:
|
|
|
100
79
|
return id(self)
|
|
101
80
|
|
|
102
81
|
def __len__(self) -> int:
|
|
103
|
-
assert self.length is not None
|
|
104
|
-
return self.length
|
|
105
|
-
|
|
106
|
-
@property
|
|
107
|
-
def is_grouped(self) -> bool:
|
|
108
|
-
return self._grouped
|
|
109
|
-
|
|
110
|
-
@property
|
|
111
|
-
def num_groups(self) -> int:
|
|
112
|
-
# Grouped: the number of groups. Flat: the (flat) sample count, since sample_ids is the
|
|
113
|
-
# flat id list and there is one sample per "group".
|
|
114
82
|
assert self.sample_ids is not None
|
|
115
83
|
return len(self.sample_ids)
|
|
116
84
|
|
|
117
|
-
@property
|
|
118
|
-
def groups(self) -> Optional[List[List[SampleId]]]:
|
|
119
|
-
# The nested list of groups when grouped, otherwise None. Callers should
|
|
120
|
-
# branch on is_grouped before relying on this.
|
|
121
|
-
return cast(List[List[SampleId]], self.sample_ids) if self._grouped else None
|
|
122
|
-
|
|
123
|
-
@property
|
|
124
|
-
def flat_sample_ids(self) -> List[SampleId]:
|
|
125
|
-
# All sample ids in order: concatenation of the groups when grouped,
|
|
126
|
-
# otherwise the flat sample_ids list as-is.
|
|
127
|
-
assert self.sample_ids is not None
|
|
128
|
-
if self._grouped:
|
|
129
|
-
groups = cast(List[List[SampleId]], self.sample_ids)
|
|
130
|
-
return [sample_id for group in groups for sample_id in group]
|
|
131
|
-
return cast(List[SampleId], self.sample_ids)
|
|
132
|
-
|
|
133
85
|
@dataclass
|
|
134
86
|
class ElementInstance:
|
|
135
87
|
name: str
|
|
@@ -300,6 +252,7 @@ class MetadataHandler:
|
|
|
300
252
|
class CustomLatentSpaceHandler:
|
|
301
253
|
function: SectionCallableInterface
|
|
302
254
|
name: str = 'custom_latent_space'
|
|
255
|
+
use_ls_for_analysis: bool = False
|
|
303
256
|
|
|
304
257
|
|
|
305
258
|
# How a chain's latent-space vectors are derived from its per-step forward passes.
|
|
@@ -382,7 +335,7 @@ class DatasetIntegrationSetup:
|
|
|
382
335
|
metrics: List[MetricHandler] = field(default_factory=list)
|
|
383
336
|
instance_metrics: List[InstanceMetricHandler] = field(default_factory=list)
|
|
384
337
|
custom_layers: Dict[str, CustomLayerHandler] = field(default_factory=dict)
|
|
385
|
-
|
|
338
|
+
custom_latent_spaces: Dict[str, CustomLatentSpaceHandler] = field(default_factory=dict)
|
|
386
339
|
simulations: List[SimulationHandler] = field(default_factory=list)
|
|
387
340
|
autoregressive_step: Optional[AutoregressiveStepHandler] = None
|
|
388
341
|
autoregressive_metrics: List[AutoregressiveMetricHandler] = field(default_factory=list)
|
|
@@ -398,6 +351,6 @@ class DatasetSample:
|
|
|
398
351
|
metadata_is_none: Dict[str, bool]
|
|
399
352
|
index: Union[int, str]
|
|
400
353
|
state: DataStateEnum
|
|
401
|
-
|
|
354
|
+
custom_latent_spaces: Optional[Dict[str, npt.NDArray[np.float32]]] = None
|
|
402
355
|
instance_masks: Optional[Dict[str, ElementInstance]] = None
|
|
403
356
|
|
{code_loader-1.0.196.dev1 → code_loader-1.0.197.dev1}/code_loader/inner_leap_binder/leapbinder.py
RENAMED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
import builtins
|
|
3
2
|
import inspect
|
|
4
|
-
import
|
|
5
|
-
from contextlib import contextmanager
|
|
6
|
-
from typing import Callable, List, Optional, Dict, Any, Type, Union, get_args, cast, Iterator, Set
|
|
3
|
+
from typing import Callable, List, Optional, Dict, Any, Type, Union, get_args
|
|
7
4
|
|
|
8
5
|
import numpy as np
|
|
9
6
|
import numpy.typing as npt
|
|
@@ -19,8 +16,7 @@ from code_loader.contract.datasetclasses import SectionCallableInterface, InputH
|
|
|
19
16
|
SimulationHandler, _simulation_context, AutoregressiveStepHandler, AutoregressiveStepCallableInterface, \
|
|
20
17
|
AUTOREGRESSIVE_LATENT_SPACE_AGGREGATIONS, AUTOREGRESSIVE_IMPLICIT_ARG_NAMES, \
|
|
21
18
|
AutoregressiveMetricHandler, AutoregressiveLossHandler, AutoregressiveVisualizerHandler
|
|
22
|
-
from code_loader.contract.enums import LeapDataType, DataStateEnum, DataStateType, MetricDirection, DatasetMetadataType
|
|
23
|
-
TestingSectionEnum
|
|
19
|
+
from code_loader.contract.enums import LeapDataType, DataStateEnum, DataStateType, MetricDirection, DatasetMetadataType
|
|
24
20
|
from code_loader.contract.mapping import NodeConnection, NodeMapping, NodeMappingType
|
|
25
21
|
from code_loader.contract.responsedataclasses import DatasetTestResultPayload, LeapAnalysisConfiguration
|
|
26
22
|
from code_loader.contract.visualizer_classes import map_leap_data_type_to_visualizer_class
|
|
@@ -37,25 +33,6 @@ from code_loader.visualizers.default_visualizers import DefaultVisualizer, \
|
|
|
37
33
|
mapping_runtime_mode_env_var_mame = '__MAPPING_RUNTIME_MODE__'
|
|
38
34
|
|
|
39
35
|
|
|
40
|
-
@contextmanager
|
|
41
|
-
def _track_opened_files() -> Iterator[Set[str]]:
|
|
42
|
-
opened: Set[str] = set()
|
|
43
|
-
original_open = builtins.open
|
|
44
|
-
|
|
45
|
-
def tracking_open(file: Any, *args: Any, **kwargs: Any) -> Any:
|
|
46
|
-
mode = args[0] if args else kwargs.get('mode', 'r')
|
|
47
|
-
is_read_mode = isinstance(mode, str) and not any(c in mode for c in ('a', 'w', 'x'))
|
|
48
|
-
if is_read_mode and isinstance(file, (str, os.PathLike)):
|
|
49
|
-
opened.add(os.fspath(file))
|
|
50
|
-
return original_open(file, *args, **kwargs)
|
|
51
|
-
|
|
52
|
-
builtins.open = tracking_open
|
|
53
|
-
try:
|
|
54
|
-
yield opened
|
|
55
|
-
finally:
|
|
56
|
-
builtins.open = original_open
|
|
57
|
-
|
|
58
|
-
|
|
59
36
|
def _stringized_annotation_type_name(annotation: Any) -> Optional[str]:
|
|
60
37
|
"""Bare type name if ``annotation`` is a stringized annotation (from ``from __future__
|
|
61
38
|
import annotations`` or a quoted hint), else ``None``. code_loader inspects raw
|
|
@@ -536,18 +513,54 @@ class LeapBinder:
|
|
|
536
513
|
"""
|
|
537
514
|
self.setup_container.metadata.append(MetadataHandler(name, function, metadata_type))
|
|
538
515
|
|
|
539
|
-
def set_custom_latent_space(self, function: SectionCallableInterface
|
|
516
|
+
def set_custom_latent_space(self, function: SectionCallableInterface,
|
|
517
|
+
name: Optional[str] = None,
|
|
518
|
+
use_ls_for_analysis: bool = False) -> None:
|
|
540
519
|
"""
|
|
541
|
-
|
|
520
|
+
Register a custom latent space function.
|
|
521
|
+
|
|
522
|
+
Multiple custom latent spaces may be registered as long as each has a
|
|
523
|
+
unique name. They are stored name-keyed (insertion order preserved), so a
|
|
524
|
+
later registration no longer overrides an earlier one.
|
|
542
525
|
|
|
543
526
|
Args:
|
|
544
|
-
function (SectionCallableInterface): The
|
|
527
|
+
function (SectionCallableInterface): The latent-space handler function.
|
|
545
528
|
This function receives:
|
|
546
529
|
subset (PreprocessResponse): The subset of the data.
|
|
547
530
|
index (int): The index of the sample within the subset.
|
|
548
|
-
This function should numpy float32 array
|
|
531
|
+
This function should return a numpy float32 array containing the latent
|
|
532
|
+
space vec of the sample.
|
|
533
|
+
name (Optional[str]): Unique name for this custom latent space. Defaults to
|
|
534
|
+
the reserved single-LS name for backward compatibility.
|
|
535
|
+
use_ls_for_analysis (bool): When True, the engine uses this custom latent
|
|
536
|
+
space for the Out-Of-Distribution and Domain-Gap insights instead of the
|
|
537
|
+
built-in defaults. At most one registered custom latent space may set this;
|
|
538
|
+
registering a second one with the flag raises.
|
|
549
539
|
"""
|
|
550
|
-
|
|
540
|
+
if name is None:
|
|
541
|
+
name = custom_latent_space_attribute
|
|
542
|
+
if name in self.setup_container.custom_latent_spaces:
|
|
543
|
+
raise Exception(
|
|
544
|
+
f"A custom latent space named '{name}' is already registered. Each "
|
|
545
|
+
f"@tensorleap_custom_latent_space must have a unique name "
|
|
546
|
+
f"(pass name='...' to distinguish them)."
|
|
547
|
+
)
|
|
548
|
+
if use_ls_for_analysis:
|
|
549
|
+
already_flagged = [
|
|
550
|
+
existing_name
|
|
551
|
+
for existing_name, handler in self.setup_container.custom_latent_spaces.items()
|
|
552
|
+
if handler.use_ls_for_analysis
|
|
553
|
+
]
|
|
554
|
+
if already_flagged:
|
|
555
|
+
raise Exception(
|
|
556
|
+
f"use_ls_for_analysis=True is already set on custom latent space "
|
|
557
|
+
f"'{already_flagged[0]}'. Only one custom latent space may set "
|
|
558
|
+
f"use_ls_for_analysis=True (it selects the latent space used for the "
|
|
559
|
+
f"Out-Of-Distribution and Domain-Gap insights). Set it on '{name}' "
|
|
560
|
+
f"or '{already_flagged[0]}', not both."
|
|
561
|
+
)
|
|
562
|
+
self.setup_container.custom_latent_spaces[name] = CustomLatentSpaceHandler(
|
|
563
|
+
function, name, use_ls_for_analysis)
|
|
551
564
|
|
|
552
565
|
def set_autoregressive_step(self, function: AutoregressiveStepCallableInterface,
|
|
553
566
|
latent_space_aggregation: str = 'last_step') -> None:
|
|
@@ -572,9 +585,7 @@ class LeapBinder:
|
|
|
572
585
|
# Builtin chain metadata, declared at parse time so it survives the reporter's
|
|
573
586
|
# metadata type mapping; the placeholder values are overwritten by the engine when a
|
|
574
587
|
# chain finalizes (realized length, truncated-by-safety-cap flag).
|
|
575
|
-
def builtin_chain_metadata(idx: Any, preprocess: PreprocessResponse) -> Any:
|
|
576
|
-
if isinstance(idx, list):
|
|
577
|
-
return [{'length': -1, 'truncated': False} for _ in idx]
|
|
588
|
+
def builtin_chain_metadata(idx: Any, preprocess: PreprocessResponse) -> Dict[str, Any]:
|
|
578
589
|
return {'length': -1, 'truncated': False}
|
|
579
590
|
|
|
580
591
|
self.set_metadata(builtin_chain_metadata, 'builtin_chain')
|
|
@@ -738,15 +749,6 @@ class LeapBinder:
|
|
|
738
749
|
if state_enum in preprocess_result_dict:
|
|
739
750
|
preprocess_result_dict_in_correct_order[state_enum] = preprocess_result_dict[state_enum]
|
|
740
751
|
|
|
741
|
-
# All-or-none: every state must agree on grouped (nested sample_ids) vs flat.
|
|
742
|
-
if len({r.is_grouped for r in preprocess_result_dict_in_correct_order.values()}) > 1:
|
|
743
|
-
shapes = ', '.join(
|
|
744
|
-
f"{state.name}={'grouped' if r.is_grouped else 'flat'}"
|
|
745
|
-
for state, r in preprocess_result_dict_in_correct_order.items())
|
|
746
|
-
raise Exception(
|
|
747
|
-
"All preprocess states must be either all grouped (nested sample_ids) or all flat, "
|
|
748
|
-
f"but got a mix: {shapes}.")
|
|
749
|
-
|
|
750
752
|
return preprocess_result_dict_in_correct_order
|
|
751
753
|
|
|
752
754
|
def get_preprocess_unlabeled_result(self) -> Optional[PreprocessResponse]:
|
|
@@ -767,34 +769,7 @@ class LeapBinder:
|
|
|
767
769
|
preprocess_response: PreprocessResponse, test_result: List[DatasetTestResultPayload],
|
|
768
770
|
dataset_base_handler: Union[DatasetBaseHandler, MetadataHandler], state: DataStateEnum) -> List[DatasetTestResultPayload]:
|
|
769
771
|
assert preprocess_response.sample_ids is not None
|
|
770
|
-
|
|
771
|
-
if preprocess_response.is_grouped:
|
|
772
|
-
# Grouped: probe with the first group, then reduce to a single sample's result so the
|
|
773
|
-
# recorded shape/type is per-sample (matching the flat case), not the (B, *) batch.
|
|
774
|
-
# (casts: sample_ids[0] is a group list here, and the grouped result is a per-sample list.)
|
|
775
|
-
group = preprocess_response.sample_ids[0]
|
|
776
|
-
with _track_opened_files() as opened_files:
|
|
777
|
-
raw_result = cast(Any, dataset_base_handler.function(cast(Any, group), preprocess_response))[0]
|
|
778
|
-
else:
|
|
779
|
-
raw_result = dataset_base_handler.function(
|
|
780
|
-
cast(Union[int, str], preprocess_response.sample_ids[0]), preprocess_response)
|
|
781
|
-
|
|
782
|
-
def _warn_if_group_spans_multiple_files(payloads: List[DatasetTestResultPayload]) -> None:
|
|
783
|
-
if opened_files is None or len(opened_files) <= 1:
|
|
784
|
-
return
|
|
785
|
-
shown = sorted(opened_files)[:5]
|
|
786
|
-
suffix = f" (+{len(opened_files) - 5} more)" if len(opened_files) > 5 else ""
|
|
787
|
-
warning = (
|
|
788
|
-
f"Encoding declared group 0 (size {len(cast(List[Any], group))}) for '{dataset_base_handler.name}' opened "
|
|
789
|
-
f"{len(opened_files)} distinct files: {shown}{suffix}. If this group is meant to be one "
|
|
790
|
-
f"physical source (e.g. one Parquet file), it may be grouped incorrectly - check your "
|
|
791
|
-
f"preprocess grouping logic. (Only files opened via Python's open() are tracked, so this "
|
|
792
|
-
f"can miss other I/O paths or be a false positive if grouping isn't meant to reflect file "
|
|
793
|
-
f"locality.)")
|
|
794
|
-
for payload in payloads:
|
|
795
|
-
existing = payload.display.get(TestingSectionEnum.Errors.name, '')
|
|
796
|
-
payload.display[TestingSectionEnum.Errors.name] = (existing + '\n' if existing else '') + warning
|
|
797
|
-
|
|
772
|
+
raw_result = dataset_base_handler.function(preprocess_response.sample_ids[0], preprocess_response)
|
|
798
773
|
handler_type = 'metadata' if isinstance(dataset_base_handler, MetadataHandler) else None
|
|
799
774
|
if isinstance(dataset_base_handler, MetadataHandler):
|
|
800
775
|
if isinstance(raw_result, dict):
|
|
@@ -834,7 +809,6 @@ class LeapBinder:
|
|
|
834
809
|
else:
|
|
835
810
|
if raw_result is None:
|
|
836
811
|
if state != DataStateEnum.training:
|
|
837
|
-
_warn_if_group_spans_multiple_files(test_result)
|
|
838
812
|
return test_result
|
|
839
813
|
|
|
840
814
|
if dataset_base_handler.metadata_type is None:
|
|
@@ -856,7 +830,6 @@ class LeapBinder:
|
|
|
856
830
|
# setting shape in setup for all encoders
|
|
857
831
|
if isinstance(dataset_base_handler, (InputHandler, GroundTruthHandler)):
|
|
858
832
|
dataset_base_handler.shape = result_shape
|
|
859
|
-
_warn_if_group_spans_multiple_files(test_result)
|
|
860
833
|
return test_result
|
|
861
834
|
|
|
862
835
|
def check_handlers(self, preprocess_result: Dict[DataStateEnum, PreprocessResponse]) -> None:
|
|
@@ -892,11 +865,10 @@ class LeapBinder:
|
|
|
892
865
|
preprocess_response.tl_generated = True
|
|
893
866
|
if not preprocess_response.length or preprocess_response.length < 1:
|
|
894
867
|
raise Exception("Simulation '{}' returned PreprocessResponse with length < 1".format(sim.name))
|
|
895
|
-
preprocess_response.sample_ids =
|
|
896
|
-
sim_sample_ids = cast(List[Union[int, str]], preprocess_response.sample_ids)
|
|
868
|
+
preprocess_response.sample_ids = [0]
|
|
897
869
|
for handler in self.setup_container.inputs:
|
|
898
|
-
out1 = handler.function(
|
|
899
|
-
out2 = handler.function(
|
|
870
|
+
out1 = handler.function(preprocess_response.sample_ids[0], preprocess_response)
|
|
871
|
+
out2 = handler.function(preprocess_response.sample_ids[0], preprocess_response)
|
|
900
872
|
if not np.allclose(out1, out2):
|
|
901
873
|
raise Exception(
|
|
902
874
|
"Simulation '{}': encoder '{}' is non-deterministic — consecutive calls with seed=0 returned different outputs".format(
|
|
@@ -954,7 +926,7 @@ class LeapBinder:
|
|
|
954
926
|
"Element instances are not supported together with tensorleap_autoregressive_step: "
|
|
955
927
|
"instance generation masks the sample's encoded inputs, which do not exist in an "
|
|
956
928
|
"autoregressive integration. Remove the instance encoders or the autoregressive hook.")
|
|
957
|
-
if self.setup_container.
|
|
929
|
+
if self.setup_container.custom_latent_spaces:
|
|
958
930
|
raise Exception(
|
|
959
931
|
"tensorleap_custom_latent_space is not supported together with "
|
|
960
932
|
"tensorleap_autoregressive_step: the custom latent space function only sees "
|