learning-loop-node 0.19.0__py3-none-any.whl → 0.20.1__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.
- learning_loop_node/trainer/trainer_logic.py +6 -11
- learning_loop_node/trainer/trainer_logic_generic.py +8 -3
- learning_loop_node/trainer/trainer_node.py +9 -0
- {learning_loop_node-0.19.0.dist-info → learning_loop_node-0.20.1.dist-info}/METADATA +1 -1
- {learning_loop_node-0.19.0.dist-info → learning_loop_node-0.20.1.dist-info}/RECORD +7 -7
- {learning_loop_node-0.19.0.dist-info → learning_loop_node-0.20.1.dist-info}/WHEEL +1 -1
- {learning_loop_node-0.19.0.dist-info → learning_loop_node-0.20.1.dist-info}/top_level.txt +0 -0
|
@@ -79,9 +79,12 @@ class TrainerLogic(TrainerLogicGeneric):
|
|
|
79
79
|
|
|
80
80
|
except TrainingError:
|
|
81
81
|
logging.exception('Exception in trainer_logic._train')
|
|
82
|
-
await self.executor.stop_and_wait()
|
|
83
82
|
self.training.training_state = previous_state
|
|
84
83
|
raise
|
|
84
|
+
finally:
|
|
85
|
+
# shield so the subprocess is stopped even when the task is cancelled (e.g. on abort())
|
|
86
|
+
if self._executor and self._executor.is_running():
|
|
87
|
+
await asyncio.shield(self.executor.stop_and_wait())
|
|
85
88
|
|
|
86
89
|
async def _do_detections(self) -> None:
|
|
87
90
|
context = self.training.context
|
|
@@ -147,20 +150,12 @@ class TrainerLogic(TrainerLogicGeneric):
|
|
|
147
150
|
async def stop(self) -> None:
|
|
148
151
|
"""If executor is running, stop it. Else cancel training task."""
|
|
149
152
|
print('===============> stop received in trainer_logic.', flush=True)
|
|
150
|
-
|
|
151
153
|
if not self.training_active:
|
|
152
154
|
return
|
|
153
155
|
if self._executor and self._executor.is_running():
|
|
154
156
|
await self.executor.stop_and_wait()
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
if self.training_task.cancel():
|
|
158
|
-
try:
|
|
159
|
-
await self.training_task
|
|
160
|
-
except asyncio.CancelledError:
|
|
161
|
-
pass
|
|
162
|
-
logging.info('cancelled training task')
|
|
163
|
-
self._may_restart()
|
|
157
|
+
return
|
|
158
|
+
await super().stop()
|
|
164
159
|
|
|
165
160
|
# ---------------------------------------- ABSTRACT METHODS ----------------------------------------
|
|
166
161
|
|
|
@@ -470,18 +470,23 @@ class TrainerLogicGeneric(ABC):
|
|
|
470
470
|
await self.stop()
|
|
471
471
|
|
|
472
472
|
async def stop(self):
|
|
473
|
-
"""
|
|
473
|
+
"""Stop the training. Default is to abort.
|
|
474
|
+
"""
|
|
475
|
+
await self.abort()
|
|
476
|
+
|
|
477
|
+
async def abort(self):
|
|
478
|
+
"""Abort the training: cancel the task immediately and discards in-progress model.
|
|
474
479
|
"""
|
|
475
480
|
if not self.training_active:
|
|
476
481
|
return
|
|
477
482
|
if self.training_task:
|
|
478
|
-
logger.info('
|
|
483
|
+
logger.info('aborting training task')
|
|
479
484
|
if self.training_task.cancel():
|
|
480
485
|
try:
|
|
481
486
|
await self.training_task
|
|
482
487
|
except asyncio.CancelledError:
|
|
483
488
|
pass
|
|
484
|
-
logger.info('
|
|
489
|
+
logger.info('aborted training task')
|
|
485
490
|
self._may_restart()
|
|
486
491
|
|
|
487
492
|
def _may_restart(self) -> None:
|
|
@@ -76,6 +76,15 @@ class TrainerNode(Node):
|
|
|
76
76
|
self.log.exception('error in stop_training. Exception:')
|
|
77
77
|
return True
|
|
78
78
|
|
|
79
|
+
@sio_client.event
|
|
80
|
+
async def abort_training():
|
|
81
|
+
self.log.info('abort_training received. Current state : %s', self.trainer_logic.state)
|
|
82
|
+
try:
|
|
83
|
+
await self.trainer_logic.abort()
|
|
84
|
+
except Exception:
|
|
85
|
+
self.log.exception('error in abort_training. Exception:')
|
|
86
|
+
return True
|
|
87
|
+
|
|
79
88
|
async def send_status(self):
|
|
80
89
|
if not self.sio_client or not self.sio_client.connected:
|
|
81
90
|
self.log.debug('cannot send status - not connected to the Learning Loop')
|
|
@@ -50,12 +50,12 @@ learning_loop_node/trainer/exceptions.py,sha256=vbuoE6kssLQuA8zd3LiDHmZglP6E2IJJ
|
|
|
50
50
|
learning_loop_node/trainer/executor.py,sha256=XQ1TwgOF2pQv7bgzSaljDWG4I1ySjYXL8r9c_p9MX1Q,3947
|
|
51
51
|
learning_loop_node/trainer/io_helpers.py,sha256=zWl0-HLP8zxOG3ybm76vXgEozULj_1QRl95jkrF126k,7255
|
|
52
52
|
learning_loop_node/trainer/test_executor.py,sha256=6BVGDN_6f5GEMMEvDLSG1yzMybSvgXaP5uYpSfsVPP0,2224
|
|
53
|
-
learning_loop_node/trainer/trainer_logic.py,sha256=
|
|
54
|
-
learning_loop_node/trainer/trainer_logic_generic.py,sha256=
|
|
55
|
-
learning_loop_node/trainer/trainer_node.py,sha256=
|
|
53
|
+
learning_loop_node/trainer/trainer_logic.py,sha256=BgkeDEVaRVuRETYMt2rKe5cspExTgnO7LXNVYVbIcsw,8679
|
|
54
|
+
learning_loop_node/trainer/trainer_logic_generic.py,sha256=IRP68ZGpnOX4OS03OwB7HmTUvk6nbBRmCjMCVupGE_Q,27196
|
|
55
|
+
learning_loop_node/trainer/trainer_node.py,sha256=ZnydfHJ2ehAhb821Xke_09qthCE3vDf7iqeYUrliSSo,4938
|
|
56
56
|
learning_loop_node/trainer/rest/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
57
57
|
learning_loop_node/trainer/rest/backdoor_controls.py,sha256=ZnK8ypY5r_q0-YZbtaOxhQThzuZvMsQHM5gJGESd_dE,5131
|
|
58
|
-
learning_loop_node-0.
|
|
59
|
-
learning_loop_node-0.
|
|
60
|
-
learning_loop_node-0.
|
|
61
|
-
learning_loop_node-0.
|
|
58
|
+
learning_loop_node-0.20.1.dist-info/METADATA,sha256=8dCz3CJ2-uiWstXKUzKrRirUdukjQP3nbqDLdcTcIhU,15383
|
|
59
|
+
learning_loop_node-0.20.1.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
60
|
+
learning_loop_node-0.20.1.dist-info/top_level.txt,sha256=nS5qiFc4stVF_VXVCVJxZnrqVOv3IGX5-_E3sLby6OE,19
|
|
61
|
+
learning_loop_node-0.20.1.dist-info/RECORD,,
|
|
File without changes
|