code-loader 1.0.135__tar.gz → 1.0.137__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.
Potentially problematic release.
This version of code-loader might be problematic. Click here for more details.
- {code_loader-1.0.135 → code_loader-1.0.137}/PKG-INFO +1 -1
- {code_loader-1.0.135 → code_loader-1.0.137}/code_loader/inner_leap_binder/leapbinder_decorators.py +39 -9
- {code_loader-1.0.135 → code_loader-1.0.137}/code_loader/leaploader.py +1 -1
- {code_loader-1.0.135 → code_loader-1.0.137}/pyproject.toml +1 -1
- {code_loader-1.0.135 → code_loader-1.0.137}/LICENSE +0 -0
- {code_loader-1.0.135 → code_loader-1.0.137}/README.md +0 -0
- {code_loader-1.0.135 → code_loader-1.0.137}/code_loader/__init__.py +0 -0
- {code_loader-1.0.135 → code_loader-1.0.137}/code_loader/contract/__init__.py +0 -0
- {code_loader-1.0.135 → code_loader-1.0.137}/code_loader/contract/datasetclasses.py +0 -0
- {code_loader-1.0.135 → code_loader-1.0.137}/code_loader/contract/enums.py +0 -0
- {code_loader-1.0.135 → code_loader-1.0.137}/code_loader/contract/exceptions.py +0 -0
- {code_loader-1.0.135 → code_loader-1.0.137}/code_loader/contract/mapping.py +0 -0
- {code_loader-1.0.135 → code_loader-1.0.137}/code_loader/contract/responsedataclasses.py +0 -0
- {code_loader-1.0.135 → code_loader-1.0.137}/code_loader/contract/visualizer_classes.py +0 -0
- {code_loader-1.0.135 → code_loader-1.0.137}/code_loader/default_losses.py +0 -0
- {code_loader-1.0.135 → code_loader-1.0.137}/code_loader/default_metrics.py +0 -0
- {code_loader-1.0.135 → code_loader-1.0.137}/code_loader/experiment_api/__init__.py +0 -0
- {code_loader-1.0.135 → code_loader-1.0.137}/code_loader/experiment_api/api.py +0 -0
- {code_loader-1.0.135 → code_loader-1.0.137}/code_loader/experiment_api/cli_config_utils.py +0 -0
- {code_loader-1.0.135 → code_loader-1.0.137}/code_loader/experiment_api/client.py +0 -0
- {code_loader-1.0.135 → code_loader-1.0.137}/code_loader/experiment_api/epoch.py +0 -0
- {code_loader-1.0.135 → code_loader-1.0.137}/code_loader/experiment_api/experiment.py +0 -0
- {code_loader-1.0.135 → code_loader-1.0.137}/code_loader/experiment_api/experiment_context.py +0 -0
- {code_loader-1.0.135 → code_loader-1.0.137}/code_loader/experiment_api/types.py +0 -0
- {code_loader-1.0.135 → code_loader-1.0.137}/code_loader/experiment_api/utils.py +0 -0
- {code_loader-1.0.135 → code_loader-1.0.137}/code_loader/experiment_api/workingspace_config_utils.py +0 -0
- {code_loader-1.0.135 → code_loader-1.0.137}/code_loader/inner_leap_binder/__init__.py +0 -0
- {code_loader-1.0.135 → code_loader-1.0.137}/code_loader/inner_leap_binder/leapbinder.py +0 -0
- {code_loader-1.0.135 → code_loader-1.0.137}/code_loader/leaploaderbase.py +0 -0
- {code_loader-1.0.135 → code_loader-1.0.137}/code_loader/mixpanel_tracker.py +0 -0
- {code_loader-1.0.135 → code_loader-1.0.137}/code_loader/plot_functions/__init__.py +0 -0
- {code_loader-1.0.135 → code_loader-1.0.137}/code_loader/plot_functions/plot_functions.py +0 -0
- {code_loader-1.0.135 → code_loader-1.0.137}/code_loader/plot_functions/visualize.py +0 -0
- {code_loader-1.0.135 → code_loader-1.0.137}/code_loader/utils.py +0 -0
- {code_loader-1.0.135 → code_loader-1.0.137}/code_loader/visualizers/__init__.py +0 -0
- {code_loader-1.0.135 → code_loader-1.0.137}/code_loader/visualizers/default_visualizers.py +0 -0
{code_loader-1.0.135 → code_loader-1.0.137}/code_loader/inner_leap_binder/leapbinder_decorators.py
RENAMED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# mypy: ignore-errors
|
|
2
2
|
import os
|
|
3
|
+
from collections import defaultdict
|
|
3
4
|
from functools import lru_cache
|
|
5
|
+
from pathlib import Path
|
|
4
6
|
from typing import Optional, Union, Callable, List, Dict
|
|
5
7
|
|
|
6
8
|
import numpy as np
|
|
@@ -11,7 +13,7 @@ from code_loader.contract.datasetclasses import CustomCallableInterfaceMultiArgs
|
|
|
11
13
|
VisualizerCallableInterface, MetadataSectionCallableInterface, PreprocessResponse, SectionCallableInterface, \
|
|
12
14
|
ConfusionMatrixElement, SamplePreprocessResponse, PredictionTypeHandler, InstanceCallableInterface, ElementInstance, \
|
|
13
15
|
InstanceLengthCallableInterface
|
|
14
|
-
from code_loader.contract.enums import MetricDirection, LeapDataType, DatasetMetadataType
|
|
16
|
+
from code_loader.contract.enums import MetricDirection, LeapDataType, DatasetMetadataType, DataStateType
|
|
15
17
|
from code_loader import leap_binder
|
|
16
18
|
from code_loader.contract.mapping import NodeMapping, NodeMappingType, NodeConnection
|
|
17
19
|
from code_loader.contract.visualizer_classes import LeapImage, LeapImageMask, LeapTextMask, LeapText, LeapGraph, \
|
|
@@ -43,7 +45,7 @@ def _add_mapping_connections(connects_to, arg_names, node_mapping_type, name):
|
|
|
43
45
|
_add_mapping_connection(user_unique_name, connection_destinations, arg_names, name, node_mapping_type)
|
|
44
46
|
|
|
45
47
|
|
|
46
|
-
def
|
|
48
|
+
def tensorleap_integration_test():
|
|
47
49
|
def decorating_function(integration_test_function: Callable):
|
|
48
50
|
leap_binder.integration_test_func = integration_test_function
|
|
49
51
|
|
|
@@ -55,10 +57,19 @@ def integration_test():
|
|
|
55
57
|
|
|
56
58
|
try:
|
|
57
59
|
os.environ[mapping_runtime_mode_env_var_mame] = 'True'
|
|
58
|
-
integration_test_function(None,
|
|
60
|
+
integration_test_function(None, PreprocessResponse(state=DataStateType.training, length=0))
|
|
59
61
|
except Exception as e:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
import traceback
|
|
63
|
+
first_tb = traceback.extract_tb(e.__traceback__)[-1]
|
|
64
|
+
file_name = Path(first_tb.filename).name
|
|
65
|
+
line_number = first_tb.lineno
|
|
66
|
+
if isinstance(e, TypeError) and 'is not subscriptable' in str(e):
|
|
67
|
+
print(f'Invalid integration code. File {file_name}, line {line_number}: '
|
|
68
|
+
f'Please remove this indexing operation usage from the integration test code.')
|
|
69
|
+
else:
|
|
70
|
+
print(f'Invalid integration code. File {file_name}, line {line_number}: '
|
|
71
|
+
f'Integration test is only allowed to call Tensorleap decorators. '
|
|
72
|
+
f'Ensure any arithmetics, external library use, Python logic is placed within Tensorleap decoders')
|
|
62
73
|
finally:
|
|
63
74
|
if mapping_runtime_mode_env_var_mame in os.environ:
|
|
64
75
|
del os.environ[mapping_runtime_mode_env_var_mame]
|
|
@@ -77,7 +88,7 @@ def _safe_get_item(key):
|
|
|
77
88
|
except ValueError:
|
|
78
89
|
raise Exception(f'Tensorleap currently supports models with no more then 10 inputs')
|
|
79
90
|
|
|
80
|
-
def tensorleap_load_model(prediction_types: Optional[List[PredictionTypeHandler]] =
|
|
91
|
+
def tensorleap_load_model(prediction_types: Optional[List[PredictionTypeHandler]] = []):
|
|
81
92
|
for i, prediction_type in enumerate(prediction_types):
|
|
82
93
|
leap_binder.add_prediction(prediction_type.name, prediction_type.labels, prediction_type.channel_dim, i)
|
|
83
94
|
|
|
@@ -232,9 +243,11 @@ def tensorleap_custom_metric(name: str,
|
|
|
232
243
|
direction: Union[MetricDirection, Dict[str, MetricDirection]] = MetricDirection.Downward,
|
|
233
244
|
compute_insights: Optional[Union[bool, Dict[str, bool]]] = None,
|
|
234
245
|
connects_to=None):
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
246
|
+
name_to_unique_name = defaultdict(set)
|
|
247
|
+
|
|
248
|
+
def decorating_function(
|
|
249
|
+
user_function: Union[CustomCallableInterfaceMultiArgs, CustomMultipleReturnCallableInterfaceMultiArgs,
|
|
250
|
+
ConfusionMatrixCallableInterfaceMultiArgs]):
|
|
238
251
|
for metric_handler in leap_binder.setup_container.metrics:
|
|
239
252
|
if metric_handler.metric_handler_data.name == name:
|
|
240
253
|
raise Exception(f'Metric with name {name} already exists. '
|
|
@@ -354,6 +367,11 @@ def tensorleap_custom_metric(name: str,
|
|
|
354
367
|
|
|
355
368
|
ordered_connections = [kwargs[n] for n in mapping_inner.arg_names if n in kwargs]
|
|
356
369
|
ordered_connections = list(args) + ordered_connections
|
|
370
|
+
|
|
371
|
+
if user_unique_name in name_to_unique_name[mapping_inner.name]:
|
|
372
|
+
user_unique_name = f'{user_unique_name}_{len(name_to_unique_name[mapping_inner.name])}'
|
|
373
|
+
name_to_unique_name[mapping_inner.name].add(user_unique_name)
|
|
374
|
+
|
|
357
375
|
_add_mapping_connection(user_unique_name, ordered_connections, mapping_inner.arg_names,
|
|
358
376
|
mapping_inner.name, NodeMappingType.Metric)
|
|
359
377
|
|
|
@@ -376,6 +394,8 @@ def tensorleap_custom_metric(name: str,
|
|
|
376
394
|
def tensorleap_custom_visualizer(name: str, visualizer_type: LeapDataType,
|
|
377
395
|
heatmap_function: Optional[Callable[..., npt.NDArray[np.float32]]] = None,
|
|
378
396
|
connects_to=None):
|
|
397
|
+
name_to_unique_name = defaultdict(set)
|
|
398
|
+
|
|
379
399
|
def decorating_function(user_function: VisualizerCallableInterface):
|
|
380
400
|
for viz_handler in leap_binder.setup_container.visualizers:
|
|
381
401
|
if viz_handler.visualizer_handler_data.name == name:
|
|
@@ -452,6 +472,10 @@ def tensorleap_custom_visualizer(name: str, visualizer_type: LeapDataType,
|
|
|
452
472
|
if 'user_unique_name' in kwargs:
|
|
453
473
|
user_unique_name = kwargs['user_unique_name']
|
|
454
474
|
|
|
475
|
+
if user_unique_name in name_to_unique_name[mapping_inner.name]:
|
|
476
|
+
user_unique_name = f'{user_unique_name}_{len(name_to_unique_name[mapping_inner.name])}'
|
|
477
|
+
name_to_unique_name[mapping_inner.name].add(user_unique_name)
|
|
478
|
+
|
|
455
479
|
ordered_connections = [kwargs[n] for n in mapping_inner.arg_names if n in kwargs]
|
|
456
480
|
ordered_connections = list(args) + ordered_connections
|
|
457
481
|
_add_mapping_connection(user_unique_name, ordered_connections, mapping_inner.arg_names,
|
|
@@ -974,6 +998,8 @@ def tensorleap_gt_encoder(name: str):
|
|
|
974
998
|
|
|
975
999
|
|
|
976
1000
|
def tensorleap_custom_loss(name: str, connects_to=None):
|
|
1001
|
+
name_to_unique_name = defaultdict(set)
|
|
1002
|
+
|
|
977
1003
|
def decorating_function(user_function: CustomCallableInterface):
|
|
978
1004
|
for loss_handler in leap_binder.setup_container.custom_loss_handlers:
|
|
979
1005
|
if loss_handler.custom_loss_handler_data.name == name:
|
|
@@ -1042,6 +1068,10 @@ def tensorleap_custom_loss(name: str, connects_to=None):
|
|
|
1042
1068
|
if 'user_unique_name' in kwargs:
|
|
1043
1069
|
user_unique_name = kwargs['user_unique_name']
|
|
1044
1070
|
|
|
1071
|
+
if user_unique_name in name_to_unique_name[mapping_inner.name]:
|
|
1072
|
+
user_unique_name = f'{user_unique_name}_{len(name_to_unique_name[mapping_inner.name])}'
|
|
1073
|
+
name_to_unique_name[mapping_inner.name].add(user_unique_name)
|
|
1074
|
+
|
|
1045
1075
|
ordered_connections = [kwargs[n] for n in mapping_inner.arg_names if n in kwargs]
|
|
1046
1076
|
ordered_connections = list(args) + ordered_connections
|
|
1047
1077
|
_add_mapping_connection(user_unique_name, ordered_connections, mapping_inner.arg_names,
|
|
@@ -51,7 +51,7 @@ class LeapLoader(LeapLoaderBase):
|
|
|
51
51
|
os.environ[mapping_runtime_mode_env_var_mame] = 'TRUE'
|
|
52
52
|
self.evaluate_module()
|
|
53
53
|
if global_leap_binder.integration_test_func is not None:
|
|
54
|
-
global_leap_binder.integration_test_func(None,
|
|
54
|
+
global_leap_binder.integration_test_func(None, PreprocessResponse(state=DataStateType.training, length=0))
|
|
55
55
|
except TypeError as e:
|
|
56
56
|
import traceback
|
|
57
57
|
if "leap_binder.set_metadata(" in traceback.format_exc(5):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
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.135 → code_loader-1.0.137}/code_loader/experiment_api/experiment_context.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_loader-1.0.135 → code_loader-1.0.137}/code_loader/experiment_api/workingspace_config_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|