code-loader 1.0.106__tar.gz → 1.0.108__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.106 → code_loader-1.0.108}/PKG-INFO +1 -1
- {code_loader-1.0.106 → code_loader-1.0.108}/code_loader/contract/datasetclasses.py +0 -5
- {code_loader-1.0.106 → code_loader-1.0.108}/code_loader/inner_leap_binder/leapbinder_decorators.py +74 -58
- {code_loader-1.0.106 → code_loader-1.0.108}/pyproject.toml +1 -1
- {code_loader-1.0.106 → code_loader-1.0.108}/LICENSE +0 -0
- {code_loader-1.0.106 → code_loader-1.0.108}/README.md +0 -0
- {code_loader-1.0.106 → code_loader-1.0.108}/code_loader/__init__.py +0 -0
- {code_loader-1.0.106 → code_loader-1.0.108}/code_loader/contract/__init__.py +0 -0
- {code_loader-1.0.106 → code_loader-1.0.108}/code_loader/contract/enums.py +0 -0
- {code_loader-1.0.106 → code_loader-1.0.108}/code_loader/contract/exceptions.py +0 -0
- {code_loader-1.0.106 → code_loader-1.0.108}/code_loader/contract/mapping.py +0 -0
- {code_loader-1.0.106 → code_loader-1.0.108}/code_loader/contract/responsedataclasses.py +0 -0
- {code_loader-1.0.106 → code_loader-1.0.108}/code_loader/contract/visualizer_classes.py +0 -0
- {code_loader-1.0.106 → code_loader-1.0.108}/code_loader/default_losses.py +0 -0
- {code_loader-1.0.106 → code_loader-1.0.108}/code_loader/default_metrics.py +0 -0
- {code_loader-1.0.106 → code_loader-1.0.108}/code_loader/experiment_api/__init__.py +0 -0
- {code_loader-1.0.106 → code_loader-1.0.108}/code_loader/experiment_api/api.py +0 -0
- {code_loader-1.0.106 → code_loader-1.0.108}/code_loader/experiment_api/cli_config_utils.py +0 -0
- {code_loader-1.0.106 → code_loader-1.0.108}/code_loader/experiment_api/client.py +0 -0
- {code_loader-1.0.106 → code_loader-1.0.108}/code_loader/experiment_api/epoch.py +0 -0
- {code_loader-1.0.106 → code_loader-1.0.108}/code_loader/experiment_api/experiment.py +0 -0
- {code_loader-1.0.106 → code_loader-1.0.108}/code_loader/experiment_api/experiment_context.py +0 -0
- {code_loader-1.0.106 → code_loader-1.0.108}/code_loader/experiment_api/types.py +0 -0
- {code_loader-1.0.106 → code_loader-1.0.108}/code_loader/experiment_api/utils.py +0 -0
- {code_loader-1.0.106 → code_loader-1.0.108}/code_loader/experiment_api/workingspace_config_utils.py +0 -0
- {code_loader-1.0.106 → code_loader-1.0.108}/code_loader/inner_leap_binder/__init__.py +0 -0
- {code_loader-1.0.106 → code_loader-1.0.108}/code_loader/inner_leap_binder/leapbinder.py +0 -0
- {code_loader-1.0.106 → code_loader-1.0.108}/code_loader/leaploader.py +0 -0
- {code_loader-1.0.106 → code_loader-1.0.108}/code_loader/leaploaderbase.py +0 -0
- {code_loader-1.0.106 → code_loader-1.0.108}/code_loader/plot_functions/__init__.py +0 -0
- {code_loader-1.0.106 → code_loader-1.0.108}/code_loader/plot_functions/plot_functions.py +0 -0
- {code_loader-1.0.106 → code_loader-1.0.108}/code_loader/plot_functions/visualize.py +0 -0
- {code_loader-1.0.106 → code_loader-1.0.108}/code_loader/utils.py +0 -0
- {code_loader-1.0.106 → code_loader-1.0.108}/code_loader/visualizers/__init__.py +0 -0
- {code_loader-1.0.106 → code_loader-1.0.108}/code_loader/visualizers/default_visualizers.py +0 -0
|
@@ -43,9 +43,6 @@ class PreprocessResponse:
|
|
|
43
43
|
instance_ids_to_names: Optional[Dict[str, str]] = None # in use only for element instance
|
|
44
44
|
|
|
45
45
|
def __post_init__(self) -> None:
|
|
46
|
-
def is_valid_string(s: str) -> bool:
|
|
47
|
-
return bool(re.match(r'^[A-Za-z0-9_]+$', s))
|
|
48
|
-
|
|
49
46
|
assert self.sample_ids_to_instance_mappings is None, f"Keep sample_ids_to_instance_mappings None when initializing PreprocessResponse"
|
|
50
47
|
assert self.instance_to_sample_ids_mappings is None, f"Keep instance_to_sample_ids_mappings None when initializing PreprocessResponse"
|
|
51
48
|
assert self.instance_ids_to_names is None, f"Keep instance_ids_to_names None when initializing PreprocessResponse"
|
|
@@ -60,8 +57,6 @@ class PreprocessResponse:
|
|
|
60
57
|
if self.sample_id_type == str:
|
|
61
58
|
for sample_id in self.sample_ids:
|
|
62
59
|
assert isinstance(sample_id, str), f"Sample id should be of type str. Got: {type(sample_id)}"
|
|
63
|
-
if not is_valid_string(sample_id):
|
|
64
|
-
raise Exception(f"Sample id should contain only letters (A-Z, a-z), numbers or '_'. Got: {sample_id}")
|
|
65
60
|
else:
|
|
66
61
|
raise Exception("length is deprecated.")
|
|
67
62
|
|
{code_loader-1.0.106 → code_loader-1.0.108}/code_loader/inner_leap_binder/leapbinder_decorators.py
RENAMED
|
@@ -152,12 +152,6 @@ def tensorleap_custom_metric(name: str,
|
|
|
152
152
|
raise Exception(f'Metric with name {name} already exists. '
|
|
153
153
|
f'Please choose another')
|
|
154
154
|
|
|
155
|
-
leap_binder.add_custom_metric(user_function, name, direction, compute_insights)
|
|
156
|
-
|
|
157
|
-
if connects_to is not None:
|
|
158
|
-
arg_names = leap_binder.setup_container.metrics[-1].metric_handler_data.arg_names
|
|
159
|
-
_add_mapping_connections(connects_to, arg_names, NodeMappingType.Metric, name)
|
|
160
|
-
|
|
161
155
|
def _validate_input_args(*args, **kwargs) -> None:
|
|
162
156
|
for i, arg in enumerate(args):
|
|
163
157
|
assert isinstance(arg, (np.ndarray, SamplePreprocessResponse)), (
|
|
@@ -233,9 +227,7 @@ def tensorleap_custom_metric(name: str,
|
|
|
233
227
|
(f'tensorleap_custom_metric validation failed: '
|
|
234
228
|
f'compute_insights should be boolean. Got {type(compute_insights)}.')
|
|
235
229
|
|
|
236
|
-
def
|
|
237
|
-
_validate_input_args(*args, **kwargs)
|
|
238
|
-
|
|
230
|
+
def inner_without_validate(*args, **kwargs):
|
|
239
231
|
global _called_from_inside_tl_decorator
|
|
240
232
|
_called_from_inside_tl_decorator += 1
|
|
241
233
|
|
|
@@ -244,6 +236,19 @@ def tensorleap_custom_metric(name: str,
|
|
|
244
236
|
finally:
|
|
245
237
|
_called_from_inside_tl_decorator -= 1
|
|
246
238
|
|
|
239
|
+
return result
|
|
240
|
+
|
|
241
|
+
leap_binder.add_custom_metric(inner_without_validate, name, direction, compute_insights)
|
|
242
|
+
|
|
243
|
+
if connects_to is not None:
|
|
244
|
+
arg_names = leap_binder.setup_container.metrics[-1].metric_handler_data.arg_names
|
|
245
|
+
_add_mapping_connections(connects_to, arg_names, NodeMappingType.Metric, name)
|
|
246
|
+
|
|
247
|
+
def inner(*args, **kwargs):
|
|
248
|
+
_validate_input_args(*args, **kwargs)
|
|
249
|
+
|
|
250
|
+
result = inner_without_validate(*args, **kwargs)
|
|
251
|
+
|
|
247
252
|
_validate_result(result)
|
|
248
253
|
return result
|
|
249
254
|
|
|
@@ -284,12 +289,6 @@ def tensorleap_custom_visualizer(name: str, visualizer_type: LeapDataType,
|
|
|
284
289
|
raise Exception(f'Visualizer with name {name} already exists. '
|
|
285
290
|
f'Please choose another')
|
|
286
291
|
|
|
287
|
-
leap_binder.set_visualizer(user_function, name, visualizer_type, heatmap_function)
|
|
288
|
-
|
|
289
|
-
if connects_to is not None:
|
|
290
|
-
arg_names = leap_binder.setup_container.visualizers[-1].visualizer_handler_data.arg_names
|
|
291
|
-
_add_mapping_connections(connects_to, arg_names, NodeMappingType.Visualizer, name)
|
|
292
|
-
|
|
293
292
|
def _validate_input_args(*args, **kwargs):
|
|
294
293
|
for i, arg in enumerate(args):
|
|
295
294
|
assert isinstance(arg, (np.ndarray, SamplePreprocessResponse)), (
|
|
@@ -324,9 +323,8 @@ def tensorleap_custom_visualizer(name: str, visualizer_type: LeapDataType,
|
|
|
324
323
|
(f'tensorleap_custom_visualizer validation failed: '
|
|
325
324
|
f'The return type should be {result_type_map[visualizer_type]}. Got {type(result)}.')
|
|
326
325
|
|
|
327
|
-
def inner(*args, **kwargs):
|
|
328
|
-
_validate_input_args(*args, **kwargs)
|
|
329
326
|
|
|
327
|
+
def inner_without_validate(*args, **kwargs):
|
|
330
328
|
global _called_from_inside_tl_decorator
|
|
331
329
|
_called_from_inside_tl_decorator += 1
|
|
332
330
|
|
|
@@ -335,9 +333,23 @@ def tensorleap_custom_visualizer(name: str, visualizer_type: LeapDataType,
|
|
|
335
333
|
finally:
|
|
336
334
|
_called_from_inside_tl_decorator -= 1
|
|
337
335
|
|
|
336
|
+
return result
|
|
337
|
+
|
|
338
|
+
leap_binder.set_visualizer(inner_without_validate, name, visualizer_type, heatmap_function)
|
|
339
|
+
|
|
340
|
+
if connects_to is not None:
|
|
341
|
+
arg_names = leap_binder.setup_container.visualizers[-1].visualizer_handler_data.arg_names
|
|
342
|
+
_add_mapping_connections(connects_to, arg_names, NodeMappingType.Visualizer, name)
|
|
343
|
+
|
|
344
|
+
def inner(*args, **kwargs):
|
|
345
|
+
_validate_input_args(*args, **kwargs)
|
|
346
|
+
|
|
347
|
+
result = inner_without_validate()
|
|
348
|
+
|
|
338
349
|
_validate_result(result)
|
|
339
350
|
return result
|
|
340
351
|
|
|
352
|
+
|
|
341
353
|
def mapping_inner(*args, **kwargs):
|
|
342
354
|
user_unique_name = mapping_inner.name
|
|
343
355
|
if 'user_unique_name' in kwargs:
|
|
@@ -372,8 +384,6 @@ def tensorleap_metadata(
|
|
|
372
384
|
raise Exception(f'Metadata with name {name} already exists. '
|
|
373
385
|
f'Please choose another')
|
|
374
386
|
|
|
375
|
-
leap_binder.set_metadata(user_function, name, metadata_type)
|
|
376
|
-
|
|
377
387
|
def _validate_input_args(sample_id: Union[int, str], preprocess_response: PreprocessResponse):
|
|
378
388
|
assert isinstance(sample_id, (int, str)), \
|
|
379
389
|
(f'tensorleap_metadata validation failed: '
|
|
@@ -401,11 +411,7 @@ def tensorleap_metadata(
|
|
|
401
411
|
(f'tensorleap_metadata validation failed: '
|
|
402
412
|
f'Values in the return dict should be of type {str(supported_result_types)}. Got {type(value)}.')
|
|
403
413
|
|
|
404
|
-
def
|
|
405
|
-
if os.environ.get(mapping_runtime_mode_env_var_mame):
|
|
406
|
-
return None
|
|
407
|
-
|
|
408
|
-
_validate_input_args(sample_id, preprocess_response)
|
|
414
|
+
def inner_without_validate(sample_id, preprocess_response):
|
|
409
415
|
|
|
410
416
|
global _called_from_inside_tl_decorator
|
|
411
417
|
_called_from_inside_tl_decorator += 1
|
|
@@ -415,6 +421,19 @@ def tensorleap_metadata(
|
|
|
415
421
|
finally:
|
|
416
422
|
_called_from_inside_tl_decorator -= 1
|
|
417
423
|
|
|
424
|
+
return result
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
leap_binder.set_metadata(inner_without_validate, name, metadata_type)
|
|
428
|
+
|
|
429
|
+
def inner(sample_id, preprocess_response):
|
|
430
|
+
if os.environ.get(mapping_runtime_mode_env_var_mame):
|
|
431
|
+
return None
|
|
432
|
+
|
|
433
|
+
_validate_input_args(sample_id, preprocess_response)
|
|
434
|
+
|
|
435
|
+
result = inner_without_validate(sample_id, preprocess_response)
|
|
436
|
+
|
|
418
437
|
_validate_result(result)
|
|
419
438
|
return result
|
|
420
439
|
|
|
@@ -549,8 +568,6 @@ def tensorleap_unlabeled_preprocess():
|
|
|
549
568
|
|
|
550
569
|
def tensorleap_instances_masks_encoder(name: str):
|
|
551
570
|
def decorating_function(user_function: InstanceCallableInterface):
|
|
552
|
-
leap_binder.set_instance_masks(user_function, name)
|
|
553
|
-
|
|
554
571
|
def _validate_input_args(sample_id: str, preprocess_response: PreprocessResponse):
|
|
555
572
|
assert isinstance(sample_id, str), \
|
|
556
573
|
(f'tensorleap_instances_masks_encoder validation failed: '
|
|
@@ -568,13 +585,7 @@ def tensorleap_instances_masks_encoder(name: str):
|
|
|
568
585
|
(f'tensorleap_instances_masks_encoder validation failed: '
|
|
569
586
|
f'Unsupported return type. Should be a numpy array. Got {type(result)}.')
|
|
570
587
|
|
|
571
|
-
|
|
572
|
-
def inner(sample_id, preprocess_response):
|
|
573
|
-
if os.environ.get(mapping_runtime_mode_env_var_mame):
|
|
574
|
-
return None
|
|
575
|
-
|
|
576
|
-
_validate_input_args(sample_id, preprocess_response)
|
|
577
|
-
|
|
588
|
+
def inner_without_validate(sample_id, preprocess_response):
|
|
578
589
|
global _called_from_inside_tl_decorator
|
|
579
590
|
_called_from_inside_tl_decorator += 1
|
|
580
591
|
|
|
@@ -583,6 +594,19 @@ def tensorleap_instances_masks_encoder(name: str):
|
|
|
583
594
|
finally:
|
|
584
595
|
_called_from_inside_tl_decorator -= 1
|
|
585
596
|
|
|
597
|
+
return result
|
|
598
|
+
|
|
599
|
+
leap_binder.set_instance_masks(inner_without_validate, name)
|
|
600
|
+
|
|
601
|
+
|
|
602
|
+
def inner(sample_id, preprocess_response):
|
|
603
|
+
if os.environ.get(mapping_runtime_mode_env_var_mame):
|
|
604
|
+
return None
|
|
605
|
+
|
|
606
|
+
_validate_input_args(sample_id, preprocess_response)
|
|
607
|
+
|
|
608
|
+
result = inner_without_validate(sample_id, preprocess_response)
|
|
609
|
+
|
|
586
610
|
_validate_result(result)
|
|
587
611
|
return result
|
|
588
612
|
|
|
@@ -601,6 +625,8 @@ def tensorleap_input_encoder(name: str, channel_dim=-1, model_input_index=None):
|
|
|
601
625
|
if channel_dim <= 0 and channel_dim != -1:
|
|
602
626
|
raise Exception(f"Channel dim for input {name} is expected to be either -1 or positive")
|
|
603
627
|
|
|
628
|
+
leap_binder.set_input(user_function, name, channel_dim=channel_dim)
|
|
629
|
+
|
|
604
630
|
def _validate_input_args(sample_id: Union[int, str], preprocess_response: PreprocessResponse):
|
|
605
631
|
assert isinstance(sample_id, (int, str)), \
|
|
606
632
|
(f'tensorleap_input_encoder validation failed: '
|
|
@@ -637,14 +663,6 @@ def tensorleap_input_encoder(name: str, channel_dim=-1, model_input_index=None):
|
|
|
637
663
|
node_mapping_type = NodeMappingType(f'Input{str(model_input_index)}')
|
|
638
664
|
inner.node_mapping = NodeMapping(name, node_mapping_type)
|
|
639
665
|
|
|
640
|
-
def inner_without_validate(sample_id, preprocess_response):
|
|
641
|
-
result = user_function(sample_id, preprocess_response)
|
|
642
|
-
if _called_from_inside_tl_decorator == 0:
|
|
643
|
-
result = np.expand_dims(result, axis=0)
|
|
644
|
-
return result
|
|
645
|
-
|
|
646
|
-
leap_binder.set_input(inner_without_validate, name, channel_dim=channel_dim)
|
|
647
|
-
|
|
648
666
|
|
|
649
667
|
def mapping_inner(sample_id, preprocess_response):
|
|
650
668
|
class TempMapping:
|
|
@@ -676,6 +694,7 @@ def tensorleap_gt_encoder(name: str):
|
|
|
676
694
|
raise Exception(f'GT with name {name} already exists. '
|
|
677
695
|
f'Please choose another')
|
|
678
696
|
|
|
697
|
+
leap_binder.set_ground_truth(user_function, name)
|
|
679
698
|
|
|
680
699
|
def _validate_input_args(sample_id: Union[int, str], preprocess_response: PreprocessResponse):
|
|
681
700
|
assert isinstance(sample_id, (int, str)), \
|
|
@@ -706,14 +725,6 @@ def tensorleap_gt_encoder(name: str):
|
|
|
706
725
|
result = np.expand_dims(result, axis=0)
|
|
707
726
|
return result
|
|
708
727
|
|
|
709
|
-
def inner_without_validate(sample_id, preprocess_response):
|
|
710
|
-
result = user_function(sample_id, preprocess_response)
|
|
711
|
-
if _called_from_inside_tl_decorator == 0:
|
|
712
|
-
result = np.expand_dims(result, axis=0)
|
|
713
|
-
return result
|
|
714
|
-
|
|
715
|
-
leap_binder.set_ground_truth(inner_without_validate, name)
|
|
716
|
-
|
|
717
728
|
inner.node_mapping = NodeMapping(name, NodeMappingType.GroundTruth)
|
|
718
729
|
|
|
719
730
|
def mapping_inner(sample_id, preprocess_response):
|
|
@@ -746,12 +757,6 @@ def tensorleap_custom_loss(name: str, connects_to=None):
|
|
|
746
757
|
raise Exception(f'Custom loss with name {name} already exists. '
|
|
747
758
|
f'Please choose another')
|
|
748
759
|
|
|
749
|
-
leap_binder.add_custom_loss(user_function, name)
|
|
750
|
-
|
|
751
|
-
if connects_to is not None:
|
|
752
|
-
arg_names = leap_binder.setup_container.custom_loss_handlers[-1].custom_loss_handler_data.arg_names
|
|
753
|
-
_add_mapping_connections(connects_to, arg_names, NodeMappingType.CustomLoss, name)
|
|
754
|
-
|
|
755
760
|
|
|
756
761
|
valid_types = (np.ndarray, SamplePreprocessResponse)
|
|
757
762
|
try:
|
|
@@ -784,9 +789,7 @@ def tensorleap_custom_loss(name: str, connects_to=None):
|
|
|
784
789
|
(f'tensorleap_custom_loss validation failed: '
|
|
785
790
|
f'The return type should be a numpy array. Got {type(result)}.')
|
|
786
791
|
|
|
787
|
-
def
|
|
788
|
-
_validate_input_args(*args, **kwargs)
|
|
789
|
-
|
|
792
|
+
def inner_without_validate(*args, **kwargs):
|
|
790
793
|
global _called_from_inside_tl_decorator
|
|
791
794
|
_called_from_inside_tl_decorator += 1
|
|
792
795
|
|
|
@@ -795,6 +798,19 @@ def tensorleap_custom_loss(name: str, connects_to=None):
|
|
|
795
798
|
finally:
|
|
796
799
|
_called_from_inside_tl_decorator -= 1
|
|
797
800
|
|
|
801
|
+
return result
|
|
802
|
+
|
|
803
|
+
leap_binder.add_custom_loss(inner_without_validate, name)
|
|
804
|
+
|
|
805
|
+
if connects_to is not None:
|
|
806
|
+
arg_names = leap_binder.setup_container.custom_loss_handlers[-1].custom_loss_handler_data.arg_names
|
|
807
|
+
_add_mapping_connections(connects_to, arg_names, NodeMappingType.CustomLoss, name)
|
|
808
|
+
|
|
809
|
+
def inner(*args, **kwargs):
|
|
810
|
+
_validate_input_args(*args, **kwargs)
|
|
811
|
+
|
|
812
|
+
result = inner_without_validate(*args, **kwargs)
|
|
813
|
+
|
|
798
814
|
_validate_result(result)
|
|
799
815
|
return result
|
|
800
816
|
|
|
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.106 → code_loader-1.0.108}/code_loader/experiment_api/experiment_context.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_loader-1.0.106 → code_loader-1.0.108}/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
|