code-loader 1.0.49.dev7__py3-none-any.whl → 1.0.49.dev9__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.
- code_loader/leaploader.py +21 -14
- {code_loader-1.0.49.dev7.dist-info → code_loader-1.0.49.dev9.dist-info}/METADATA +1 -1
- {code_loader-1.0.49.dev7.dist-info → code_loader-1.0.49.dev9.dist-info}/RECORD +5 -5
- {code_loader-1.0.49.dev7.dist-info → code_loader-1.0.49.dev9.dist-info}/LICENSE +0 -0
- {code_loader-1.0.49.dev7.dist-info → code_loader-1.0.49.dev9.dist-info}/WHEEL +0 -0
code_loader/leaploader.py
CHANGED
@@ -106,16 +106,16 @@ class LeapLoader:
|
|
106
106
|
for prediction_type in setup.prediction_types
|
107
107
|
}
|
108
108
|
|
109
|
-
def get_sample(self, state: DataStateEnum,
|
109
|
+
def get_sample(self, state: DataStateEnum, sample_id: Union[int, str]) -> DatasetSample:
|
110
110
|
self.exec_script()
|
111
111
|
preprocess_result = self._preprocess_result()
|
112
|
-
if state == DataStateEnum.unlabeled and
|
112
|
+
if state == DataStateEnum.unlabeled and sample_id not in preprocess_result[state].sample_ids:
|
113
113
|
self._preprocess_result(update_unlabeled_preprocess=True)
|
114
114
|
|
115
|
-
sample = DatasetSample(inputs=self._get_inputs(state,
|
116
|
-
gt=None if state == DataStateEnum.unlabeled else self._get_gt(state,
|
117
|
-
metadata=self._get_metadata(state,
|
118
|
-
index=
|
115
|
+
sample = DatasetSample(inputs=self._get_inputs(state, sample_id),
|
116
|
+
gt=None if state == DataStateEnum.unlabeled else self._get_gt(state, sample_id),
|
117
|
+
metadata=self._get_metadata(state, sample_id),
|
118
|
+
index=sample_id,
|
119
119
|
state=state)
|
120
120
|
return sample
|
121
121
|
|
@@ -155,6 +155,13 @@ class LeapLoader:
|
|
155
155
|
test_result = DatasetTestResultPayload('preprocess')
|
156
156
|
try:
|
157
157
|
preprocess_result = self._preprocess_result()
|
158
|
+
if self.get_sample_id_type() is str:
|
159
|
+
max_allowed_item_size = np.dtype('<U256').itemsize
|
160
|
+
for state, preprocess_response in preprocess_result.items():
|
161
|
+
sample_ids_array = np.array(preprocess_response.sample_ids)
|
162
|
+
if sample_ids_array.dtype.itemsize > max_allowed_item_size:
|
163
|
+
raise Exception(f"Sample id are too long. Max allowed length is 256 charecters.")
|
164
|
+
|
158
165
|
global_leap_binder.check_preprocess(preprocess_result)
|
159
166
|
except Exception as e:
|
160
167
|
line_number, file_name, stacktrace = get_root_exception_file_and_line_number()
|
@@ -307,21 +314,21 @@ class LeapLoader:
|
|
307
314
|
return sample_ids
|
308
315
|
|
309
316
|
def _get_dataset_handlers(self, handlers: Iterable[DatasetBaseHandler],
|
310
|
-
state: DataStateEnum,
|
317
|
+
state: DataStateEnum, sample_id: Union[int, str]) -> Dict[str, npt.NDArray[np.float32]]:
|
311
318
|
result_agg = {}
|
312
319
|
preprocess_result = self._preprocess_result()
|
313
320
|
preprocess_state = preprocess_result[state]
|
314
321
|
for handler in handlers:
|
315
|
-
handler_result = handler.function(
|
322
|
+
handler_result = handler.function(sample_id, preprocess_state)
|
316
323
|
handler_name = handler.name
|
317
324
|
result_agg[handler_name] = handler_result
|
318
325
|
return result_agg
|
319
326
|
|
320
|
-
def _get_inputs(self, state: DataStateEnum,
|
321
|
-
return self._get_dataset_handlers(global_leap_binder.setup_container.inputs, state,
|
327
|
+
def _get_inputs(self, state: DataStateEnum, sample_id: Union[int, str]) -> Dict[str, npt.NDArray[np.float32]]:
|
328
|
+
return self._get_dataset_handlers(global_leap_binder.setup_container.inputs, state, sample_id)
|
322
329
|
|
323
|
-
def _get_gt(self, state: DataStateEnum,
|
324
|
-
return self._get_dataset_handlers(global_leap_binder.setup_container.ground_truths, state,
|
330
|
+
def _get_gt(self, state: DataStateEnum, sample_id: Union[int, str]) -> Dict[str, npt.NDArray[np.float32]]:
|
331
|
+
return self._get_dataset_handlers(global_leap_binder.setup_container.ground_truths, state, sample_id)
|
325
332
|
|
326
333
|
@lru_cache()
|
327
334
|
def _metadata_name_to_type(self) -> Dict[str, DatasetMetadataType]:
|
@@ -356,12 +363,12 @@ class LeapLoader:
|
|
356
363
|
|
357
364
|
return converted_value
|
358
365
|
|
359
|
-
def _get_metadata(self, state: DataStateEnum,
|
366
|
+
def _get_metadata(self, state: DataStateEnum, sample_id: Union[int, str]) -> Dict[str, Union[str, int, bool, float]]:
|
360
367
|
result_agg = {}
|
361
368
|
preprocess_result = self._preprocess_result()
|
362
369
|
preprocess_state = preprocess_result[state]
|
363
370
|
for handler in global_leap_binder.setup_container.metadata:
|
364
|
-
handler_result = handler.function(
|
371
|
+
handler_result = handler.function(sample_id, preprocess_state)
|
365
372
|
if isinstance(handler_result, dict):
|
366
373
|
for single_metadata_name, single_metadata_result in handler_result.items():
|
367
374
|
handler_name = f'{handler.name}_{single_metadata_name}'
|
@@ -19,11 +19,11 @@ code_loader/experiment_api/utils.py,sha256=XZHtxge12TS4H4-8PjV3sKuhp8Ud6ojAiIzTZ
|
|
19
19
|
code_loader/experiment_api/workingspace_config_utils.py,sha256=DLzXQCg4dgTV_YgaSbeTVzq-2ja_SQw4zi7LXwKL9cY,990
|
20
20
|
code_loader/inner_leap_binder/__init__.py,sha256=koOlJyMNYzGbEsoIbXathSmQ-L38N_pEXH_HvL7beXU,99
|
21
21
|
code_loader/inner_leap_binder/leapbinder.py,sha256=URm7W1W0KnmDqFMp1yPQrZQwm2B9DQ9oHVvAwRFkJuc,24934
|
22
|
-
code_loader/leaploader.py,sha256=
|
22
|
+
code_loader/leaploader.py,sha256=wv9pJ44w8BeuvDQpp-9uCvbMAa5IbhgXD9CeGkeEbLE,19531
|
23
23
|
code_loader/utils.py,sha256=TZAoUbA2pE8eK3Le3s5Xr4eRaYdeDMQtxotx6rh-5oE,2185
|
24
24
|
code_loader/visualizers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
25
25
|
code_loader/visualizers/default_visualizers.py,sha256=VoqO9FN84yXyMjRjHjUTOt2GdTkJRMbHbXJ1cJkREkk,2230
|
26
|
-
code_loader-1.0.49.
|
27
|
-
code_loader-1.0.49.
|
28
|
-
code_loader-1.0.49.
|
29
|
-
code_loader-1.0.49.
|
26
|
+
code_loader-1.0.49.dev9.dist-info/LICENSE,sha256=qIwWjdspQeSMTtnFZBC8MuT-95L02FPvzRUdWFxrwJY,1067
|
27
|
+
code_loader-1.0.49.dev9.dist-info/METADATA,sha256=Ug2IZqSHAzJBmDGE0m9iyoVFAXR4YZnESGMKblwB7p0,893
|
28
|
+
code_loader-1.0.49.dev9.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
29
|
+
code_loader-1.0.49.dev9.dist-info/RECORD,,
|
File without changes
|
File without changes
|