learning-loop-node 0.9.2__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.

Files changed (55) hide show
  1. learning_loop_node/__init__.py +2 -3
  2. learning_loop_node/annotation/annotator_logic.py +2 -2
  3. learning_loop_node/annotation/annotator_node.py +16 -15
  4. learning_loop_node/data_classes/__init__.py +17 -10
  5. learning_loop_node/data_classes/detections.py +7 -2
  6. learning_loop_node/data_classes/general.py +8 -5
  7. learning_loop_node/data_classes/training.py +49 -21
  8. learning_loop_node/data_exchanger.py +85 -139
  9. learning_loop_node/detector/__init__.py +0 -1
  10. learning_loop_node/detector/detector_logic.py +0 -2
  11. learning_loop_node/detector/detector_node.py +14 -15
  12. learning_loop_node/detector/inbox_filter/cam_observation_history.py +4 -7
  13. learning_loop_node/detector/outbox.py +0 -1
  14. learning_loop_node/detector/rest/about.py +25 -0
  15. learning_loop_node/detector/tests/conftest.py +4 -1
  16. learning_loop_node/detector/tests/test_client_communication.py +18 -0
  17. learning_loop_node/detector/tests/test_outbox.py +2 -0
  18. learning_loop_node/detector/tests/testing_detector.py +0 -7
  19. learning_loop_node/globals.py +2 -2
  20. learning_loop_node/helpers/gdrive_downloader.py +1 -1
  21. learning_loop_node/helpers/misc.py +124 -17
  22. learning_loop_node/loop_communication.py +57 -25
  23. learning_loop_node/node.py +62 -135
  24. learning_loop_node/tests/test_downloader.py +8 -7
  25. learning_loop_node/tests/test_executor.py +14 -11
  26. learning_loop_node/tests/test_helper.py +3 -5
  27. learning_loop_node/trainer/downloader.py +1 -1
  28. learning_loop_node/trainer/executor.py +87 -83
  29. learning_loop_node/trainer/io_helpers.py +66 -9
  30. learning_loop_node/trainer/rest/backdoor_controls.py +10 -5
  31. learning_loop_node/trainer/rest/controls.py +3 -1
  32. learning_loop_node/trainer/tests/conftest.py +19 -28
  33. learning_loop_node/trainer/tests/states/test_state_cleanup.py +5 -3
  34. learning_loop_node/trainer/tests/states/test_state_detecting.py +23 -20
  35. learning_loop_node/trainer/tests/states/test_state_download_train_model.py +18 -12
  36. learning_loop_node/trainer/tests/states/test_state_prepare.py +13 -12
  37. learning_loop_node/trainer/tests/states/test_state_sync_confusion_matrix.py +21 -18
  38. learning_loop_node/trainer/tests/states/test_state_train.py +27 -28
  39. learning_loop_node/trainer/tests/states/test_state_upload_detections.py +34 -32
  40. learning_loop_node/trainer/tests/states/test_state_upload_model.py +22 -20
  41. learning_loop_node/trainer/tests/test_errors.py +20 -12
  42. learning_loop_node/trainer/tests/test_trainer_states.py +4 -5
  43. learning_loop_node/trainer/tests/testing_trainer_logic.py +25 -30
  44. learning_loop_node/trainer/trainer_logic.py +80 -590
  45. learning_loop_node/trainer/trainer_logic_generic.py +495 -0
  46. learning_loop_node/trainer/trainer_node.py +27 -106
  47. {learning_loop_node-0.9.2.dist-info → learning_loop_node-0.10.0.dist-info}/METADATA +1 -1
  48. learning_loop_node-0.10.0.dist-info/RECORD +85 -0
  49. learning_loop_node/converter/converter_logic.py +0 -68
  50. learning_loop_node/converter/converter_node.py +0 -125
  51. learning_loop_node/converter/tests/test_converter.py +0 -55
  52. learning_loop_node/trainer/training_syncronizer.py +0 -52
  53. learning_loop_node-0.9.2.dist-info/RECORD +0 -87
  54. /learning_loop_node/{converter/__init__.py → py.typed} +0 -0
  55. {learning_loop_node-0.9.2.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, Training, TrainingState
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 = TrainingState.Preparing
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 == 'preparing'
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, Union
3
+ from typing import Dict, List, Optional
4
4
 
5
- from learning_loop_node.data_classes import BasicModel, Context, Detections, ModelInformation, PretrainedModel
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._can_resume: bool = can_resume
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
- PretrainedModel(name='small', label='Small', description='a small model'),
30
- PretrainedModel(name='medium', label='Medium', description='a medium model'),
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 start_training(self, model: str = 'model.model') -> None:
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 start_training_from_scratch(self, base_model_id: str) -> None:
39
- await self.start_training(model=f'model_{base_model_id}.pt')
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 get_new_model(self) -> Optional[BasicModel]:
41
+ def _get_new_best_training_state(self) -> Optional[TrainingStateData]:
42
42
  if self.has_new_model:
43
- return BasicModel(confusion_matrix={})
43
+ return TrainingStateData(confusion_matrix={})
44
44
  return None
45
45
 
46
- def on_model_published(self, basic_model: BasicModel) -> None:
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 ensure_confusion_matrix_synced(self):
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().ensure_confusion_matrix_synced()
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 upload_model(self) -> None:
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().upload_model()
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 get_latest_model_files(self) -> Union[List[str], Dict[str, List[str]]]:
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 can_resume(self) -> bool:
86
- return self._can_resume
80
+ def _can_resume(self) -> bool:
81
+ return self._can_resume_flag
87
82
 
88
- async def resume(self) -> None:
89
- return await self.start_training()
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 clear_training_data(self, training_folder: str) -> None:
90
+ async def _clear_training_data(self, training_folder: str) -> None:
96
91
  return
97
92
 
98
- def get_executor_error_from_log(self) -> Optional[str]:
93
+ def _get_executor_error_from_log(self) -> Optional[str]:
99
94
  return self.error_msg