code-loader 1.0.94.dev1__py3-none-any.whl → 1.0.94.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 +2 -1
- code_loader/inner_leap_binder/leapbinder_decorators.py +11 -4
- {code_loader-1.0.94.dev1.dist-info → code_loader-1.0.94.dev2.dist-info}/METADATA +1 -1
- {code_loader-1.0.94.dev1.dist-info → code_loader-1.0.94.dev2.dist-info}/RECORD +6 -6
- {code_loader-1.0.94.dev1.dist-info → code_loader-1.0.94.dev2.dist-info}/LICENSE +0 -0
- {code_loader-1.0.94.dev1.dist-info → code_loader-1.0.94.dev2.dist-info}/WHEEL +0 -0
|
@@ -40,7 +40,7 @@ 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
|
-
|
|
43
|
+
instance_id_to_instance_name: Optional[Dict[str, str]] = None # in use only for element instance
|
|
44
44
|
|
|
45
45
|
def __post_init__(self) -> None:
|
|
46
46
|
def is_valid_string(s: str) -> bool:
|
|
@@ -48,6 +48,7 @@ class PreprocessResponse:
|
|
|
48
48
|
|
|
49
49
|
assert self.sample_ids_to_instance_mappings is None, f"Keep sample_ids_to_instance_mappings None when initializing PreprocessResponse"
|
|
50
50
|
assert self.instance_to_sample_ids_mappings is None, f"Keep instance_to_sample_ids_mappings None when initializing PreprocessResponse"
|
|
51
|
+
assert self.instance_id_to_instance_name is None, f"Keep instance_id_to_instance_name None when initializing PreprocessResponse"
|
|
51
52
|
|
|
52
53
|
if self.length is not None and self.sample_ids is None:
|
|
53
54
|
self.sample_ids = [i for i in range(self.length)]
|
|
@@ -8,7 +8,7 @@ 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, InstanceCallableInterface
|
|
11
|
+
ConfusionMatrixElement, SamplePreprocessResponse, InstanceCallableInterface, ElementInstance
|
|
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
|
|
@@ -270,29 +270,36 @@ def tensorleap_preprocess():
|
|
|
270
270
|
|
|
271
271
|
return decorating_function
|
|
272
272
|
|
|
273
|
-
def tensorleap_element_instance_preprocess(instance_mask_encoder: Callable[[int, PreprocessResponse], List[
|
|
273
|
+
def tensorleap_element_instance_preprocess(instance_mask_encoder: Callable[[int, PreprocessResponse], List[ElementInstance]]):
|
|
274
274
|
def decorating_function(user_function: Callable[[], List[PreprocessResponse]]):
|
|
275
275
|
def user_function_instance() -> List[PreprocessResponse]:
|
|
276
276
|
result = user_function()
|
|
277
277
|
for preprocess_response in result:
|
|
278
278
|
sample_ids_to_instance_mappings = {}
|
|
279
279
|
instance_to_sample_ids_mappings = {}
|
|
280
|
+
instance_id_to_instance_name = {}
|
|
280
281
|
all_sample_ids = preprocess_response.sample_ids.copy()
|
|
281
282
|
for sample_id in preprocess_response.sample_ids:
|
|
282
283
|
instances_masks = instance_mask_encoder(sample_id, preprocess_response)
|
|
284
|
+
instance_names = [instance.name for instance in instances_masks]
|
|
283
285
|
instances_ids = [f'{sample_id}_{instance_id}' for instance_id in range(len(instances_masks))]
|
|
284
286
|
sample_ids_to_instance_mappings[sample_id] = instances_ids
|
|
285
287
|
instance_to_sample_ids_mappings[sample_id] = sample_id
|
|
286
|
-
|
|
288
|
+
instance_id_to_instance_name[sample_id] = None
|
|
289
|
+
for instance_id, instance_name in zip(instances_ids, instance_names):
|
|
287
290
|
instance_to_sample_ids_mappings[instance_id] = sample_id
|
|
291
|
+
instance_id_to_instance_name[instance_id] = instance_name
|
|
288
292
|
all_sample_ids.extend(instances_ids)
|
|
289
293
|
preprocess_response.sample_ids_to_instance_mappings = sample_ids_to_instance_mappings
|
|
290
294
|
preprocess_response.instance_to_sample_ids_mappings = instance_to_sample_ids_mappings
|
|
295
|
+
preprocess_response.instance_id_to_instance_name = instance_id_to_instance_name
|
|
291
296
|
preprocess_response.sample_ids = all_sample_ids
|
|
292
297
|
return result
|
|
293
298
|
|
|
294
299
|
def metadata_is_instance(idx: str, preprocess: PreprocessResponse) -> Dict[str, str]:
|
|
295
|
-
return {'is_instance': '0',
|
|
300
|
+
return {'is_instance': '0',
|
|
301
|
+
'orig_sample_id': preprocess.instance_to_sample_ids_mappings[idx],
|
|
302
|
+
'instance_name': preprocess.instance_id_to_instance_name[idx]}
|
|
296
303
|
leap_binder.set_preprocess(user_function_instance)
|
|
297
304
|
leap_binder.set_metadata(metadata_is_instance, "metadata_is_instance")
|
|
298
305
|
|
|
@@ -1,7 +1,7 @@
|
|
|
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=PT1dMA0FxpzJ75rpc79d_oxn3zJmrdOihKTC46ZEZvI,9139
|
|
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
|
|
@@ -21,13 +21,13 @@ code_loader/experiment_api/utils.py,sha256=XZHtxge12TS4H4-8PjV3sKuhp8Ud6ojAiIzTZ
|
|
|
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
23
|
code_loader/inner_leap_binder/leapbinder.py,sha256=wmCOj_YKbRXqLL1k5Tw_FrcZgfmgnVQcjs2ok6wdlww,32362
|
|
24
|
-
code_loader/inner_leap_binder/leapbinder_decorators.py,sha256=
|
|
24
|
+
code_loader/inner_leap_binder/leapbinder_decorators.py,sha256=KNbfm8o7F-3ljys5fbVK8NP6mkPSD_itFceGFTWk4kw,29657
|
|
25
25
|
code_loader/leaploader.py,sha256=HPDZb10HPYh18_HjoIYT8ipB5pmVvL5tEI_KFKmHS7g,28866
|
|
26
26
|
code_loader/leaploaderbase.py,sha256=tpMVEd97675b_var4hvesjN7EgQzoCbPEayNBut6AvI,4551
|
|
27
27
|
code_loader/utils.py,sha256=_j8b60pimoNAvWMRj7hEkkT6C76qES6cZoBFHpXHMxA,2698
|
|
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.94.
|
|
31
|
-
code_loader-1.0.94.
|
|
32
|
-
code_loader-1.0.94.
|
|
33
|
-
code_loader-1.0.94.
|
|
30
|
+
code_loader-1.0.94.dev2.dist-info/LICENSE,sha256=qIwWjdspQeSMTtnFZBC8MuT-95L02FPvzRUdWFxrwJY,1067
|
|
31
|
+
code_loader-1.0.94.dev2.dist-info/METADATA,sha256=5rh-Eu9KRqvossEgh3kk7iSDstW5JYfVnuo6xAhFFCY,854
|
|
32
|
+
code_loader-1.0.94.dev2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
33
|
+
code_loader-1.0.94.dev2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|