learning-loop-node 0.9.3__py3-none-any.whl → 0.10.0__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/__init__.py +2 -3
- learning_loop_node/annotation/annotator_logic.py +2 -2
- learning_loop_node/annotation/annotator_node.py +16 -15
- learning_loop_node/data_classes/__init__.py +17 -10
- learning_loop_node/data_classes/detections.py +7 -2
- learning_loop_node/data_classes/general.py +4 -5
- learning_loop_node/data_classes/training.py +49 -21
- learning_loop_node/data_exchanger.py +85 -139
- learning_loop_node/detector/__init__.py +0 -1
- learning_loop_node/detector/detector_node.py +10 -13
- learning_loop_node/detector/inbox_filter/cam_observation_history.py +4 -7
- learning_loop_node/detector/outbox.py +0 -1
- learning_loop_node/detector/rest/about.py +1 -0
- learning_loop_node/detector/tests/conftest.py +0 -1
- learning_loop_node/detector/tests/test_client_communication.py +5 -3
- learning_loop_node/detector/tests/test_outbox.py +2 -0
- learning_loop_node/detector/tests/testing_detector.py +1 -8
- learning_loop_node/globals.py +2 -2
- learning_loop_node/helpers/gdrive_downloader.py +1 -1
- learning_loop_node/helpers/misc.py +124 -17
- learning_loop_node/loop_communication.py +57 -25
- learning_loop_node/node.py +62 -135
- learning_loop_node/tests/test_downloader.py +8 -7
- learning_loop_node/tests/test_executor.py +14 -11
- learning_loop_node/tests/test_helper.py +3 -5
- learning_loop_node/trainer/downloader.py +1 -1
- learning_loop_node/trainer/executor.py +87 -83
- learning_loop_node/trainer/io_helpers.py +66 -9
- learning_loop_node/trainer/rest/backdoor_controls.py +10 -5
- learning_loop_node/trainer/rest/controls.py +3 -1
- learning_loop_node/trainer/tests/conftest.py +19 -28
- learning_loop_node/trainer/tests/states/test_state_cleanup.py +5 -3
- learning_loop_node/trainer/tests/states/test_state_detecting.py +23 -20
- learning_loop_node/trainer/tests/states/test_state_download_train_model.py +18 -12
- learning_loop_node/trainer/tests/states/test_state_prepare.py +13 -12
- learning_loop_node/trainer/tests/states/test_state_sync_confusion_matrix.py +21 -18
- learning_loop_node/trainer/tests/states/test_state_train.py +27 -28
- learning_loop_node/trainer/tests/states/test_state_upload_detections.py +34 -32
- learning_loop_node/trainer/tests/states/test_state_upload_model.py +22 -20
- learning_loop_node/trainer/tests/test_errors.py +20 -12
- learning_loop_node/trainer/tests/test_trainer_states.py +4 -5
- learning_loop_node/trainer/tests/testing_trainer_logic.py +25 -30
- learning_loop_node/trainer/trainer_logic.py +80 -590
- learning_loop_node/trainer/trainer_logic_generic.py +495 -0
- learning_loop_node/trainer/trainer_node.py +27 -106
- {learning_loop_node-0.9.3.dist-info → learning_loop_node-0.10.0.dist-info}/METADATA +1 -1
- learning_loop_node-0.10.0.dist-info/RECORD +85 -0
- learning_loop_node/converter/converter_logic.py +0 -68
- learning_loop_node/converter/converter_node.py +0 -125
- learning_loop_node/converter/tests/test_converter.py +0 -55
- learning_loop_node/trainer/training_syncronizer.py +0 -52
- learning_loop_node-0.9.3.dist-info/RECORD +0 -88
- /learning_loop_node/{converter/__init__.py → py.typed} +0 -0
- {learning_loop_node-0.9.3.dist-info → learning_loop_node-0.10.0.dist-info}/WHEEL +0 -0
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
|
|
2
2
|
from uuid import uuid4
|
|
3
3
|
|
|
4
|
-
from learning_loop_node.data_classes import Context,
|
|
4
|
+
from learning_loop_node.data_classes import Context, TrainerState, Training
|
|
5
5
|
from learning_loop_node.trainer.io_helpers import LastTrainingIO
|
|
6
|
-
from learning_loop_node.trainer.tests.testing_trainer_logic import
|
|
7
|
-
TestingTrainerLogic
|
|
6
|
+
from learning_loop_node.trainer.tests.testing_trainer_logic import TestingTrainerLogic
|
|
8
7
|
from learning_loop_node.trainer.trainer_node import TrainerNode
|
|
9
8
|
|
|
10
9
|
|
|
@@ -27,8 +26,8 @@ def test_fixture_trainer_node(test_initialized_trainer_node):
|
|
|
27
26
|
def test_save_load_training():
|
|
28
27
|
training = create_training()
|
|
29
28
|
last_training_io = LastTrainingIO('00000000-0000-0000-0000-000000000000')
|
|
30
|
-
training.training_state =
|
|
29
|
+
training.training_state = TrainerState.Preparing
|
|
31
30
|
last_training_io.save(training)
|
|
32
31
|
|
|
33
32
|
training = last_training_io.load()
|
|
34
|
-
assert training.training_state ==
|
|
33
|
+
assert training.training_state == TrainerState.Preparing
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import time
|
|
3
|
-
from typing import Dict, List, Optional
|
|
3
|
+
from typing import Dict, List, Optional
|
|
4
4
|
|
|
5
|
-
from learning_loop_node.data_classes import
|
|
5
|
+
from learning_loop_node.data_classes import Context, Detections, ModelInformation, PretrainedModel, TrainingStateData
|
|
6
6
|
from learning_loop_node.trainer.trainer_logic import TrainerLogic
|
|
7
7
|
|
|
8
8
|
|
|
@@ -11,7 +11,7 @@ class TestingTrainerLogic(TrainerLogic):
|
|
|
11
11
|
|
|
12
12
|
def __init__(self, can_resume: bool = False) -> None:
|
|
13
13
|
super().__init__('mocked')
|
|
14
|
-
self.
|
|
14
|
+
self._can_resume_flag: bool = can_resume
|
|
15
15
|
self.has_new_model: bool = False
|
|
16
16
|
self.error_msg: Optional[str] = None
|
|
17
17
|
|
|
@@ -25,25 +25,25 @@ class TestingTrainerLogic(TrainerLogic):
|
|
|
25
25
|
|
|
26
26
|
@property
|
|
27
27
|
def provided_pretrained_models(self) -> List[PretrainedModel]:
|
|
28
|
-
return [
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
PretrainedModel(name='large', label='Large', description='a large model')]
|
|
28
|
+
return [PretrainedModel(name='small', label='Small', description='a small model'),
|
|
29
|
+
PretrainedModel(name='medium', label='Medium', description='a medium model'),
|
|
30
|
+
PretrainedModel(name='large', label='Large', description='a large model')]
|
|
32
31
|
|
|
33
32
|
# pylint: disable=unused-argument
|
|
34
|
-
async def
|
|
33
|
+
async def _start_training_from_base_model(self, model: str = 'model.model') -> None:
|
|
35
34
|
assert self._executor is not None
|
|
36
|
-
self._executor.start('while true; do sleep 1; done')
|
|
35
|
+
await self._executor.start('/bin/bash -c "while true; do sleep 1; done"')
|
|
37
36
|
|
|
38
|
-
async def
|
|
39
|
-
|
|
37
|
+
async def _start_training_from_scratch(self) -> None:
|
|
38
|
+
assert self.training.base_model_uuid_or_name is not None, 'base_model_uuid_or_name must be set'
|
|
39
|
+
await self._start_training_from_base_model(model=f'model_{self.training.base_model_uuid_or_name}.pt')
|
|
40
40
|
|
|
41
|
-
def
|
|
41
|
+
def _get_new_best_training_state(self) -> Optional[TrainingStateData]:
|
|
42
42
|
if self.has_new_model:
|
|
43
|
-
return
|
|
43
|
+
return TrainingStateData(confusion_matrix={})
|
|
44
44
|
return None
|
|
45
45
|
|
|
46
|
-
def
|
|
46
|
+
def _on_metrics_published(self, training_state_data: TrainingStateData) -> None:
|
|
47
47
|
pass
|
|
48
48
|
|
|
49
49
|
async def _prepare(self) -> None:
|
|
@@ -54,24 +54,19 @@ class TestingTrainerLogic(TrainerLogic):
|
|
|
54
54
|
await super()._download_model()
|
|
55
55
|
await asyncio.sleep(0.1) # give tests a bit time to to check for the state
|
|
56
56
|
|
|
57
|
-
async def
|
|
57
|
+
async def _upload_model(self) -> None:
|
|
58
58
|
await asyncio.sleep(0.1) # give tests a bit time to to check for the state
|
|
59
|
-
await super().
|
|
59
|
+
await super()._upload_model()
|
|
60
60
|
await asyncio.sleep(0.1) # give tests a bit time to to check for the state
|
|
61
61
|
|
|
62
|
-
async def
|
|
62
|
+
async def _upload_model_return_new_model_uuid(self, context: Context) -> Optional[str]:
|
|
63
63
|
await asyncio.sleep(0.1) # give tests a bit time to to check for the state
|
|
64
|
-
await super().
|
|
65
|
-
await asyncio.sleep(0.1) # give tests a bit time to to check for the state
|
|
66
|
-
|
|
67
|
-
async def _upload_model_return_new_id(self, context: Context) -> Optional[str]:
|
|
68
|
-
await asyncio.sleep(0.1) # give tests a bit time to to check for the state
|
|
69
|
-
result = await super()._upload_model_return_new_id(context)
|
|
64
|
+
result = await super()._upload_model_return_new_model_uuid(context)
|
|
70
65
|
await asyncio.sleep(0.1) # give tests a bit time to to check for the state
|
|
71
66
|
assert isinstance(result, str)
|
|
72
67
|
return result
|
|
73
68
|
|
|
74
|
-
def
|
|
69
|
+
async def _get_latest_model_files(self) -> Dict[str, List[str]]:
|
|
75
70
|
time.sleep(1) # NOTE reduce flakyness in Backend tests du to wrong order of events.
|
|
76
71
|
fake_weight_file = '/tmp/weightfile.weights'
|
|
77
72
|
with open(fake_weight_file, 'wb') as f:
|
|
@@ -82,18 +77,18 @@ class TestingTrainerLogic(TrainerLogic):
|
|
|
82
77
|
f.write('zweiundvierzig')
|
|
83
78
|
return {'mocked': [fake_weight_file, more_data_file], 'mocked_2': [fake_weight_file, more_data_file]}
|
|
84
79
|
|
|
85
|
-
def
|
|
86
|
-
return self.
|
|
80
|
+
def _can_resume(self) -> bool:
|
|
81
|
+
return self._can_resume_flag
|
|
87
82
|
|
|
88
|
-
async def
|
|
89
|
-
return await self.
|
|
83
|
+
async def _resume(self) -> None:
|
|
84
|
+
return await self._start_training_from_base_model()
|
|
90
85
|
|
|
91
86
|
async def _detect(self, model_information: ModelInformation, images: List[str], model_folder: str) -> List[Detections]:
|
|
92
87
|
detections: List[Detections] = []
|
|
93
88
|
return detections
|
|
94
89
|
|
|
95
|
-
async def
|
|
90
|
+
async def _clear_training_data(self, training_folder: str) -> None:
|
|
96
91
|
return
|
|
97
92
|
|
|
98
|
-
def
|
|
93
|
+
def _get_executor_error_from_log(self) -> Optional[str]:
|
|
99
94
|
return self.error_msg
|