code-loader 1.0.125__tar.gz → 1.0.128__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.125 → code_loader-1.0.128}/PKG-INFO +1 -1
- {code_loader-1.0.125 → code_loader-1.0.128}/code_loader/contract/datasetclasses.py +4 -4
- {code_loader-1.0.125 → code_loader-1.0.128}/code_loader/inner_leap_binder/leapbinder_decorators.py +78 -27
- {code_loader-1.0.125 → code_loader-1.0.128}/code_loader/leaploader.py +10 -24
- {code_loader-1.0.125 → code_loader-1.0.128}/code_loader/leaploaderbase.py +2 -6
- {code_loader-1.0.125 → code_loader-1.0.128}/code_loader/plot_functions/plot_functions.py +0 -1
- {code_loader-1.0.125 → code_loader-1.0.128}/code_loader/utils.py +6 -6
- {code_loader-1.0.125 → code_loader-1.0.128}/pyproject.toml +1 -1
- {code_loader-1.0.125 → code_loader-1.0.128}/LICENSE +0 -0
- {code_loader-1.0.125 → code_loader-1.0.128}/README.md +0 -0
- {code_loader-1.0.125 → code_loader-1.0.128}/code_loader/__init__.py +0 -0
- {code_loader-1.0.125 → code_loader-1.0.128}/code_loader/contract/__init__.py +0 -0
- {code_loader-1.0.125 → code_loader-1.0.128}/code_loader/contract/enums.py +0 -0
- {code_loader-1.0.125 → code_loader-1.0.128}/code_loader/contract/exceptions.py +0 -0
- {code_loader-1.0.125 → code_loader-1.0.128}/code_loader/contract/mapping.py +0 -0
- {code_loader-1.0.125 → code_loader-1.0.128}/code_loader/contract/responsedataclasses.py +0 -0
- {code_loader-1.0.125 → code_loader-1.0.128}/code_loader/contract/visualizer_classes.py +0 -0
- {code_loader-1.0.125 → code_loader-1.0.128}/code_loader/default_losses.py +0 -0
- {code_loader-1.0.125 → code_loader-1.0.128}/code_loader/default_metrics.py +0 -0
- {code_loader-1.0.125 → code_loader-1.0.128}/code_loader/experiment_api/__init__.py +0 -0
- {code_loader-1.0.125 → code_loader-1.0.128}/code_loader/experiment_api/api.py +0 -0
- {code_loader-1.0.125 → code_loader-1.0.128}/code_loader/experiment_api/cli_config_utils.py +0 -0
- {code_loader-1.0.125 → code_loader-1.0.128}/code_loader/experiment_api/client.py +0 -0
- {code_loader-1.0.125 → code_loader-1.0.128}/code_loader/experiment_api/epoch.py +0 -0
- {code_loader-1.0.125 → code_loader-1.0.128}/code_loader/experiment_api/experiment.py +0 -0
- {code_loader-1.0.125 → code_loader-1.0.128}/code_loader/experiment_api/experiment_context.py +0 -0
- {code_loader-1.0.125 → code_loader-1.0.128}/code_loader/experiment_api/types.py +0 -0
- {code_loader-1.0.125 → code_loader-1.0.128}/code_loader/experiment_api/utils.py +0 -0
- {code_loader-1.0.125 → code_loader-1.0.128}/code_loader/experiment_api/workingspace_config_utils.py +0 -0
- {code_loader-1.0.125 → code_loader-1.0.128}/code_loader/inner_leap_binder/__init__.py +0 -0
- {code_loader-1.0.125 → code_loader-1.0.128}/code_loader/inner_leap_binder/leapbinder.py +0 -0
- {code_loader-1.0.125 → code_loader-1.0.128}/code_loader/mixpanel_tracker.py +0 -0
- {code_loader-1.0.125 → code_loader-1.0.128}/code_loader/plot_functions/__init__.py +0 -0
- {code_loader-1.0.125 → code_loader-1.0.128}/code_loader/plot_functions/visualize.py +0 -0
- {code_loader-1.0.125 → code_loader-1.0.128}/code_loader/visualizers/__init__.py +0 -0
- {code_loader-1.0.125 → code_loader-1.0.128}/code_loader/visualizers/default_visualizers.py +0 -0
|
@@ -40,12 +40,10 @@ class PreprocessResponse:
|
|
|
40
40
|
sample_id_type: Optional[Union[Type[str], Type[int]]] = None
|
|
41
41
|
sample_ids_to_instance_mappings: Optional[Dict[str, List[str]]] = None # in use only for element instance
|
|
42
42
|
instance_to_sample_ids_mappings: Optional[Dict[str, str]] = None # in use only for element instance
|
|
43
|
-
instance_ids_to_names: Optional[Dict[str, str]] = None # in use only for element instance
|
|
44
43
|
|
|
45
44
|
def __post_init__(self) -> None:
|
|
46
45
|
assert self.sample_ids_to_instance_mappings is None, f"Keep sample_ids_to_instance_mappings None when initializing PreprocessResponse"
|
|
47
46
|
assert self.instance_to_sample_ids_mappings is None, f"Keep instance_to_sample_ids_mappings None when initializing PreprocessResponse"
|
|
48
|
-
assert self.instance_ids_to_names is None, f"Keep instance_ids_to_names None when initializing PreprocessResponse"
|
|
49
47
|
|
|
50
48
|
if self.length is not None and self.sample_ids is None:
|
|
51
49
|
self.sample_ids = [i for i in range(self.length)]
|
|
@@ -73,7 +71,9 @@ class ElementInstance:
|
|
|
73
71
|
mask: npt.NDArray[np.float32]
|
|
74
72
|
|
|
75
73
|
SectionCallableInterface = Callable[[Union[int, str], PreprocessResponse], npt.NDArray[np.float32]]
|
|
76
|
-
InstanceCallableInterface = Callable[[Union[int, str], PreprocessResponse],
|
|
74
|
+
InstanceCallableInterface = Callable[[Union[int, str], PreprocessResponse, int], Optional[ElementInstance]]
|
|
75
|
+
InstanceLengthCallableInterface = Callable[[Union[int, str], PreprocessResponse], int]
|
|
76
|
+
|
|
77
77
|
|
|
78
78
|
MetadataSectionCallableInterface = Union[
|
|
79
79
|
Callable[[Union[int, str], PreprocessResponse], int],
|
|
@@ -257,6 +257,6 @@ class DatasetSample:
|
|
|
257
257
|
metadata_is_none: Dict[str, bool]
|
|
258
258
|
index: Union[int, str]
|
|
259
259
|
state: DataStateEnum
|
|
260
|
-
instance_masks: Optional[Dict[str, List[ElementInstance]]] = None
|
|
261
260
|
custom_latent_space: Optional[npt.NDArray[np.float32]] = None
|
|
261
|
+
instance_masks: Optional[Dict[str, ElementInstance]] = None
|
|
262
262
|
|
{code_loader-1.0.125 → code_loader-1.0.128}/code_loader/inner_leap_binder/leapbinder_decorators.py
RENAMED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# mypy: ignore-errors
|
|
2
2
|
import os
|
|
3
|
+
from functools import lru_cache
|
|
3
4
|
from typing import Optional, Union, Callable, List, Dict
|
|
4
5
|
|
|
5
6
|
import numpy as np
|
|
@@ -8,7 +9,8 @@ import numpy.typing as npt
|
|
|
8
9
|
from code_loader.contract.datasetclasses import CustomCallableInterfaceMultiArgs, \
|
|
9
10
|
CustomMultipleReturnCallableInterfaceMultiArgs, ConfusionMatrixCallableInterfaceMultiArgs, CustomCallableInterface, \
|
|
10
11
|
VisualizerCallableInterface, MetadataSectionCallableInterface, PreprocessResponse, SectionCallableInterface, \
|
|
11
|
-
ConfusionMatrixElement, SamplePreprocessResponse, PredictionTypeHandler, InstanceCallableInterface, ElementInstance
|
|
12
|
+
ConfusionMatrixElement, SamplePreprocessResponse, PredictionTypeHandler, InstanceCallableInterface, ElementInstance, \
|
|
13
|
+
InstanceLengthCallableInterface
|
|
12
14
|
from code_loader.contract.enums import MetricDirection, LeapDataType, DatasetMetadataType
|
|
13
15
|
from code_loader import leap_binder
|
|
14
16
|
from code_loader.contract.mapping import NodeMapping, NodeMappingType, NodeConnection
|
|
@@ -20,6 +22,7 @@ import inspect
|
|
|
20
22
|
import functools
|
|
21
23
|
|
|
22
24
|
_called_from_inside_tl_decorator = 0
|
|
25
|
+
_called_from_inside_tl_integration_test_decorator = False
|
|
23
26
|
|
|
24
27
|
|
|
25
28
|
def _add_mapping_connection(user_unique_name, connection_destinations, arg_names, name, node_mapping_type):
|
|
@@ -45,17 +48,22 @@ def integration_test():
|
|
|
45
48
|
leap_binder.integration_test_func = integration_test_function
|
|
46
49
|
|
|
47
50
|
def inner(*args, **kwargs):
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
global _called_from_inside_tl_integration_test_decorator
|
|
50
52
|
try:
|
|
51
|
-
|
|
52
|
-
integration_test_function(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
_called_from_inside_tl_integration_test_decorator = True
|
|
54
|
+
ret = integration_test_function(*args, **kwargs)
|
|
55
|
+
|
|
56
|
+
try:
|
|
57
|
+
os.environ[mapping_runtime_mode_env_var_mame] = 'True'
|
|
58
|
+
integration_test_function(None, None)
|
|
59
|
+
except Exception as e:
|
|
60
|
+
print(f'Error during integration test: Make sure to disable any non tensorleap decorators '
|
|
61
|
+
f'functions before pushing a new TL version')
|
|
62
|
+
finally:
|
|
63
|
+
if mapping_runtime_mode_env_var_mame in os.environ:
|
|
64
|
+
del os.environ[mapping_runtime_mode_env_var_mame]
|
|
56
65
|
finally:
|
|
57
|
-
|
|
58
|
-
del os.environ[mapping_runtime_mode_env_var_mame]
|
|
66
|
+
_called_from_inside_tl_integration_test_decorator = False
|
|
59
67
|
|
|
60
68
|
return inner
|
|
61
69
|
|
|
@@ -70,6 +78,7 @@ def tensorleap_load_model(prediction_types: Optional[List[PredictionTypeHandler]
|
|
|
70
78
|
class TempMapping:
|
|
71
79
|
pass
|
|
72
80
|
|
|
81
|
+
@lru_cache()
|
|
73
82
|
def inner():
|
|
74
83
|
class ModelPlaceholder:
|
|
75
84
|
def __init__(self):
|
|
@@ -529,29 +538,24 @@ def tensorleap_preprocess():
|
|
|
529
538
|
|
|
530
539
|
|
|
531
540
|
def tensorleap_element_instance_preprocess(
|
|
532
|
-
|
|
541
|
+
instance_length_encoder: InstanceLengthCallableInterface):
|
|
533
542
|
def decorating_function(user_function: Callable[[], List[PreprocessResponse]]):
|
|
534
543
|
def user_function_instance() -> List[PreprocessResponse]:
|
|
535
544
|
result = user_function()
|
|
536
545
|
for preprocess_response in result:
|
|
537
546
|
sample_ids_to_instance_mappings = {}
|
|
538
547
|
instance_to_sample_ids_mappings = {}
|
|
539
|
-
instance_ids_to_names = {}
|
|
540
548
|
all_sample_ids = preprocess_response.sample_ids.copy()
|
|
541
549
|
for sample_id in preprocess_response.sample_ids:
|
|
542
|
-
|
|
543
|
-
instances_ids = [f'{sample_id}_{instance_id}' for instance_id in range(
|
|
550
|
+
instances_length = instance_length_encoder(sample_id, preprocess_response)
|
|
551
|
+
instances_ids = [f'{sample_id}_{instance_id}' for instance_id in range(instances_length)]
|
|
544
552
|
sample_ids_to_instance_mappings[sample_id] = instances_ids
|
|
545
553
|
instance_to_sample_ids_mappings[sample_id] = sample_id
|
|
546
|
-
|
|
547
|
-
instance_ids_to_names[sample_id] = 'none'
|
|
548
|
-
for instance_id, instance_name in zip(instances_ids, instance_names):
|
|
554
|
+
for instance_id in instances_ids:
|
|
549
555
|
instance_to_sample_ids_mappings[instance_id] = sample_id
|
|
550
|
-
instance_ids_to_names[instance_id] = instance_name
|
|
551
556
|
all_sample_ids.extend(instances_ids)
|
|
552
557
|
preprocess_response.sample_ids_to_instance_mappings = sample_ids_to_instance_mappings
|
|
553
558
|
preprocess_response.instance_to_sample_ids_mappings = instance_to_sample_ids_mappings
|
|
554
|
-
preprocess_response.instance_ids_to_names = instance_ids_to_names
|
|
555
559
|
preprocess_response.sample_ids = all_sample_ids
|
|
556
560
|
return result
|
|
557
561
|
|
|
@@ -620,7 +624,7 @@ def tensorleap_unlabeled_preprocess():
|
|
|
620
624
|
|
|
621
625
|
def tensorleap_instances_masks_encoder(name: str):
|
|
622
626
|
def decorating_function(user_function: InstanceCallableInterface):
|
|
623
|
-
def _validate_input_args(sample_id: str, preprocess_response: PreprocessResponse):
|
|
627
|
+
def _validate_input_args(sample_id: str, preprocess_response: PreprocessResponse, instance_id: int):
|
|
624
628
|
assert isinstance(sample_id, str), \
|
|
625
629
|
(f'tensorleap_instances_masks_encoder validation failed: '
|
|
626
630
|
f'Argument sample_id should be str. Got {type(sample_id)}.')
|
|
@@ -631,18 +635,21 @@ def tensorleap_instances_masks_encoder(name: str):
|
|
|
631
635
|
(f'tensorleap_instances_masks_encoder validation failed: '
|
|
632
636
|
f'Argument sample_id should be as the same type as defined in the preprocess response '
|
|
633
637
|
f'{preprocess_response.sample_id_type}. Got {type(sample_id)}.')
|
|
638
|
+
assert isinstance(instance_id, int), \
|
|
639
|
+
(f'tensorleap_instances_masks_encoder validation failed: '
|
|
640
|
+
f'Argument instance_id should be int. Got {type(instance_id)}.')
|
|
634
641
|
|
|
635
642
|
def _validate_result(result):
|
|
636
|
-
assert isinstance(result,
|
|
643
|
+
assert isinstance(result, ElementInstance) or (result is None), \
|
|
637
644
|
(f'tensorleap_instances_masks_encoder validation failed: '
|
|
638
|
-
f'Unsupported return type. Should be a
|
|
645
|
+
f'Unsupported return type. Should be a ElementInstance or None. Got {type(result)}.')
|
|
639
646
|
|
|
640
|
-
def inner_without_validate(sample_id, preprocess_response):
|
|
647
|
+
def inner_without_validate(sample_id, preprocess_response, instance_id):
|
|
641
648
|
global _called_from_inside_tl_decorator
|
|
642
649
|
_called_from_inside_tl_decorator += 1
|
|
643
650
|
|
|
644
651
|
try:
|
|
645
|
-
result = user_function(sample_id, preprocess_response)
|
|
652
|
+
result = user_function(sample_id, preprocess_response, instance_id)
|
|
646
653
|
finally:
|
|
647
654
|
_called_from_inside_tl_decorator -= 1
|
|
648
655
|
|
|
@@ -650,6 +657,51 @@ def tensorleap_instances_masks_encoder(name: str):
|
|
|
650
657
|
|
|
651
658
|
leap_binder.set_instance_masks(inner_without_validate, name)
|
|
652
659
|
|
|
660
|
+
def inner(sample_id, preprocess_response, instance_id):
|
|
661
|
+
if os.environ.get(mapping_runtime_mode_env_var_mame):
|
|
662
|
+
return None
|
|
663
|
+
|
|
664
|
+
_validate_input_args(sample_id, preprocess_response, instance_id)
|
|
665
|
+
|
|
666
|
+
result = inner_without_validate(sample_id, preprocess_response, instance_id)
|
|
667
|
+
|
|
668
|
+
_validate_result(result)
|
|
669
|
+
return result
|
|
670
|
+
|
|
671
|
+
return inner
|
|
672
|
+
|
|
673
|
+
return decorating_function
|
|
674
|
+
|
|
675
|
+
def tensorleap_instances_length_encoder(name: str):
|
|
676
|
+
def decorating_function(user_function: InstanceLengthCallableInterface):
|
|
677
|
+
def _validate_input_args(sample_id: str, preprocess_response: PreprocessResponse):
|
|
678
|
+
assert isinstance(sample_id, str), \
|
|
679
|
+
(f'tensorleap_instances_length_encoder validation failed: '
|
|
680
|
+
f'Argument sample_id should be str. Got {type(sample_id)}.')
|
|
681
|
+
assert isinstance(preprocess_response, PreprocessResponse), \
|
|
682
|
+
(f'tensorleap_instances_length_encoder validation failed: '
|
|
683
|
+
f'Argument preprocess_response should be a PreprocessResponse. Got {type(preprocess_response)}.')
|
|
684
|
+
assert type(sample_id) == preprocess_response.sample_id_type, \
|
|
685
|
+
(f'tensorleap_instances_length_encoder validation failed: '
|
|
686
|
+
f'Argument sample_id should be as the same type as defined in the preprocess response '
|
|
687
|
+
f'{preprocess_response.sample_id_type}. Got {type(sample_id)}.')
|
|
688
|
+
|
|
689
|
+
def _validate_result(result):
|
|
690
|
+
assert isinstance(result, int), \
|
|
691
|
+
(f'tensorleap_instances_length_encoder validation failed: '
|
|
692
|
+
f'Unsupported return type. Should be a int. Got {type(result)}.')
|
|
693
|
+
|
|
694
|
+
def inner_without_validate(sample_id, preprocess_response):
|
|
695
|
+
global _called_from_inside_tl_decorator
|
|
696
|
+
_called_from_inside_tl_decorator += 1
|
|
697
|
+
|
|
698
|
+
try:
|
|
699
|
+
result = user_function(sample_id, preprocess_response)
|
|
700
|
+
finally:
|
|
701
|
+
_called_from_inside_tl_decorator -= 1
|
|
702
|
+
|
|
703
|
+
return result
|
|
704
|
+
|
|
653
705
|
def inner(sample_id, preprocess_response):
|
|
654
706
|
if os.environ.get(mapping_runtime_mode_env_var_mame):
|
|
655
707
|
return None
|
|
@@ -665,7 +717,6 @@ def tensorleap_instances_masks_encoder(name: str):
|
|
|
665
717
|
|
|
666
718
|
return decorating_function
|
|
667
719
|
|
|
668
|
-
|
|
669
720
|
def tensorleap_input_encoder(name: str, channel_dim=-1, model_input_index=None):
|
|
670
721
|
def decorating_function(user_function: SectionCallableInterface):
|
|
671
722
|
for input_handler in leap_binder.setup_container.inputs:
|
|
@@ -719,7 +770,7 @@ def tensorleap_input_encoder(name: str, channel_dim=-1, model_input_index=None):
|
|
|
719
770
|
|
|
720
771
|
_validate_result(result)
|
|
721
772
|
|
|
722
|
-
if _called_from_inside_tl_decorator == 0:
|
|
773
|
+
if _called_from_inside_tl_decorator == 0 and _called_from_inside_tl_integration_test_decorator:
|
|
723
774
|
result = np.expand_dims(result, axis=0)
|
|
724
775
|
|
|
725
776
|
return result
|
|
@@ -803,7 +854,7 @@ def tensorleap_gt_encoder(name: str):
|
|
|
803
854
|
|
|
804
855
|
_validate_result(result)
|
|
805
856
|
|
|
806
|
-
if _called_from_inside_tl_decorator == 0:
|
|
857
|
+
if _called_from_inside_tl_decorator == 0 and _called_from_inside_tl_integration_test_decorator:
|
|
807
858
|
result = np.expand_dims(result, axis=0)
|
|
808
859
|
|
|
809
860
|
return result
|
|
@@ -157,7 +157,7 @@ class LeapLoader(LeapLoaderBase):
|
|
|
157
157
|
for prediction_type in setup.prediction_types
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
def get_sample(self, state: DataStateEnum, sample_id: Union[int, str]) -> DatasetSample:
|
|
160
|
+
def get_sample(self, state: DataStateEnum, sample_id: Union[int, str], instance_id: int = None) -> DatasetSample:
|
|
161
161
|
self.exec_script()
|
|
162
162
|
preprocess_result = self._preprocess_result()
|
|
163
163
|
if state == DataStateEnum.unlabeled and sample_id not in preprocess_result[state].sample_ids:
|
|
@@ -170,30 +170,15 @@ class LeapLoader(LeapLoaderBase):
|
|
|
170
170
|
custom_latent_space = global_leap_binder.setup_container.custom_latent_space.function(sample_id,
|
|
171
171
|
preprocess_result[
|
|
172
172
|
state])
|
|
173
|
-
|
|
173
|
+
instance_mask = self._get_instances_masks(state, sample_id, instance_id)
|
|
174
174
|
sample = DatasetSample(inputs=self._get_inputs(state, sample_id),
|
|
175
175
|
gt=None if state == DataStateEnum.unlabeled else self._get_gt(state, sample_id),
|
|
176
176
|
metadata=metadata,
|
|
177
177
|
metadata_is_none=metadata_is_none,
|
|
178
178
|
index=sample_id,
|
|
179
179
|
state=state,
|
|
180
|
-
custom_latent_space=custom_latent_space
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
def get_sample_with_masks(self, state: DataStateEnum, sample_id: Union[int, str]) -> DatasetSample:
|
|
184
|
-
self.exec_script()
|
|
185
|
-
preprocess_result = self._preprocess_result()
|
|
186
|
-
if state == DataStateEnum.unlabeled and sample_id not in preprocess_result[state].sample_ids:
|
|
187
|
-
self._preprocess_result(update_unlabeled_preprocess=True)
|
|
188
|
-
|
|
189
|
-
metadata, metadata_is_none = self._get_metadata(state, sample_id)
|
|
190
|
-
sample = DatasetSample(inputs=self._get_inputs(state, sample_id),
|
|
191
|
-
gt=None if state == DataStateEnum.unlabeled else self._get_gt(state, sample_id),
|
|
192
|
-
metadata=metadata,
|
|
193
|
-
metadata_is_none=metadata_is_none,
|
|
194
|
-
index=sample_id,
|
|
195
|
-
state=state,
|
|
196
|
-
instance_masks=self._get_instances_masks(state, sample_id))
|
|
180
|
+
custom_latent_space=custom_latent_space,
|
|
181
|
+
instance_masks=instance_mask)
|
|
197
182
|
return sample
|
|
198
183
|
|
|
199
184
|
def check_dataset(self) -> DatasetIntegParseResult:
|
|
@@ -484,13 +469,14 @@ class LeapLoader(LeapLoaderBase):
|
|
|
484
469
|
def _get_inputs(self, state: DataStateEnum, sample_id: Union[int, str]) -> Dict[str, npt.NDArray[np.float32]]:
|
|
485
470
|
return self._get_dataset_handlers(global_leap_binder.setup_container.inputs, state, sample_id)
|
|
486
471
|
|
|
487
|
-
def _get_instances_masks(self, state: DataStateEnum, sample_id: Union[int, str]) -> Dict[
|
|
488
|
-
|
|
472
|
+
def _get_instances_masks(self, state: DataStateEnum, sample_id: Union[int, str], instance_id: int) -> Optional[Dict[str, ElementInstance]]:
|
|
473
|
+
if instance_id is None:
|
|
474
|
+
return None
|
|
489
475
|
preprocess_result = self._preprocess_result()
|
|
490
476
|
preprocess_state = preprocess_result[state]
|
|
491
477
|
result_agg = {}
|
|
492
478
|
for handler in global_leap_binder.setup_container.instance_masks:
|
|
493
|
-
handler_result = handler.function(sample_id, preprocess_state)
|
|
479
|
+
handler_result = handler.function(sample_id, preprocess_state, instance_id)
|
|
494
480
|
handler_name = handler.name
|
|
495
481
|
result_agg[handler_name] = handler_result
|
|
496
482
|
return result_agg
|
|
@@ -570,7 +556,7 @@ class LeapLoader(LeapLoaderBase):
|
|
|
570
556
|
self.exec_script()
|
|
571
557
|
return global_leap_binder.setup_container.custom_latent_space is not None
|
|
572
558
|
|
|
573
|
-
def get_instances_data(self, state: DataStateEnum) -> Tuple[Dict[str, List[str]], Dict[str, str]
|
|
559
|
+
def get_instances_data(self, state: DataStateEnum) -> Tuple[Dict[str, List[str]], Dict[str, str]]:
|
|
574
560
|
"""
|
|
575
561
|
This Method get the data state and returns two dictionaries that holds the mapping of the sample ids to their
|
|
576
562
|
instances and the other way around and the sample ids array.
|
|
@@ -583,4 +569,4 @@ class LeapLoader(LeapLoaderBase):
|
|
|
583
569
|
"""
|
|
584
570
|
preprocess_result = self._preprocess_result()
|
|
585
571
|
preprocess_state = preprocess_result[state]
|
|
586
|
-
return preprocess_state.sample_ids_to_instance_mappings, preprocess_state.instance_to_sample_ids_mappings
|
|
572
|
+
return preprocess_state.sample_ids_to_instance_mappings, preprocess_state.instance_to_sample_ids_mappings
|
|
@@ -61,15 +61,11 @@ class LeapLoaderBase:
|
|
|
61
61
|
pass
|
|
62
62
|
|
|
63
63
|
@abstractmethod
|
|
64
|
-
def get_sample(self, state: DataStateEnum, sample_id: Union[int, str]) -> DatasetSample:
|
|
64
|
+
def get_sample(self, state: DataStateEnum, sample_id: Union[int, str], instance_id: int = None) -> DatasetSample:
|
|
65
65
|
pass
|
|
66
66
|
|
|
67
67
|
@abstractmethod
|
|
68
|
-
def
|
|
69
|
-
pass
|
|
70
|
-
|
|
71
|
-
@abstractmethod
|
|
72
|
-
def get_instances_data(self, state: DataStateEnum) -> Tuple[Dict[str, List[str]], Dict[str, str], Dict[str, str]]:
|
|
68
|
+
def get_instances_data(self, state: DataStateEnum) -> Tuple[Dict[str, List[str]], Dict[str, str]]:
|
|
73
69
|
pass
|
|
74
70
|
|
|
75
71
|
@abstractmethod
|
|
@@ -29,7 +29,6 @@ def run_only_on_non_mapping_mode():
|
|
|
29
29
|
def decorator(func):
|
|
30
30
|
def wrapper(*args, **kwargs):
|
|
31
31
|
if os.environ.get(mapping_runtime_mode_env_var_mame):
|
|
32
|
-
print(f"Skipping {func.__name__} in mapping mode.")
|
|
33
32
|
return
|
|
34
33
|
return func(*args, **kwargs)
|
|
35
34
|
return wrapper
|
|
@@ -18,12 +18,12 @@ def to_numpy_return_wrapper(encoder_function: SectionCallableInterface) -> Secti
|
|
|
18
18
|
|
|
19
19
|
return numpy_encoder_function
|
|
20
20
|
|
|
21
|
-
def to_numpy_return_masks_wrapper(encoder_function: InstanceCallableInterface) ->
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
result
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
def to_numpy_return_masks_wrapper(encoder_function: InstanceCallableInterface) -> InstanceCallableInterface:
|
|
22
|
+
def numpy_encoder_function(idx: Union[int, str], samples: PreprocessResponse, element_idx: int) -> Union[ElementInstance, None]:
|
|
23
|
+
result = encoder_function(idx, samples, element_idx)
|
|
24
|
+
if result is None:
|
|
25
|
+
return None
|
|
26
|
+
result.mask = np.array(result.mask)
|
|
27
27
|
return result
|
|
28
28
|
return numpy_encoder_function
|
|
29
29
|
|
|
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.125 → code_loader-1.0.128}/code_loader/experiment_api/experiment_context.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_loader-1.0.125 → code_loader-1.0.128}/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
|