code-loader 1.0.208.dev6__py3-none-any.whl → 1.0.208.dev8__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/responsedataclasses.py +0 -1
- code_loader/inner_leap_binder/leapbinder.py +0 -6
- code_loader/inner_leap_binder/leapbinder_decorators.py +32 -18
- code_loader/leaploader.py +14 -14
- {code_loader-1.0.208.dev6.dist-info → code_loader-1.0.208.dev8.dist-info}/METADATA +1 -1
- {code_loader-1.0.208.dev6.dist-info → code_loader-1.0.208.dev8.dist-info}/RECORD +8 -8
- {code_loader-1.0.208.dev6.dist-info → code_loader-1.0.208.dev8.dist-info}/LICENSE +0 -0
- {code_loader-1.0.208.dev6.dist-info → code_loader-1.0.208.dev8.dist-info}/WHEEL +0 -0
|
@@ -144,7 +144,6 @@ class LeapAnalysisConfiguration:
|
|
|
144
144
|
class EngineFileContract:
|
|
145
145
|
node_connections: Optional[List[NodeConnection]] = None
|
|
146
146
|
leap_analysis_configuration: Optional[LeapAnalysisConfiguration] = None
|
|
147
|
-
latent_space_connections: Optional[List[NodeConnection]] = None
|
|
148
147
|
|
|
149
148
|
|
|
150
149
|
@dataclass
|
|
@@ -85,11 +85,6 @@ def _reject_stringized_sample_preprocess_response(function: Callable[..., Any],
|
|
|
85
85
|
"This breaks Tensorleap type detection, so it must be referenced as a real type.")
|
|
86
86
|
|
|
87
87
|
|
|
88
|
-
def _reject_stringized_preprocess_response(function: Callable[..., Any], arg_name: str, annotation: Any) -> None:
|
|
89
|
-
_reject_stringized_annotation(
|
|
90
|
-
function, arg_name, annotation, PreprocessResponse,
|
|
91
|
-
"Tensorleap uses that annotation to tell a dataset-computed custom latent space from a "
|
|
92
|
-
"model-computed one, so it must be a real type.")
|
|
93
88
|
|
|
94
89
|
|
|
95
90
|
|
|
@@ -115,7 +110,6 @@ class LeapBinder:
|
|
|
115
110
|
self._extend_with_default_losses()
|
|
116
111
|
|
|
117
112
|
self.mapping_connections: List[NodeConnection] = []
|
|
118
|
-
self.latent_space_connections: List[NodeConnection] = []
|
|
119
113
|
self.integration_test_func: Optional[Callable[[str, PreprocessResponse], Any]] = None
|
|
120
114
|
|
|
121
115
|
self.batch_size_to_validate: Optional[int] = None
|
|
@@ -7,6 +7,7 @@ import warnings
|
|
|
7
7
|
import logging
|
|
8
8
|
from collections import defaultdict
|
|
9
9
|
import functools
|
|
10
|
+
import typing
|
|
10
11
|
from functools import lru_cache
|
|
11
12
|
from pathlib import Path
|
|
12
13
|
from typing import Optional, Union, Callable, List, Dict, Set, Any
|
|
@@ -36,7 +37,7 @@ from code_loader.contract.visualizer_classes import LeapImage, LeapImageMask, Le
|
|
|
36
37
|
LeapHorizontalBar, LeapImageWithBBox, LeapImageWithHeatmap, LeapVideo, LeapAudio, LeapValidationError, \
|
|
37
38
|
map_leap_data_type_to_visualizer_class
|
|
38
39
|
from code_loader.inner_leap_binder.leapbinder import mapping_runtime_mode_env_var_mame, \
|
|
39
|
-
|
|
40
|
+
_reject_stringized_sample_preprocess_response
|
|
40
41
|
from code_loader.mixpanel_tracker import clear_integration_events, AnalyticsEvent, emit_integration_event_once
|
|
41
42
|
|
|
42
43
|
_called_from_inside_tl_decorator = 0
|
|
@@ -1751,15 +1752,32 @@ def tensorleap_metadata(
|
|
|
1751
1752
|
return decorating_function
|
|
1752
1753
|
|
|
1753
1754
|
|
|
1755
|
+
def _is_preprocess_response_type(annotation: Any) -> bool:
|
|
1756
|
+
if isinstance(annotation, type):
|
|
1757
|
+
return issubclass(annotation, PreprocessResponse)
|
|
1758
|
+
return any(_is_preprocess_response_type(arg) for arg in get_args(annotation))
|
|
1759
|
+
|
|
1760
|
+
|
|
1754
1761
|
def _classify_custom_latent_space_signature(user_function) -> str:
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1762
|
+
"""Dataset-computed when a parameter is typed PreprocessResponse (a subclass or an
|
|
1763
|
+
Optional[...] of it included), model-computed otherwise."""
|
|
1764
|
+
params = list(inspect.signature(user_function).parameters.values())
|
|
1765
|
+
hints = typing.get_type_hints(user_function)
|
|
1766
|
+
preprocess_params = [p.name for p in params if _is_preprocess_response_type(hints.get(p.name))]
|
|
1767
|
+
if preprocess_params:
|
|
1768
|
+
positional = [p.name for p in params
|
|
1769
|
+
if p.kind in (inspect.Parameter.POSITIONAL_ONLY, inspect.Parameter.POSITIONAL_OR_KEYWORD)]
|
|
1770
|
+
if positional[1:2] != preprocess_params[:1] or len(preprocess_params) > 1:
|
|
1771
|
+
raise Exception(
|
|
1772
|
+
f"tensorleap_custom_latent_space validation failed: '{user_function.__name__}' is "
|
|
1773
|
+
f"dataset-computed (it takes a PreprocessResponse), so it is called as "
|
|
1774
|
+
f"{user_function.__name__}(sample_id, preprocess) and its PreprocessResponse must be "
|
|
1775
|
+
f"the second positional parameter, and the only one. Got parameters "
|
|
1776
|
+
f"{[p.name for p in params]} with PreprocessResponse on {preprocess_params}.")
|
|
1777
|
+
return 'dataset'
|
|
1759
1778
|
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
if second not in argspec.annotations:
|
|
1779
|
+
if len(params) == 2 and params[1].name not in hints:
|
|
1780
|
+
first, second = params[0].name, params[1].name
|
|
1763
1781
|
raise Exception(
|
|
1764
1782
|
f"tensorleap_custom_latent_space validation failed: '{user_function.__name__}' has "
|
|
1765
1783
|
f"exactly two parameters ('{first}', '{second}') and '{second}' has no type "
|
|
@@ -1771,11 +1789,6 @@ def _classify_custom_latent_space_signature(user_function) -> str:
|
|
|
1771
1789
|
f"If you are upgrading an existing project, this signature used to be accepted "
|
|
1772
1790
|
f"unannotated as dataset-computed; add ': PreprocessResponse' to '{second}' to keep "
|
|
1773
1791
|
f"the previous behavior.")
|
|
1774
|
-
|
|
1775
|
-
annotation = argspec.annotations[second]
|
|
1776
|
-
_reject_stringized_preprocess_response(user_function, second, annotation)
|
|
1777
|
-
if annotation is PreprocessResponse:
|
|
1778
|
-
return 'dataset'
|
|
1779
1792
|
return 'model'
|
|
1780
1793
|
|
|
1781
1794
|
|
|
@@ -2055,14 +2068,15 @@ def _decorate_model_latent_space(user_function, ls_name, use_ls_for_analysis, re
|
|
|
2055
2068
|
ordered_connections = [kwargs[arg_name] for arg_name in arg_names if arg_name in kwargs]
|
|
2056
2069
|
ordered_connections = list(args) + ordered_connections
|
|
2057
2070
|
|
|
2058
|
-
leap_binder.
|
|
2059
|
-
connection for connection in leap_binder.
|
|
2060
|
-
if connection.node.
|
|
2071
|
+
leap_binder.mapping_connections[:] = [
|
|
2072
|
+
connection for connection in leap_binder.mapping_connections
|
|
2073
|
+
if not (connection.node.type is NodeMappingType.CustomLatentSpace
|
|
2074
|
+
and connection.node.name == ls_name)]
|
|
2061
2075
|
_add_mapping_connection(ls_name, ordered_connections, arg_names, ls_name,
|
|
2062
|
-
NodeMappingType.CustomLatentSpace
|
|
2063
|
-
target_list=leap_binder.latent_space_connections)
|
|
2076
|
+
NodeMappingType.CustomLatentSpace)
|
|
2064
2077
|
return None
|
|
2065
2078
|
|
|
2079
|
+
@functools.wraps(user_function)
|
|
2066
2080
|
def final_inner(*args, **kwargs):
|
|
2067
2081
|
if os.environ.get(mapping_runtime_mode_env_var_mame):
|
|
2068
2082
|
return mapping_inner(*args, **kwargs)
|
code_loader/leaploader.py
CHANGED
|
@@ -55,8 +55,6 @@ class LeapLoader(LeapLoaderBase):
|
|
|
55
55
|
self._preprocess_result_cached = None
|
|
56
56
|
self._synthetic_lookup: Dict[str, Tuple[PreprocessResponse, Any]] = {}
|
|
57
57
|
self._synthetic_populator: Optional[Callable[[str], None]] = None
|
|
58
|
-
# Dataset-computed custom LS the engine dropped for this job; get_sample stops computing them.
|
|
59
|
-
self._skipped_custom_latent_spaces: FrozenSet[str] = frozenset()
|
|
60
58
|
|
|
61
59
|
try:
|
|
62
60
|
from code_loader.mixpanel_tracker import track_code_loader_loaded
|
|
@@ -396,8 +394,7 @@ class LeapLoader(LeapLoaderBase):
|
|
|
396
394
|
print_log=print_log,
|
|
397
395
|
engine_file_contract=EngineFileContract(
|
|
398
396
|
global_leap_binder.mapping_connections,
|
|
399
|
-
global_leap_binder.leap_analysis_configuration
|
|
400
|
-
global_leap_binder.latent_space_connections))
|
|
397
|
+
global_leap_binder.leap_analysis_configuration))
|
|
401
398
|
|
|
402
399
|
def _check_integration_test_exists(self) -> DatasetTestResultPayload:
|
|
403
400
|
test_result = DatasetTestResultPayload('integration_test')
|
|
@@ -457,9 +454,10 @@ class LeapLoader(LeapLoaderBase):
|
|
|
457
454
|
)
|
|
458
455
|
if global_leap_binder.setup_container.unlabeled_data_preprocess is not None:
|
|
459
456
|
gt_bound_names = [
|
|
460
|
-
connection.node.name for connection in global_leap_binder.
|
|
461
|
-
if
|
|
462
|
-
|
|
457
|
+
connection.node.name for connection in global_leap_binder.mapping_connections
|
|
458
|
+
if connection.node.type is NodeMappingType.CustomLatentSpace
|
|
459
|
+
and any(node_input.type == NodeMappingType.GroundTruth
|
|
460
|
+
for node_input in (connection.node_inputs or {}).values())
|
|
463
461
|
]
|
|
464
462
|
if gt_bound_names:
|
|
465
463
|
test_result.display[TestingSectionEnum.Warnings.name] = (
|
|
@@ -1208,10 +1206,17 @@ class LeapLoader(LeapLoaderBase):
|
|
|
1208
1206
|
if any(handler.instance_aware for handler in latent_handlers.values()):
|
|
1209
1207
|
raise Exception(
|
|
1210
1208
|
"instance-aware custom latent spaces are not supported with grouped preprocess responses")
|
|
1209
|
+
# TODO: support model-computed custom latent spaces on grouped datasets (skip them here,
|
|
1210
|
+
# as the per-sample path does, once the grouped metrics path is verified to compute them).
|
|
1211
|
+
model_ls_names = [name for name, handler in latent_handlers.items()
|
|
1212
|
+
if handler.computed_at == CustomLatentSpaceComputedAt.MODEL]
|
|
1213
|
+
if model_ls_names:
|
|
1214
|
+
raise Exception(
|
|
1215
|
+
f"model-computed custom latent spaces {model_ls_names} are not supported with "
|
|
1216
|
+
f"grouped preprocess responses yet")
|
|
1211
1217
|
custom_latent_spaces = {
|
|
1212
1218
|
name: self._to_grouped_list(handler.function(group_ids, preprocess_state))
|
|
1213
1219
|
for name, handler in latent_handlers.items()
|
|
1214
|
-
if name not in self._skipped_custom_latent_spaces
|
|
1215
1220
|
}
|
|
1216
1221
|
|
|
1217
1222
|
return DatasetSample(inputs=inputs, gt=gt, metadata=metadata, metadata_is_none=metadata_is_none,
|
|
@@ -1435,8 +1440,7 @@ class LeapLoader(LeapLoaderBase):
|
|
|
1435
1440
|
instance_id: Optional[int] = None) -> Optional[Dict[str, npt.NDArray[np.float32]]]:
|
|
1436
1441
|
handlers = {handler_name: handler for handler_name, handler
|
|
1437
1442
|
in global_leap_binder.setup_container.custom_latent_spaces.items()
|
|
1438
|
-
if handler.computed_at != CustomLatentSpaceComputedAt.MODEL
|
|
1439
|
-
and handler_name not in self._skipped_custom_latent_spaces}
|
|
1443
|
+
if handler.computed_at != CustomLatentSpaceComputedAt.MODEL}
|
|
1440
1444
|
if not handlers:
|
|
1441
1445
|
return None
|
|
1442
1446
|
if preprocess.is_grouped:
|
|
@@ -1463,10 +1467,6 @@ class LeapLoader(LeapLoaderBase):
|
|
|
1463
1467
|
self.exec_script()
|
|
1464
1468
|
return len(global_leap_binder.setup_container.custom_latent_spaces) > 0
|
|
1465
1469
|
|
|
1466
|
-
def set_skipped_custom_latent_spaces(self, names: Iterable[str]) -> None:
|
|
1467
|
-
"""Stop computing these dataset-computed custom latent spaces in get_sample(s)."""
|
|
1468
|
-
self._skipped_custom_latent_spaces = frozenset(names)
|
|
1469
|
-
|
|
1470
1470
|
@lru_cache()
|
|
1471
1471
|
def get_custom_latent_space_names(self) -> Tuple[str, ...]:
|
|
1472
1472
|
"""Names of all registered custom latent spaces, in registration order.
|
|
@@ -5,7 +5,7 @@ code_loader/contract/datasetclasses.py,sha256=yNEPIyZqCO54fKBgmgbFIKEMVBzvpf4n8U
|
|
|
5
5
|
code_loader/contract/enums.py,sha256=R4Ge9-oSO7-GYjZAKMTB8Ws5FNsxhCQAYAJruxViJxk,1886
|
|
6
6
|
code_loader/contract/exceptions.py,sha256=jWqu5i7t-0IG0jGRsKF4DjJdrsdpJjIYpUkN1F4RiyQ,51
|
|
7
7
|
code_loader/contract/mapping.py,sha256=i-yVyFuGUITL5lchPNfYlu7bhwk-yuoHPacAeFhcYr8,1490
|
|
8
|
-
code_loader/contract/responsedataclasses.py,sha256=
|
|
8
|
+
code_loader/contract/responsedataclasses.py,sha256=2SQCccuIlSeUJT0igyvIJRYtmaWSqqlQwtaAA1iEuSI,5044
|
|
9
9
|
code_loader/contract/sim_config.py,sha256=le8KMALZiP0WU4UcuKnTOSWBW2rNjpnWYfII502NqDM,3493
|
|
10
10
|
code_loader/contract/visualizer_classes.py,sha256=vzX9YcwxKOm3IpYj8OaqsA1odPlRgj2Cfvglwd88Wbw,18213
|
|
11
11
|
code_loader/default_losses.py,sha256=NoOQym1106bDN5dcIk56Elr7ZG5quUHArqfP5-Nyxyo,1139
|
|
@@ -21,9 +21,9 @@ 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=
|
|
24
|
+
code_loader/inner_leap_binder/leapbinder.py,sha256=fplNN3TfJHg79YpEPHKK3b6CxrR7W0ugDeHhAZfYty0,62784
|
|
25
|
+
code_loader/inner_leap_binder/leapbinder_decorators.py,sha256=paUtnncLn-4iFUJhqEOg3rPtKh9DoS3_HVgGUgOz8c4,210906
|
|
26
|
+
code_loader/leaploader.py,sha256=DiVCs076JP21HXBfpKkzs3Qaumg8Cz26q1tIc4C-kcg,97552
|
|
27
27
|
code_loader/leaploaderbase.py,sha256=JzgpEfY-kNUWbWUb_cZ1G1zHo6oSci6QhT7hqw3E1Jg,12371
|
|
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=v6VraCdbFADoNwNx5TH89BLnZ6yfPoWMkyJrqQ_usFc,12377
|
|
33
33
|
code_loader/visualizers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
34
34
|
code_loader/visualizers/default_visualizers.py,sha256=grTPin_lCE9aci8i8CqA7DqQwAyXRB7_EamA3na_pls,5438
|
|
35
|
-
code_loader-1.0.208.
|
|
36
|
-
code_loader-1.0.208.
|
|
37
|
-
code_loader-1.0.208.
|
|
38
|
-
code_loader-1.0.208.
|
|
35
|
+
code_loader-1.0.208.dev8.dist-info/LICENSE,sha256=qIwWjdspQeSMTtnFZBC8MuT-95L02FPvzRUdWFxrwJY,1067
|
|
36
|
+
code_loader-1.0.208.dev8.dist-info/METADATA,sha256=Zv4Z5dCnspuqPU778nnj7nEOkmHqIhxBg44L_ZwRIUw,1095
|
|
37
|
+
code_loader-1.0.208.dev8.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
38
|
+
code_loader-1.0.208.dev8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|