code-loader 1.0.92.dev5__py3-none-any.whl → 1.0.93.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/visualizer_classes.py +2 -6
- code_loader/inner_leap_binder/leapbinder_decorators.py +152 -14
- code_loader-1.0.93.dev2.dist-info/LICENSE +21 -0
- {code_loader-1.0.92.dev5.dist-info → code_loader-1.0.93.dev2.dist-info}/METADATA +3 -3
- {code_loader-1.0.92.dev5.dist-info → code_loader-1.0.93.dev2.dist-info}/RECORD +7 -6
- {code_loader-1.0.92.dev5.dist-info → code_loader-1.0.93.dev2.dist-info}/WHEEL +1 -1
- /code_loader-1.0.92.dev5.dist-info/LICENSE → /LICENSE +0 -0
|
@@ -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')
|
|
@@ -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
|
|
@@ -16,14 +16,74 @@ from code_loader.contract.visualizer_classes import LeapImage, LeapImageMask, Le
|
|
|
16
16
|
LeapHorizontalBar, LeapImageWithBBox, LeapImageWithHeatmap
|
|
17
17
|
|
|
18
18
|
|
|
19
|
+
mapping_runtime_mode_env_var_mame = '__mapping_runtime_mode__'
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _add_mapping_connection(user_unique_name, connection_destinations, arg_names, name, node_mapping_type):
|
|
23
|
+
main_node_mapping = NodeMapping(name, node_mapping_type, user_unique_name, arg_names=arg_names)
|
|
24
|
+
node_inputs = {}
|
|
25
|
+
for arg_name, destination in zip(arg_names, connection_destinations):
|
|
26
|
+
node_inputs[arg_name] = destination.node_mapping
|
|
27
|
+
|
|
28
|
+
leap_binder.mapping_connections.append(NodeConnection(main_node_mapping, node_inputs))
|
|
29
|
+
|
|
30
|
+
|
|
19
31
|
def _add_mapping_connections(connects_to, arg_names, node_mapping_type, name):
|
|
20
32
|
for user_unique_name, connection_destinations in connects_to.items():
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
33
|
+
_add_mapping_connection(user_unique_name, connection_destinations, arg_names, name, node_mapping_type)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def tensorleap_load_model():
|
|
39
|
+
def decorating_function(load_model_func):
|
|
40
|
+
class TempMapping:
|
|
41
|
+
pass
|
|
42
|
+
|
|
43
|
+
def mapping_inner():
|
|
44
|
+
class ModelOutputPlaceholder:
|
|
45
|
+
def __init__(self):
|
|
46
|
+
self.node_mapping = NodeMapping('', NodeMappingType.Prediction0)
|
|
47
|
+
|
|
48
|
+
def __getitem__(self, key):
|
|
49
|
+
assert isinstance(key, int), \
|
|
50
|
+
f'Expected key to be an int, got {type(key)} instead.'
|
|
51
|
+
|
|
52
|
+
ret = TempMapping()
|
|
53
|
+
ret.node_mapping = NodeMapping('', NodeMappingType(f'Prediction{str(key)}'))
|
|
54
|
+
return ret
|
|
55
|
+
|
|
56
|
+
class ModelPlaceholder:
|
|
57
|
+
#keras interface
|
|
58
|
+
def __call__(self, arg):
|
|
59
|
+
if isinstance(arg, list):
|
|
60
|
+
for i, elem in enumerate(arg):
|
|
61
|
+
elem.node_mapping.type = NodeMappingType[f'Input{str(i)}']
|
|
62
|
+
else:
|
|
63
|
+
arg.node_mapping.type = NodeMappingType.Input0
|
|
64
|
+
|
|
65
|
+
return ModelOutputPlaceholder()
|
|
66
|
+
|
|
67
|
+
# onnx runtime interface
|
|
68
|
+
def run(self, output_names, input_dict):
|
|
69
|
+
assert output_names is None
|
|
70
|
+
assert isinstance(input_dict, dict), \
|
|
71
|
+
f'Expected input_dict to be a dict, got {type(input_dict)} instead.'
|
|
72
|
+
for i, elem in enumerate(input_dict.values()):
|
|
73
|
+
elem.node_mapping.type = NodeMappingType[f'Input{str(i)}']
|
|
74
|
+
|
|
75
|
+
return ModelOutputPlaceholder()
|
|
76
|
+
|
|
77
|
+
return ModelPlaceholder()
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
if os.environ[mapping_runtime_mode_env_var_mame]:
|
|
81
|
+
return mapping_inner
|
|
82
|
+
else:
|
|
83
|
+
return load_model_func
|
|
84
|
+
|
|
85
|
+
return decorating_function
|
|
25
86
|
|
|
26
|
-
leap_binder.mapping_connections.append(NodeConnection(main_node_mapping, node_inputs))
|
|
27
87
|
|
|
28
88
|
|
|
29
89
|
def tensorleap_custom_metric(name: str,
|
|
@@ -31,8 +91,8 @@ def tensorleap_custom_metric(name: str,
|
|
|
31
91
|
compute_insights: Optional[Union[bool, Dict[str, bool]]] = None,
|
|
32
92
|
connects_to=None):
|
|
33
93
|
def decorating_function(user_function: Union[CustomCallableInterfaceMultiArgs,
|
|
34
|
-
|
|
35
|
-
|
|
94
|
+
CustomMultipleReturnCallableInterfaceMultiArgs,
|
|
95
|
+
ConfusionMatrixCallableInterfaceMultiArgs]):
|
|
36
96
|
for metric_handler in leap_binder.setup_container.metrics:
|
|
37
97
|
if metric_handler.metric_handler_data.name == name:
|
|
38
98
|
raise Exception(f'Metric with name {name} already exists. '
|
|
@@ -119,14 +179,31 @@ def tensorleap_custom_metric(name: str,
|
|
|
119
179
|
(f'tensorleap_custom_metric validation failed: '
|
|
120
180
|
f'compute_insights should be boolean. Got {type(compute_insights)}.')
|
|
121
181
|
|
|
122
|
-
|
|
123
182
|
def inner(*args, **kwargs):
|
|
124
183
|
_validate_input_args(*args, **kwargs)
|
|
125
184
|
result = user_function(*args, **kwargs)
|
|
126
185
|
_validate_result(result)
|
|
127
186
|
return result
|
|
128
187
|
|
|
129
|
-
|
|
188
|
+
def mapping_inner(*args, **kwargs):
|
|
189
|
+
user_unique_name = mapping_inner.name
|
|
190
|
+
if 'user_unique_name' in kwargs:
|
|
191
|
+
user_unique_name = kwargs['user_unique_name']
|
|
192
|
+
|
|
193
|
+
ordered_connections = [kwargs[n] for n in mapping_inner.arg_names if n in kwargs]
|
|
194
|
+
ordered_connections = list(args) + ordered_connections
|
|
195
|
+
_add_mapping_connection(user_unique_name, ordered_connections, mapping_inner.arg_names,
|
|
196
|
+
mapping_inner.name, NodeMappingType.Metric)
|
|
197
|
+
|
|
198
|
+
return None
|
|
199
|
+
|
|
200
|
+
mapping_inner.arg_names = leap_binder.setup_container.metrics[-1].metric_handler_data.arg_names
|
|
201
|
+
mapping_inner.name = name
|
|
202
|
+
|
|
203
|
+
if os.environ[mapping_runtime_mode_env_var_mame]:
|
|
204
|
+
return mapping_inner
|
|
205
|
+
else:
|
|
206
|
+
return inner
|
|
130
207
|
|
|
131
208
|
return decorating_function
|
|
132
209
|
|
|
@@ -186,7 +263,25 @@ def tensorleap_custom_visualizer(name: str, visualizer_type: LeapDataType,
|
|
|
186
263
|
_validate_result(result)
|
|
187
264
|
return result
|
|
188
265
|
|
|
189
|
-
|
|
266
|
+
def mapping_inner(*args, **kwargs):
|
|
267
|
+
user_unique_name = mapping_inner.name
|
|
268
|
+
if 'user_unique_name' in kwargs:
|
|
269
|
+
user_unique_name = kwargs['user_unique_name']
|
|
270
|
+
|
|
271
|
+
ordered_connections = [kwargs[n] for n in mapping_inner.arg_names if n in kwargs]
|
|
272
|
+
ordered_connections = list(args) + ordered_connections
|
|
273
|
+
_add_mapping_connection(user_unique_name, ordered_connections, mapping_inner.arg_names,
|
|
274
|
+
mapping_inner.name, NodeMappingType.Visualizer)
|
|
275
|
+
|
|
276
|
+
return None
|
|
277
|
+
|
|
278
|
+
mapping_inner.arg_names = leap_binder.setup_container.visualizers[-1].visualizer_handler_data.arg_names
|
|
279
|
+
mapping_inner.name = name
|
|
280
|
+
|
|
281
|
+
if os.environ[mapping_runtime_mode_env_var_mame]:
|
|
282
|
+
return mapping_inner
|
|
283
|
+
else:
|
|
284
|
+
return inner
|
|
190
285
|
|
|
191
286
|
return decorating_function
|
|
192
287
|
|
|
@@ -340,7 +435,21 @@ def tensorleap_input_encoder(name: str, channel_dim=-1, model_input_index=None):
|
|
|
340
435
|
node_mapping_type = NodeMappingType(f'Input{str(model_input_index)}')
|
|
341
436
|
inner.node_mapping = NodeMapping(name, node_mapping_type)
|
|
342
437
|
|
|
343
|
-
|
|
438
|
+
|
|
439
|
+
def mapping_inner(*args, **kwargs):
|
|
440
|
+
class TempMapping:
|
|
441
|
+
pass
|
|
442
|
+
ret = TempMapping()
|
|
443
|
+
ret.node_mapping = mapping_inner.node_mapping
|
|
444
|
+
|
|
445
|
+
return ret
|
|
446
|
+
|
|
447
|
+
mapping_inner.node_mapping = NodeMapping(name, node_mapping_type)
|
|
448
|
+
|
|
449
|
+
if os.environ[mapping_runtime_mode_env_var_mame]:
|
|
450
|
+
return mapping_inner
|
|
451
|
+
else:
|
|
452
|
+
return inner
|
|
344
453
|
|
|
345
454
|
return decorating_function
|
|
346
455
|
|
|
@@ -382,9 +491,20 @@ def tensorleap_gt_encoder(name: str):
|
|
|
382
491
|
|
|
383
492
|
inner.node_mapping = NodeMapping(name, NodeMappingType.GroundTruth)
|
|
384
493
|
|
|
385
|
-
|
|
494
|
+
def mapping_inner(*args, **kwargs):
|
|
495
|
+
class TempMapping:
|
|
496
|
+
pass
|
|
497
|
+
ret = TempMapping()
|
|
498
|
+
ret.node_mapping = mapping_inner.node_mapping
|
|
499
|
+
|
|
500
|
+
return ret
|
|
386
501
|
|
|
502
|
+
mapping_inner.node_mapping = NodeMapping(name, NodeMappingType.GroundTruth)
|
|
387
503
|
|
|
504
|
+
if os.environ[mapping_runtime_mode_env_var_mame]:
|
|
505
|
+
return mapping_inner
|
|
506
|
+
else:
|
|
507
|
+
return inner
|
|
388
508
|
|
|
389
509
|
return decorating_function
|
|
390
510
|
|
|
@@ -440,7 +560,25 @@ def tensorleap_custom_loss(name: str, connects_to=None):
|
|
|
440
560
|
_validate_result(result)
|
|
441
561
|
return result
|
|
442
562
|
|
|
443
|
-
|
|
563
|
+
def mapping_inner(*args, **kwargs):
|
|
564
|
+
user_unique_name = mapping_inner.name
|
|
565
|
+
if 'user_unique_name' in kwargs:
|
|
566
|
+
user_unique_name = kwargs['user_unique_name']
|
|
567
|
+
|
|
568
|
+
ordered_connections = [kwargs[n] for n in mapping_inner.arg_names if n in kwargs]
|
|
569
|
+
ordered_connections = list(args) + ordered_connections
|
|
570
|
+
_add_mapping_connection(user_unique_name, ordered_connections, mapping_inner.arg_names,
|
|
571
|
+
mapping_inner.name, NodeMappingType.CustomLoss)
|
|
572
|
+
|
|
573
|
+
return None
|
|
574
|
+
|
|
575
|
+
mapping_inner.arg_names = leap_binder.setup_container.custom_loss_handlers[-1].custom_loss_handler_data.arg_names
|
|
576
|
+
mapping_inner.name = name
|
|
577
|
+
|
|
578
|
+
if os.environ[mapping_runtime_mode_env_var_mame]:
|
|
579
|
+
return mapping_inner
|
|
580
|
+
else:
|
|
581
|
+
return inner
|
|
444
582
|
|
|
445
583
|
return decorating_function
|
|
446
584
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 TensorLeap
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
2
|
Name: code-loader
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.93.dev2
|
|
4
4
|
Summary:
|
|
5
|
+
Home-page: https://github.com/tensorleap/code-loader
|
|
5
6
|
License: MIT
|
|
6
7
|
Author: dorhar
|
|
7
8
|
Author-email: doron.harnoy@tensorleap.ai
|
|
@@ -16,7 +17,6 @@ Requires-Dist: numpy (>=1.22.3,<2.0.0)
|
|
|
16
17
|
Requires-Dist: psutil (>=5.9.5,<6.0.0)
|
|
17
18
|
Requires-Dist: pyyaml (>=6.0.2,<7.0.0)
|
|
18
19
|
Requires-Dist: requests (>=2.32.3,<3.0.0)
|
|
19
|
-
Project-URL: Homepage, https://github.com/tensorleap/code-loader
|
|
20
20
|
Project-URL: Repository, https://github.com/tensorleap/code-loader
|
|
21
21
|
Description-Content-Type: text/markdown
|
|
22
22
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
LICENSE,sha256=qIwWjdspQeSMTtnFZBC8MuT-95L02FPvzRUdWFxrwJY,1067
|
|
1
2
|
code_loader/__init__.py,sha256=6MMWr0ObOU7hkqQKgOqp4Zp3I28L7joGC9iCbQYtAJg,241
|
|
2
3
|
code_loader/contract/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
4
|
code_loader/contract/datasetclasses.py,sha256=ZN6XC-tg0qaT-GF4YiV2SsM2dUQW4fc1akLF-J4YT0w,7964
|
|
@@ -5,7 +6,7 @@ code_loader/contract/enums.py,sha256=GEFkvUMXnCNt-GOoz7NJ9ecQZ2PPDettJNOsxsiM0wk
|
|
|
5
6
|
code_loader/contract/exceptions.py,sha256=jWqu5i7t-0IG0jGRsKF4DjJdrsdpJjIYpUkN1F4RiyQ,51
|
|
6
7
|
code_loader/contract/mapping.py,sha256=e11h_sprwOyE32PcqgRq9JvyahQrPzwqgkhmbQLKLQY,1165
|
|
7
8
|
code_loader/contract/responsedataclasses.py,sha256=6-5DJkYBdXb3UB1eNidTTPPBIYxMjEoMdYDkp9VhH8o,4223
|
|
8
|
-
code_loader/contract/visualizer_classes.py,sha256=
|
|
9
|
+
code_loader/contract/visualizer_classes.py,sha256=_nlukRfW8QeQaQG7G5HfAUSeCuoqslB4xJS2AGI_Nz8,15156
|
|
9
10
|
code_loader/default_losses.py,sha256=NoOQym1106bDN5dcIk56Elr7ZG5quUHArqfP5-Nyxyo,1139
|
|
10
11
|
code_loader/default_metrics.py,sha256=v16Mrt2Ze1tXPgfKywGVdRSrkaK4CKLNQztN1UdVqIY,5010
|
|
11
12
|
code_loader/experiment_api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -20,13 +21,13 @@ code_loader/experiment_api/utils.py,sha256=XZHtxge12TS4H4-8PjV3sKuhp8Ud6ojAiIzTZ
|
|
|
20
21
|
code_loader/experiment_api/workingspace_config_utils.py,sha256=DLzXQCg4dgTV_YgaSbeTVzq-2ja_SQw4zi7LXwKL9cY,990
|
|
21
22
|
code_loader/inner_leap_binder/__init__.py,sha256=koOlJyMNYzGbEsoIbXathSmQ-L38N_pEXH_HvL7beXU,99
|
|
22
23
|
code_loader/inner_leap_binder/leapbinder.py,sha256=mRg5ofWNbUkRsIafaz7i7NKi-1USgeAuNTIBxASSMcw,31713
|
|
23
|
-
code_loader/inner_leap_binder/leapbinder_decorators.py,sha256=
|
|
24
|
+
code_loader/inner_leap_binder/leapbinder_decorators.py,sha256=TpAgM6VTdBN4yIFCZaPXxO4vB2QgUmeo0rICqBA_f-U,29764
|
|
24
25
|
code_loader/leaploader.py,sha256=GGHZzovqGsM6oY14pwyL35LeOmdRfjVuhhY2ZqlYKaM,26481
|
|
25
26
|
code_loader/leaploaderbase.py,sha256=VH0vddRmkqLtcDlYPCO7hfz1_VbKo43lUdHDAbd4iJc,4198
|
|
26
27
|
code_loader/utils.py,sha256=aw2i_fqW_ADjLB66FWZd9DfpCQ7mPdMyauROC5Nd51I,2197
|
|
27
28
|
code_loader/visualizers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
28
29
|
code_loader/visualizers/default_visualizers.py,sha256=669lBpLISLO6my5Qcgn1FLDDeZgHumPf252m4KHY4YM,2555
|
|
29
|
-
code_loader-1.0.
|
|
30
|
-
code_loader-1.0.
|
|
31
|
-
code_loader-1.0.
|
|
32
|
-
code_loader-1.0.
|
|
30
|
+
code_loader-1.0.93.dev2.dist-info/LICENSE,sha256=qIwWjdspQeSMTtnFZBC8MuT-95L02FPvzRUdWFxrwJY,1067
|
|
31
|
+
code_loader-1.0.93.dev2.dist-info/METADATA,sha256=MySowabFif2EsHj8v1oZzNOth38H2U_PKieGriC_pxQ,854
|
|
32
|
+
code_loader-1.0.93.dev2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
33
|
+
code_loader-1.0.93.dev2.dist-info/RECORD,,
|
|
File without changes
|