code-loader 1.0.97.dev0__py3-none-any.whl → 1.0.99.dev2__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.
Potentially problematic release.
This version of code-loader might be problematic. Click here for more details.
- code_loader/contract/datasetclasses.py +6 -1
- code_loader/contract/visualizer_classes.py +2 -6
- code_loader/inner_leap_binder/leapbinder.py +5 -3
- code_loader/inner_leap_binder/leapbinder_decorators.py +154 -15
- code_loader/leaploader.py +31 -7
- code_loader/utils.py +1 -26
- {code_loader-1.0.97.dev0.dist-info → code_loader-1.0.99.dev2.dist-info}/METADATA +1 -1
- {code_loader-1.0.97.dev0.dist-info → code_loader-1.0.99.dev2.dist-info}/RECORD +10 -10
- {code_loader-1.0.97.dev0.dist-info → code_loader-1.0.99.dev2.dist-info}/LICENSE +0 -0
- {code_loader-1.0.97.dev0.dist-info → code_loader-1.0.99.dev2.dist-info}/WHEEL +0 -0
|
@@ -40,6 +40,9 @@ class PreprocessResponse:
|
|
|
40
40
|
sample_id_type: Optional[Union[Type[str], Type[int]]] = None
|
|
41
41
|
|
|
42
42
|
def __post_init__(self) -> None:
|
|
43
|
+
def is_valid_string(s: str) -> bool:
|
|
44
|
+
return bool(re.match(r'^[A-Za-z0-9_]+$', s))
|
|
45
|
+
|
|
43
46
|
if self.length is not None and self.sample_ids is None:
|
|
44
47
|
self.sample_ids = [i for i in range(self.length)]
|
|
45
48
|
self.sample_id_type = int
|
|
@@ -50,6 +53,8 @@ class PreprocessResponse:
|
|
|
50
53
|
if self.sample_id_type == str:
|
|
51
54
|
for sample_id in self.sample_ids:
|
|
52
55
|
assert isinstance(sample_id, str), f"Sample id should be of type str. Got: {type(sample_id)}"
|
|
56
|
+
if not is_valid_string(sample_id):
|
|
57
|
+
raise Exception(f"Sample id should contain only letters (A-Z, a-z), numbers or '_'. Got: {sample_id}")
|
|
53
58
|
else:
|
|
54
59
|
raise Exception("length is deprecated.")
|
|
55
60
|
|
|
@@ -200,7 +205,7 @@ class MetadataHandler:
|
|
|
200
205
|
class PredictionTypeHandler:
|
|
201
206
|
name: str
|
|
202
207
|
labels: List[str]
|
|
203
|
-
channel_dim: int
|
|
208
|
+
channel_dim: int = -1
|
|
204
209
|
|
|
205
210
|
|
|
206
211
|
@dataclass
|
|
@@ -121,23 +121,19 @@ class LeapGraph:
|
|
|
121
121
|
x_label = 'Frequency [Seconds]'
|
|
122
122
|
y_label = 'Amplitude [Voltage]'
|
|
123
123
|
x_range = (0.1, 3.0)
|
|
124
|
-
|
|
125
|
-
leap_graph = LeapGraph(data=graph_data, x_label=x_label, y_label=y_label, x_range=x_range, legend=legend)
|
|
124
|
+
leap_graph = LeapGraph(data=graph_data, x_label=x_label, y_label=y_label, x_range=x_range)
|
|
126
125
|
"""
|
|
127
126
|
data: npt.NDArray[np.float32]
|
|
128
127
|
type: LeapDataType = LeapDataType.Graph
|
|
129
128
|
x_label: Optional[str] = None
|
|
130
129
|
y_label: Optional[str] = None
|
|
131
130
|
x_range: Optional[Tuple[float,float]] = None
|
|
132
|
-
legend: Optional[List[str]] = None
|
|
133
131
|
|
|
134
132
|
def __post_init__(self) -> None:
|
|
135
133
|
validate_type(self.type, LeapDataType.Graph)
|
|
136
134
|
validate_type(type(self.data), np.ndarray)
|
|
137
135
|
validate_type(self.data.dtype, np.float32)
|
|
138
|
-
validate_type(len(self.data.shape), 2,
|
|
139
|
-
if self.legend:
|
|
140
|
-
validate_type(self.data.shape[1], len(self.legend), 'Number of labels supplied should equal the number of graphs')
|
|
136
|
+
validate_type(len(self.data.shape), 2, 'Graph must be of shape 2')
|
|
141
137
|
validate_type(type(self.x_label), [str, type(None)], 'x_label must be a string or None')
|
|
142
138
|
validate_type(type(self.y_label), [str, type(None)], 'y_label must be a string or None')
|
|
143
139
|
validate_type(type(self.x_range), [tuple, type(None)], 'x_range must be a tuple or None')
|
|
@@ -24,6 +24,9 @@ from code_loader.visualizers.default_visualizers import DefaultVisualizer, \
|
|
|
24
24
|
default_image_mask_visualizer, default_text_mask_visualizer, default_raw_data_visualizer, default_video_visualizer
|
|
25
25
|
|
|
26
26
|
|
|
27
|
+
mapping_runtime_mode_env_var_mame = '__MAPPING_RUNTIME_MODE__'
|
|
28
|
+
|
|
29
|
+
|
|
27
30
|
class LeapBinder:
|
|
28
31
|
"""
|
|
29
32
|
Interface to the Tensorleap platform. Provides methods to set up preprocessing,
|
|
@@ -513,10 +516,9 @@ class LeapBinder:
|
|
|
513
516
|
for i, (single_metadata_name, single_metadata_result) in enumerate(raw_result.items()):
|
|
514
517
|
metadata_test_result = metadata_test_result_payloads[i]
|
|
515
518
|
|
|
516
|
-
if not isinstance(single_metadata_result, (int, str, bool, float, np.unsignedinteger,
|
|
517
|
-
np.signedinteger, np.bool_, np.floating, type(None))):
|
|
519
|
+
if not isinstance(single_metadata_result, (int, str, bool, float, np.unsignedinteger, np.signedinteger, np.bool_, np.floating)):
|
|
518
520
|
raise Exception(f"Unsupported return type of metadata {single_metadata_name}."
|
|
519
|
-
f"The return type should be one of [int, float, str, bool
|
|
521
|
+
f"The return type should be one of [int, float, str, bool]. Got {type(single_metadata_result)}")
|
|
520
522
|
|
|
521
523
|
metadata_type = None
|
|
522
524
|
if single_metadata_result is None:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# mypy: ignore-errors
|
|
2
|
-
|
|
2
|
+
import os
|
|
3
3
|
from typing import Optional, Union, Callable, List, Dict
|
|
4
4
|
|
|
5
5
|
import numpy as np
|
|
@@ -8,22 +8,83 @@ import numpy.typing as npt
|
|
|
8
8
|
from code_loader.contract.datasetclasses import CustomCallableInterfaceMultiArgs, \
|
|
9
9
|
CustomMultipleReturnCallableInterfaceMultiArgs, ConfusionMatrixCallableInterfaceMultiArgs, CustomCallableInterface, \
|
|
10
10
|
VisualizerCallableInterface, MetadataSectionCallableInterface, PreprocessResponse, SectionCallableInterface, \
|
|
11
|
-
ConfusionMatrixElement, SamplePreprocessResponse
|
|
11
|
+
ConfusionMatrixElement, SamplePreprocessResponse, PredictionTypeHandler
|
|
12
12
|
from code_loader.contract.enums import MetricDirection, LeapDataType, DatasetMetadataType
|
|
13
13
|
from code_loader import leap_binder
|
|
14
14
|
from code_loader.contract.mapping import NodeMapping, NodeMappingType, NodeConnection
|
|
15
15
|
from code_loader.contract.visualizer_classes import LeapImage, LeapImageMask, LeapTextMask, LeapText, LeapGraph, \
|
|
16
16
|
LeapHorizontalBar, LeapImageWithBBox, LeapImageWithHeatmap
|
|
17
|
+
from code_loader.inner_leap_binder.leapbinder import mapping_runtime_mode_env_var_mame
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _add_mapping_connection(user_unique_name, connection_destinations, arg_names, name, node_mapping_type):
|
|
21
|
+
main_node_mapping = NodeMapping(name, node_mapping_type, user_unique_name, arg_names=arg_names)
|
|
22
|
+
node_inputs = {}
|
|
23
|
+
for arg_name, destination in zip(arg_names, connection_destinations):
|
|
24
|
+
node_inputs[arg_name] = destination.node_mapping
|
|
25
|
+
|
|
26
|
+
leap_binder.mapping_connections.append(NodeConnection(main_node_mapping, node_inputs))
|
|
17
27
|
|
|
18
28
|
|
|
19
29
|
def _add_mapping_connections(connects_to, arg_names, node_mapping_type, name):
|
|
20
30
|
for user_unique_name, connection_destinations in connects_to.items():
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
31
|
+
_add_mapping_connection(user_unique_name, connection_destinations, arg_names, name, node_mapping_type)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def tensorleap_load_model(prediction_types: Optional[List[PredictionTypeHandler]] = None):
|
|
37
|
+
for i, prediction_type in enumerate(prediction_types):
|
|
38
|
+
leap_binder.add_prediction(prediction_type.name, prediction_type.labels, prediction_type.channel_dim, i)
|
|
39
|
+
|
|
40
|
+
def decorating_function(load_model_func):
|
|
41
|
+
class TempMapping:
|
|
42
|
+
pass
|
|
43
|
+
|
|
44
|
+
def mapping_inner():
|
|
45
|
+
class ModelOutputPlaceholder:
|
|
46
|
+
def __init__(self):
|
|
47
|
+
self.node_mapping = NodeMapping('', NodeMappingType.Prediction0)
|
|
48
|
+
|
|
49
|
+
def __getitem__(self, key):
|
|
50
|
+
assert isinstance(key, int), \
|
|
51
|
+
f'Expected key to be an int, got {type(key)} instead.'
|
|
52
|
+
|
|
53
|
+
ret = TempMapping()
|
|
54
|
+
ret.node_mapping = NodeMapping('', NodeMappingType(f'Prediction{str(key)}'))
|
|
55
|
+
return ret
|
|
56
|
+
|
|
57
|
+
class ModelPlaceholder:
|
|
58
|
+
#keras interface
|
|
59
|
+
def __call__(self, arg):
|
|
60
|
+
if isinstance(arg, list):
|
|
61
|
+
for i, elem in enumerate(arg):
|
|
62
|
+
elem.node_mapping.type = NodeMappingType[f'Input{str(i)}']
|
|
63
|
+
else:
|
|
64
|
+
arg.node_mapping.type = NodeMappingType.Input0
|
|
65
|
+
|
|
66
|
+
return ModelOutputPlaceholder()
|
|
67
|
+
|
|
68
|
+
# onnx runtime interface
|
|
69
|
+
def run(self, output_names, input_dict):
|
|
70
|
+
assert output_names is None
|
|
71
|
+
assert isinstance(input_dict, dict), \
|
|
72
|
+
f'Expected input_dict to be a dict, got {type(input_dict)} instead.'
|
|
73
|
+
for i, elem in enumerate(input_dict.values()):
|
|
74
|
+
elem.node_mapping.type = NodeMappingType[f'Input{str(i)}']
|
|
75
|
+
|
|
76
|
+
return ModelOutputPlaceholder()
|
|
77
|
+
|
|
78
|
+
return ModelPlaceholder()
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
if os.environ.get(mapping_runtime_mode_env_var_mame):
|
|
82
|
+
return mapping_inner
|
|
83
|
+
else:
|
|
84
|
+
return load_model_func
|
|
85
|
+
|
|
86
|
+
return decorating_function
|
|
25
87
|
|
|
26
|
-
leap_binder.mapping_connections.append(NodeConnection(main_node_mapping, node_inputs))
|
|
27
88
|
|
|
28
89
|
|
|
29
90
|
def tensorleap_custom_metric(name: str,
|
|
@@ -31,8 +92,8 @@ def tensorleap_custom_metric(name: str,
|
|
|
31
92
|
compute_insights: Optional[Union[bool, Dict[str, bool]]] = None,
|
|
32
93
|
connects_to=None):
|
|
33
94
|
def decorating_function(user_function: Union[CustomCallableInterfaceMultiArgs,
|
|
34
|
-
|
|
35
|
-
|
|
95
|
+
CustomMultipleReturnCallableInterfaceMultiArgs,
|
|
96
|
+
ConfusionMatrixCallableInterfaceMultiArgs]):
|
|
36
97
|
for metric_handler in leap_binder.setup_container.metrics:
|
|
37
98
|
if metric_handler.metric_handler_data.name == name:
|
|
38
99
|
raise Exception(f'Metric with name {name} already exists. '
|
|
@@ -119,14 +180,31 @@ def tensorleap_custom_metric(name: str,
|
|
|
119
180
|
(f'tensorleap_custom_metric validation failed: '
|
|
120
181
|
f'compute_insights should be boolean. Got {type(compute_insights)}.')
|
|
121
182
|
|
|
122
|
-
|
|
123
183
|
def inner(*args, **kwargs):
|
|
124
184
|
_validate_input_args(*args, **kwargs)
|
|
125
185
|
result = user_function(*args, **kwargs)
|
|
126
186
|
_validate_result(result)
|
|
127
187
|
return result
|
|
128
188
|
|
|
129
|
-
|
|
189
|
+
def mapping_inner(*args, **kwargs):
|
|
190
|
+
user_unique_name = mapping_inner.name
|
|
191
|
+
if 'user_unique_name' in kwargs:
|
|
192
|
+
user_unique_name = kwargs['user_unique_name']
|
|
193
|
+
|
|
194
|
+
ordered_connections = [kwargs[n] for n in mapping_inner.arg_names if n in kwargs]
|
|
195
|
+
ordered_connections = list(args) + ordered_connections
|
|
196
|
+
_add_mapping_connection(user_unique_name, ordered_connections, mapping_inner.arg_names,
|
|
197
|
+
mapping_inner.name, NodeMappingType.Metric)
|
|
198
|
+
|
|
199
|
+
return None
|
|
200
|
+
|
|
201
|
+
mapping_inner.arg_names = leap_binder.setup_container.metrics[-1].metric_handler_data.arg_names
|
|
202
|
+
mapping_inner.name = name
|
|
203
|
+
|
|
204
|
+
if os.environ.get(mapping_runtime_mode_env_var_mame):
|
|
205
|
+
return mapping_inner
|
|
206
|
+
else:
|
|
207
|
+
return inner
|
|
130
208
|
|
|
131
209
|
return decorating_function
|
|
132
210
|
|
|
@@ -186,7 +264,25 @@ def tensorleap_custom_visualizer(name: str, visualizer_type: LeapDataType,
|
|
|
186
264
|
_validate_result(result)
|
|
187
265
|
return result
|
|
188
266
|
|
|
189
|
-
|
|
267
|
+
def mapping_inner(*args, **kwargs):
|
|
268
|
+
user_unique_name = mapping_inner.name
|
|
269
|
+
if 'user_unique_name' in kwargs:
|
|
270
|
+
user_unique_name = kwargs['user_unique_name']
|
|
271
|
+
|
|
272
|
+
ordered_connections = [kwargs[n] for n in mapping_inner.arg_names if n in kwargs]
|
|
273
|
+
ordered_connections = list(args) + ordered_connections
|
|
274
|
+
_add_mapping_connection(user_unique_name, ordered_connections, mapping_inner.arg_names,
|
|
275
|
+
mapping_inner.name, NodeMappingType.Visualizer)
|
|
276
|
+
|
|
277
|
+
return None
|
|
278
|
+
|
|
279
|
+
mapping_inner.arg_names = leap_binder.setup_container.visualizers[-1].visualizer_handler_data.arg_names
|
|
280
|
+
mapping_inner.name = name
|
|
281
|
+
|
|
282
|
+
if os.environ.get(mapping_runtime_mode_env_var_mame):
|
|
283
|
+
return mapping_inner
|
|
284
|
+
else:
|
|
285
|
+
return inner
|
|
190
286
|
|
|
191
287
|
return decorating_function
|
|
192
288
|
|
|
@@ -340,7 +436,21 @@ def tensorleap_input_encoder(name: str, channel_dim=-1, model_input_index=None):
|
|
|
340
436
|
node_mapping_type = NodeMappingType(f'Input{str(model_input_index)}')
|
|
341
437
|
inner.node_mapping = NodeMapping(name, node_mapping_type)
|
|
342
438
|
|
|
343
|
-
|
|
439
|
+
|
|
440
|
+
def mapping_inner(*args, **kwargs):
|
|
441
|
+
class TempMapping:
|
|
442
|
+
pass
|
|
443
|
+
ret = TempMapping()
|
|
444
|
+
ret.node_mapping = mapping_inner.node_mapping
|
|
445
|
+
|
|
446
|
+
return ret
|
|
447
|
+
|
|
448
|
+
mapping_inner.node_mapping = NodeMapping(name, node_mapping_type)
|
|
449
|
+
|
|
450
|
+
if os.environ.get(mapping_runtime_mode_env_var_mame):
|
|
451
|
+
return mapping_inner
|
|
452
|
+
else:
|
|
453
|
+
return inner
|
|
344
454
|
|
|
345
455
|
return decorating_function
|
|
346
456
|
|
|
@@ -382,9 +492,20 @@ def tensorleap_gt_encoder(name: str):
|
|
|
382
492
|
|
|
383
493
|
inner.node_mapping = NodeMapping(name, NodeMappingType.GroundTruth)
|
|
384
494
|
|
|
385
|
-
|
|
495
|
+
def mapping_inner(*args, **kwargs):
|
|
496
|
+
class TempMapping:
|
|
497
|
+
pass
|
|
498
|
+
ret = TempMapping()
|
|
499
|
+
ret.node_mapping = mapping_inner.node_mapping
|
|
500
|
+
|
|
501
|
+
return ret
|
|
386
502
|
|
|
503
|
+
mapping_inner.node_mapping = NodeMapping(name, NodeMappingType.GroundTruth)
|
|
387
504
|
|
|
505
|
+
if os.environ.get(mapping_runtime_mode_env_var_mame):
|
|
506
|
+
return mapping_inner
|
|
507
|
+
else:
|
|
508
|
+
return inner
|
|
388
509
|
|
|
389
510
|
return decorating_function
|
|
390
511
|
|
|
@@ -440,7 +561,25 @@ def tensorleap_custom_loss(name: str, connects_to=None):
|
|
|
440
561
|
_validate_result(result)
|
|
441
562
|
return result
|
|
442
563
|
|
|
443
|
-
|
|
564
|
+
def mapping_inner(*args, **kwargs):
|
|
565
|
+
user_unique_name = mapping_inner.name
|
|
566
|
+
if 'user_unique_name' in kwargs:
|
|
567
|
+
user_unique_name = kwargs['user_unique_name']
|
|
568
|
+
|
|
569
|
+
ordered_connections = [kwargs[n] for n in mapping_inner.arg_names if n in kwargs]
|
|
570
|
+
ordered_connections = list(args) + ordered_connections
|
|
571
|
+
_add_mapping_connection(user_unique_name, ordered_connections, mapping_inner.arg_names,
|
|
572
|
+
mapping_inner.name, NodeMappingType.CustomLoss)
|
|
573
|
+
|
|
574
|
+
return None
|
|
575
|
+
|
|
576
|
+
mapping_inner.arg_names = leap_binder.setup_container.custom_loss_handlers[-1].custom_loss_handler_data.arg_names
|
|
577
|
+
mapping_inner.name = name
|
|
578
|
+
|
|
579
|
+
if os.environ.get(mapping_runtime_mode_env_var_mame):
|
|
580
|
+
return mapping_inner
|
|
581
|
+
else:
|
|
582
|
+
return inner
|
|
444
583
|
|
|
445
584
|
return decorating_function
|
|
446
585
|
|
code_loader/leaploader.py
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import importlib.util
|
|
3
3
|
import inspect
|
|
4
4
|
import io
|
|
5
|
+
import os
|
|
5
6
|
import sys
|
|
6
7
|
from contextlib import redirect_stdout
|
|
7
8
|
from functools import lru_cache
|
|
@@ -22,8 +23,9 @@ from code_loader.contract.responsedataclasses import DatasetIntegParseResult, Da
|
|
|
22
23
|
VisualizerInstance, PredictionTypeInstance, ModelSetup, CustomLayerInstance, MetricInstance, CustomLossInstance, \
|
|
23
24
|
EngineFileContract
|
|
24
25
|
from code_loader.inner_leap_binder import global_leap_binder
|
|
26
|
+
from code_loader.inner_leap_binder.leapbinder import mapping_runtime_mode_env_var_mame
|
|
25
27
|
from code_loader.leaploaderbase import LeapLoaderBase
|
|
26
|
-
from code_loader.utils import get_root_exception_file_and_line_number
|
|
28
|
+
from code_loader.utils import get_root_exception_file_and_line_number
|
|
27
29
|
|
|
28
30
|
|
|
29
31
|
class LeapLoader(LeapLoaderBase):
|
|
@@ -157,7 +159,23 @@ class LeapLoader(LeapLoaderBase):
|
|
|
157
159
|
stdout_steam = io.StringIO()
|
|
158
160
|
with redirect_stdout(stdout_steam):
|
|
159
161
|
try:
|
|
162
|
+
# generate mapping
|
|
163
|
+
os.environ[mapping_runtime_mode_env_var_mame] = 'TRUE'
|
|
160
164
|
self.exec_script()
|
|
165
|
+
mapping_connections = global_leap_binder.mapping_connections
|
|
166
|
+
del os.environ[mapping_runtime_mode_env_var_mame]
|
|
167
|
+
|
|
168
|
+
# init global leap binder
|
|
169
|
+
global_leap_binder.__init__()
|
|
170
|
+
self.exec_script.cache_clear()
|
|
171
|
+
|
|
172
|
+
# run parse without mapping
|
|
173
|
+
self.exec_script()
|
|
174
|
+
|
|
175
|
+
# set mapping connections
|
|
176
|
+
if not global_leap_binder.mapping_connections:
|
|
177
|
+
global_leap_binder.mapping_connections = mapping_connections
|
|
178
|
+
|
|
161
179
|
preprocess_test_payload = self._check_preprocess()
|
|
162
180
|
test_payloads.append(preprocess_test_payload)
|
|
163
181
|
handlers_test_payloads = self._check_handlers()
|
|
@@ -173,6 +191,8 @@ class LeapLoader(LeapLoaderBase):
|
|
|
173
191
|
general_error = f"Something went wrong. {repr(e.__cause__)} in file {file_name}, line_number: {line_number}\nStacktrace:\n{stacktrace}"
|
|
174
192
|
is_valid = False
|
|
175
193
|
|
|
194
|
+
|
|
195
|
+
|
|
176
196
|
print_log = stdout_steam.getvalue()
|
|
177
197
|
is_valid_for_model = bool(global_leap_binder.setup_container.custom_layers)
|
|
178
198
|
model_setup = self.get_model_setup_response()
|
|
@@ -477,18 +497,22 @@ class LeapLoader(LeapLoaderBase):
|
|
|
477
497
|
|
|
478
498
|
return converted_value, is_none
|
|
479
499
|
|
|
480
|
-
def _get_metadata(self, state: DataStateEnum, sample_id: Union[int, str]) -> Tuple[
|
|
481
|
-
Dict[str, Union[str, int, bool, float]], Dict[str, bool]]:
|
|
500
|
+
def _get_metadata(self, state: DataStateEnum, sample_id: Union[int, str]) -> Tuple[Dict[str, Union[str, int, bool, float]], Dict[str, bool]]:
|
|
482
501
|
result_agg = {}
|
|
483
502
|
is_none = {}
|
|
484
503
|
preprocess_result = self._preprocess_result()
|
|
485
504
|
preprocess_state = preprocess_result[state]
|
|
486
505
|
for handler in global_leap_binder.setup_container.metadata:
|
|
487
506
|
handler_result = handler.function(sample_id, preprocess_state)
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
507
|
+
if isinstance(handler_result, dict):
|
|
508
|
+
for single_metadata_name, single_metadata_result in handler_result.items():
|
|
509
|
+
handler_name = f'{handler.name}_{single_metadata_name}'
|
|
510
|
+
result_agg[handler_name], is_none[handler_name] = self._convert_metadata_to_correct_type(
|
|
511
|
+
handler_name, single_metadata_result)
|
|
512
|
+
else:
|
|
513
|
+
handler_name = handler.name
|
|
514
|
+
result_agg[handler_name], is_none[handler_name] = self._convert_metadata_to_correct_type(
|
|
515
|
+
handler_name, handler_result)
|
|
492
516
|
|
|
493
517
|
return result_agg, is_none
|
|
494
518
|
|
code_loader/utils.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import sys
|
|
2
2
|
from pathlib import Path
|
|
3
3
|
from types import TracebackType
|
|
4
|
-
from typing import List, Union, Tuple, Any
|
|
4
|
+
from typing import List, Union, Tuple, Any
|
|
5
5
|
import traceback
|
|
6
6
|
import numpy as np
|
|
7
7
|
import numpy.typing as npt
|
|
@@ -66,28 +66,3 @@ def rescale_min_max(image: npt.NDArray[np.float32]) -> npt.NDArray[np.float32]:
|
|
|
66
66
|
return image
|
|
67
67
|
|
|
68
68
|
|
|
69
|
-
def flatten(
|
|
70
|
-
value: Any,
|
|
71
|
-
*,
|
|
72
|
-
prefix: str = "",
|
|
73
|
-
list_token: str = "e",
|
|
74
|
-
) -> Iterator[Tuple[str, Any]]:
|
|
75
|
-
"""
|
|
76
|
-
Recursively walk `value` and yield (flat_key, leaf_value) pairs.
|
|
77
|
-
|
|
78
|
-
• Dicts → descend with new_prefix = f"{prefix}_{key}" (or just key if top level)
|
|
79
|
-
• Sequences → descend with new_prefix = f"{prefix}_{list_token}{idx}"
|
|
80
|
-
• Leaf scalars → yield the accumulated flat key and the scalar itself
|
|
81
|
-
"""
|
|
82
|
-
if isinstance(value, dict):
|
|
83
|
-
for k, v in value.items():
|
|
84
|
-
new_prefix = f"{prefix}_{k}" if prefix else k
|
|
85
|
-
yield from flatten(v, prefix=new_prefix, list_token=list_token)
|
|
86
|
-
|
|
87
|
-
elif isinstance(value, (list, tuple)):
|
|
88
|
-
for idx, v in enumerate(value):
|
|
89
|
-
new_prefix = f"{prefix}_{list_token}{idx}"
|
|
90
|
-
yield from flatten(v, prefix=new_prefix, list_token=list_token)
|
|
91
|
-
|
|
92
|
-
else: # primitive leaf (str, int, float, bool, None…)
|
|
93
|
-
yield prefix, value
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
LICENSE,sha256=qIwWjdspQeSMTtnFZBC8MuT-95L02FPvzRUdWFxrwJY,1067
|
|
2
2
|
code_loader/__init__.py,sha256=6MMWr0ObOU7hkqQKgOqp4Zp3I28L7joGC9iCbQYtAJg,241
|
|
3
3
|
code_loader/contract/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
code_loader/contract/datasetclasses.py,sha256=
|
|
4
|
+
code_loader/contract/datasetclasses.py,sha256=sNBHyfdg2uS3rL65kJVZjjNVbSXy0dTQMganldQjGNw,7969
|
|
5
5
|
code_loader/contract/enums.py,sha256=GEFkvUMXnCNt-GOoz7NJ9ecQZ2PPDettJNOsxsiM0wk,1622
|
|
6
6
|
code_loader/contract/exceptions.py,sha256=jWqu5i7t-0IG0jGRsKF4DjJdrsdpJjIYpUkN1F4RiyQ,51
|
|
7
7
|
code_loader/contract/mapping.py,sha256=e11h_sprwOyE32PcqgRq9JvyahQrPzwqgkhmbQLKLQY,1165
|
|
8
8
|
code_loader/contract/responsedataclasses.py,sha256=6-5DJkYBdXb3UB1eNidTTPPBIYxMjEoMdYDkp9VhH8o,4223
|
|
9
|
-
code_loader/contract/visualizer_classes.py,sha256=
|
|
9
|
+
code_loader/contract/visualizer_classes.py,sha256=_nlukRfW8QeQaQG7G5HfAUSeCuoqslB4xJS2AGI_Nz8,15156
|
|
10
10
|
code_loader/default_losses.py,sha256=NoOQym1106bDN5dcIk56Elr7ZG5quUHArqfP5-Nyxyo,1139
|
|
11
11
|
code_loader/default_metrics.py,sha256=v16Mrt2Ze1tXPgfKywGVdRSrkaK4CKLNQztN1UdVqIY,5010
|
|
12
12
|
code_loader/experiment_api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -20,14 +20,14 @@ code_loader/experiment_api/types.py,sha256=MY8xFARHwdVA7p4dxyhD60ShmttgTvb4qdp1o
|
|
|
20
20
|
code_loader/experiment_api/utils.py,sha256=XZHtxge12TS4H4-8PjV3sKuhp8Ud6ojAiIzTZJEqBqc,3304
|
|
21
21
|
code_loader/experiment_api/workingspace_config_utils.py,sha256=DLzXQCg4dgTV_YgaSbeTVzq-2ja_SQw4zi7LXwKL9cY,990
|
|
22
22
|
code_loader/inner_leap_binder/__init__.py,sha256=koOlJyMNYzGbEsoIbXathSmQ-L38N_pEXH_HvL7beXU,99
|
|
23
|
-
code_loader/inner_leap_binder/leapbinder.py,sha256=
|
|
24
|
-
code_loader/inner_leap_binder/leapbinder_decorators.py,sha256=
|
|
25
|
-
code_loader/leaploader.py,sha256=
|
|
23
|
+
code_loader/inner_leap_binder/leapbinder.py,sha256=FaX0kT-dEQJx4tS3LBfDxjf7Bi1LihkeEfLDHbyEbnM,31778
|
|
24
|
+
code_loader/inner_leap_binder/leapbinder_decorators.py,sha256=Yo7RGjwF5srcU7gW_TnJ3CtC4JvifGLUxmUoAOkrfYY,30068
|
|
25
|
+
code_loader/leaploader.py,sha256=LN7ngforPp7zGd6_1tONpi4AvOry-wTg7agH0D-gn1c,27233
|
|
26
26
|
code_loader/leaploaderbase.py,sha256=VH0vddRmkqLtcDlYPCO7hfz1_VbKo43lUdHDAbd4iJc,4198
|
|
27
|
-
code_loader/utils.py,sha256=
|
|
27
|
+
code_loader/utils.py,sha256=aw2i_fqW_ADjLB66FWZd9DfpCQ7mPdMyauROC5Nd51I,2197
|
|
28
28
|
code_loader/visualizers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
29
29
|
code_loader/visualizers/default_visualizers.py,sha256=669lBpLISLO6my5Qcgn1FLDDeZgHumPf252m4KHY4YM,2555
|
|
30
|
-
code_loader-1.0.
|
|
31
|
-
code_loader-1.0.
|
|
32
|
-
code_loader-1.0.
|
|
33
|
-
code_loader-1.0.
|
|
30
|
+
code_loader-1.0.99.dev2.dist-info/LICENSE,sha256=qIwWjdspQeSMTtnFZBC8MuT-95L02FPvzRUdWFxrwJY,1067
|
|
31
|
+
code_loader-1.0.99.dev2.dist-info/METADATA,sha256=lI9aBDOQpVho33xALJA8L16fRr5I_IRdJQbCCaeMB-Q,854
|
|
32
|
+
code_loader-1.0.99.dev2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
33
|
+
code_loader-1.0.99.dev2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|