learning-loop-node 0.10.4__py3-none-any.whl → 0.10.5__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 learning-loop-node might be problematic. Click here for more details.
- learning_loop_node/trainer/io_helpers.py +9 -10
- learning_loop_node/trainer/tests/states/test_state_upload_detections.py +13 -12
- {learning_loop_node-0.10.4.dist-info → learning_loop_node-0.10.5.dist-info}/METADATA +1 -1
- {learning_loop_node-0.10.4.dist-info → learning_loop_node-0.10.5.dist-info}/RECORD +5 -5
- {learning_loop_node-0.10.4.dist-info → learning_loop_node-0.10.5.dist-info}/WHEEL +0 -0
|
@@ -159,18 +159,20 @@ class ActiveTrainingIO:
|
|
|
159
159
|
async def _upload_detections_batched(self, context: Context, detections: List[Detections]):
|
|
160
160
|
batch_size = 100
|
|
161
161
|
skip_detections = self.load_detection_upload_progress()
|
|
162
|
-
up_count = 0
|
|
163
162
|
for i in range(skip_detections, len(detections), batch_size):
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
batch_detections
|
|
167
|
-
await self._upload_detections(context, batch_detections, up_progress)
|
|
163
|
+
up_progress = i + batch_size if i + batch_size < len(detections) else 0
|
|
164
|
+
batch_detections = detections[i:i + batch_size]
|
|
165
|
+
await self._upload_detections_and_save_progress(context, batch_detections, up_progress)
|
|
168
166
|
skip_detections = up_progress
|
|
169
167
|
|
|
170
168
|
logging.info('uploaded %d detections', len(detections))
|
|
171
169
|
|
|
172
|
-
async def
|
|
170
|
+
async def _upload_detections_and_save_progress(self, context: Context, batch_detections: List[Detections], up_progress: int):
|
|
171
|
+
if len(batch_detections) == 0:
|
|
172
|
+
print('skipping empty batch', flush=True)
|
|
173
|
+
return
|
|
173
174
|
detections_json = [jsonable_encoder(asdict(detections)) for detections in batch_detections]
|
|
175
|
+
print(f'uploading {len(detections_json)} detections', flush=True)
|
|
174
176
|
response = await self.loop_communicator.post(
|
|
175
177
|
f'/{context.organization}/projects/{context.project}/detections', json=detections_json)
|
|
176
178
|
if response.status_code != 200:
|
|
@@ -179,7 +181,4 @@ class ActiveTrainingIO:
|
|
|
179
181
|
raise Exception(msg)
|
|
180
182
|
|
|
181
183
|
logging.info('successfully uploaded detections')
|
|
182
|
-
|
|
183
|
-
self.save_detection_upload_progress(0)
|
|
184
|
-
else:
|
|
185
|
-
self.save_detection_upload_progress(up_progress)
|
|
184
|
+
self.save_detection_upload_progress(up_progress)
|
|
@@ -37,7 +37,7 @@ async def create_valid_detection_file(trainer: TrainerLogic, number_of_entries:
|
|
|
37
37
|
'point_detections': [], 'segmentation_detections': []})
|
|
38
38
|
detections = [detection_entry] * number_of_entries
|
|
39
39
|
|
|
40
|
-
assert trainer.active_training_io is not None
|
|
40
|
+
assert trainer.active_training_io is not None
|
|
41
41
|
trainer.active_training_io.save_detections(detections, file_index)
|
|
42
42
|
|
|
43
43
|
|
|
@@ -80,21 +80,21 @@ async def test_ensure_all_detections_are_uploaded(test_initialized_trainer: Test
|
|
|
80
80
|
create_active_training_file(trainer, training_state=TrainerState.Detected)
|
|
81
81
|
trainer._init_from_last_training()
|
|
82
82
|
|
|
83
|
-
await create_valid_detection_file(trainer,
|
|
84
|
-
await create_valid_detection_file(trainer,
|
|
83
|
+
await create_valid_detection_file(trainer, 4, 0)
|
|
84
|
+
await create_valid_detection_file(trainer, 4, 1)
|
|
85
85
|
|
|
86
86
|
assert trainer.active_training_io.load_detections_upload_file_index() == 0
|
|
87
87
|
detections = trainer.active_training_io.load_detections(0)
|
|
88
|
-
assert len(detections) ==
|
|
88
|
+
assert len(detections) == 4
|
|
89
89
|
|
|
90
|
-
batch_size =
|
|
90
|
+
batch_size = 2
|
|
91
91
|
skip_detections = trainer.active_training_io.load_detection_upload_progress()
|
|
92
92
|
for i in range(skip_detections, len(detections), batch_size):
|
|
93
93
|
batch_detections = detections[i:i+batch_size]
|
|
94
|
-
|
|
95
|
-
await trainer.active_training_io.
|
|
94
|
+
progress = i + batch_size if i + batch_size < len(detections) else 0
|
|
95
|
+
await trainer.active_training_io._upload_detections_and_save_progress(trainer.training.context, batch_detections, progress)
|
|
96
96
|
|
|
97
|
-
expected_value =
|
|
97
|
+
expected_value = progress # Progress is reset for every file
|
|
98
98
|
assert trainer.active_training_io.load_detection_upload_progress() == expected_value
|
|
99
99
|
|
|
100
100
|
assert trainer.active_training_io.load_detections_upload_file_index() == 0
|
|
@@ -107,10 +107,11 @@ async def test_ensure_all_detections_are_uploaded(test_initialized_trainer: Test
|
|
|
107
107
|
skip_detections = trainer.active_training_io.load_detection_upload_progress()
|
|
108
108
|
for i in range(skip_detections, len(detections), batch_size):
|
|
109
109
|
batch_detections = detections[i:i+batch_size]
|
|
110
|
-
# pylint: disable=protected-access
|
|
111
|
-
await trainer.active_training_io._upload_detections(trainer.training.context, batch_detections, i + batch_size)
|
|
112
110
|
|
|
113
|
-
|
|
111
|
+
progress = i + batch_size if i + batch_size < len(detections) else 0
|
|
112
|
+
await trainer.active_training_io._upload_detections_and_save_progress(trainer.training.context, batch_detections, progress)
|
|
113
|
+
|
|
114
|
+
expected_value = progress # Progress is reset for every file
|
|
114
115
|
assert trainer.active_training_io.load_detection_upload_progress() == expected_value
|
|
115
116
|
assert trainer.active_training_io.load_detections_upload_file_index() == 1
|
|
116
117
|
|
|
@@ -160,5 +161,5 @@ async def test_abort_uploading(test_initialized_trainer: TestingTrainerLogic):
|
|
|
160
161
|
await trainer.stop()
|
|
161
162
|
await asyncio.sleep(0.1)
|
|
162
163
|
|
|
163
|
-
assert trainer._training is None
|
|
164
|
+
assert trainer._training is None
|
|
164
165
|
assert trainer.node.last_training_io.exists() is False
|
|
@@ -58,7 +58,7 @@ learning_loop_node/tests/test_learning_loop_node.py,sha256=4qWi1ovBzebUAbvw8ecSa
|
|
|
58
58
|
learning_loop_node/trainer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
59
59
|
learning_loop_node/trainer/downloader.py,sha256=qzx7zzObcFEvRVQFe8gi8KJNIapASi1_XssbspXD1Rw,1469
|
|
60
60
|
learning_loop_node/trainer/executor.py,sha256=j-1pkc_5b1Y0Bh8KiQthAK7SoOfJelr5Qi7L0p1sTxE,3933
|
|
61
|
-
learning_loop_node/trainer/io_helpers.py,sha256=
|
|
61
|
+
learning_loop_node/trainer/io_helpers.py,sha256=Ylxz8HAId0Jlz95So5kXdJEp1yKQuwroDKIhbTUscF4,7257
|
|
62
62
|
learning_loop_node/trainer/rest/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
63
63
|
learning_loop_node/trainer/rest/backdoor_controls.py,sha256=YQcG0KwxzKDNYeMtHrSwr26q__N7ty0o6Kar6CLWAd0,5869
|
|
64
64
|
learning_loop_node/trainer/rest/controls.py,sha256=XF37i2edeMHKdSXyJc4ZqaTZ38u6d3u3Sb3C-Mwyfko,934
|
|
@@ -72,7 +72,7 @@ learning_loop_node/trainer/tests/states/test_state_download_train_model.py,sha25
|
|
|
72
72
|
learning_loop_node/trainer/tests/states/test_state_prepare.py,sha256=fx9_bgPTaR5ANVB8n_hW8dXcaJIh_iKEnInmhzamZ9E,2432
|
|
73
73
|
learning_loop_node/trainer/tests/states/test_state_sync_confusion_matrix.py,sha256=zfNbHB3GFSJXXoEkW-8PYtmX62md3feWp4oisyzs8A4,4773
|
|
74
74
|
learning_loop_node/trainer/tests/states/test_state_train.py,sha256=j1vedjH2EwLTgHhon6eR9ttp-Sw9ozR9-9QgAKlFO-M,3248
|
|
75
|
-
learning_loop_node/trainer/tests/states/test_state_upload_detections.py,sha256=
|
|
75
|
+
learning_loop_node/trainer/tests/states/test_state_upload_detections.py,sha256=u31gC0-Z2EVTnia1dyY2yNGDGAeyIXPfObBgrEWHhVQ,7674
|
|
76
76
|
learning_loop_node/trainer/tests/states/test_state_upload_model.py,sha256=gAXJJcoxj2EVdFJcPAeqxGAjeL1a4ofLtytnM4joi-Q,3808
|
|
77
77
|
learning_loop_node/trainer/tests/test_errors.py,sha256=8H-kjs9kEBoHWcQVJIZvW5zcwCs1VQI5Tf5I0VSbCUA,2245
|
|
78
78
|
learning_loop_node/trainer/tests/test_trainer_states.py,sha256=OBrClH6srAM2hqqel2xTtfHCeTKYZlG_S4KO2G2GrS4,1147
|
|
@@ -80,6 +80,6 @@ learning_loop_node/trainer/tests/testing_trainer_logic.py,sha256=7sQ6okiOhM4IhvR
|
|
|
80
80
|
learning_loop_node/trainer/trainer_logic.py,sha256=PJxiO1chPdvpq8UTtzv_nVam9CouCswX9b1FnRwT2Tw,8411
|
|
81
81
|
learning_loop_node/trainer/trainer_logic_generic.py,sha256=KFDuxgzrGITHQaJoGvhjHxWzhbb4Q7HBxSpks4CeGBg,24801
|
|
82
82
|
learning_loop_node/trainer/trainer_node.py,sha256=bcyOMeLXrLuLgsPqS8lwEOSZ6vCjGLgT0pLXgaylI1Q,4155
|
|
83
|
-
learning_loop_node-0.10.
|
|
84
|
-
learning_loop_node-0.10.
|
|
85
|
-
learning_loop_node-0.10.
|
|
83
|
+
learning_loop_node-0.10.5.dist-info/METADATA,sha256=91R8hxfoYIBgEeAqmzV5Durgrseq70TEsJRgD243pVs,9287
|
|
84
|
+
learning_loop_node-0.10.5.dist-info/WHEEL,sha256=WGfLGfLX43Ei_YORXSnT54hxFygu34kMpcQdmgmEwCQ,88
|
|
85
|
+
learning_loop_node-0.10.5.dist-info/RECORD,,
|
|
File without changes
|