learning-loop-node 0.13.5__py3-none-any.whl → 0.13.6__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/detector/detector_logic.py +10 -18
- learning_loop_node/detector/detector_node.py +18 -9
- learning_loop_node/node.py +2 -1
- learning_loop_node/tests/detector/conftest.py +0 -4
- learning_loop_node/tests/detector/test_client_communication.py +0 -3
- {learning_loop_node-0.13.5.dist-info → learning_loop_node-0.13.6.dist-info}/METADATA +1 -1
- {learning_loop_node-0.13.5.dist-info → learning_loop_node-0.13.6.dist-info}/RECORD +8 -8
- {learning_loop_node-0.13.5.dist-info → learning_loop_node-0.13.6.dist-info}/WHEEL +0 -0
|
@@ -13,37 +13,29 @@ class DetectorLogic():
|
|
|
13
13
|
|
|
14
14
|
def __init__(self, model_format: str) -> None:
|
|
15
15
|
self.model_format: str = model_format
|
|
16
|
-
self.
|
|
16
|
+
self.model_info: Optional[ModelInformation] = None
|
|
17
17
|
|
|
18
18
|
self._remaining_init_attempts: int = 2
|
|
19
19
|
|
|
20
20
|
async def soft_reload(self):
|
|
21
|
-
self.
|
|
22
|
-
|
|
23
|
-
@property
|
|
24
|
-
def model_info(self) -> ModelInformation:
|
|
25
|
-
if self._model_info is None:
|
|
26
|
-
raise Exception('Model not loaded')
|
|
27
|
-
return self._model_info
|
|
28
|
-
|
|
29
|
-
@property
|
|
30
|
-
def is_initialized(self) -> bool:
|
|
31
|
-
return self._model_info is not None
|
|
21
|
+
self.model_info = None
|
|
32
22
|
|
|
33
23
|
def load_model_info_and_init_model(self):
|
|
34
24
|
logging.info('Loading model from %s', GLOBALS.data_folder)
|
|
35
|
-
self.
|
|
36
|
-
if self.
|
|
25
|
+
self.model_info = ModelInformation.load_from_disk(f'{GLOBALS.data_folder}/model')
|
|
26
|
+
if self.model_info is None:
|
|
37
27
|
logging.error('No model found')
|
|
38
|
-
self.
|
|
28
|
+
self.model_info = None
|
|
29
|
+
return
|
|
30
|
+
|
|
39
31
|
try:
|
|
40
32
|
self.init()
|
|
41
|
-
logging.info('Successfully loaded model %s', self.
|
|
33
|
+
logging.info('Successfully loaded model %s', self.model_info)
|
|
42
34
|
self._remaining_init_attempts = 2
|
|
43
35
|
except Exception:
|
|
44
36
|
self._remaining_init_attempts -= 1
|
|
45
|
-
self.
|
|
46
|
-
logging.error('Could not init model %s. Retries left: %s', self.
|
|
37
|
+
self.model_info = None
|
|
38
|
+
logging.error('Could not init model %s. Retries left: %s', self.model_info, self._remaining_init_attempts)
|
|
47
39
|
if self._remaining_init_attempts == 0:
|
|
48
40
|
raise NodeNeedsRestartError('Could not init model') from None
|
|
49
41
|
raise
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import contextlib
|
|
3
|
+
import math
|
|
3
4
|
import os
|
|
4
5
|
import shutil
|
|
5
6
|
import subprocess
|
|
@@ -15,8 +16,16 @@ from dacite import from_dict
|
|
|
15
16
|
from fastapi.encoders import jsonable_encoder
|
|
16
17
|
from socketio import AsyncClient
|
|
17
18
|
|
|
18
|
-
from ..data_classes import (
|
|
19
|
-
|
|
19
|
+
from ..data_classes import (
|
|
20
|
+
AboutResponse,
|
|
21
|
+
Category,
|
|
22
|
+
Context,
|
|
23
|
+
DetectionStatus,
|
|
24
|
+
ImageMetadata,
|
|
25
|
+
ModelInformation,
|
|
26
|
+
ModelVersionResponse,
|
|
27
|
+
Shape,
|
|
28
|
+
)
|
|
20
29
|
from ..data_classes.socket_response import SocketResponse
|
|
21
30
|
from ..data_exchanger import DataExchanger, DownloadError
|
|
22
31
|
from ..enums import OperationMode, VersionMode
|
|
@@ -82,13 +91,13 @@ class DetectorNode(Node):
|
|
|
82
91
|
return AboutResponse(
|
|
83
92
|
operation_mode=self.operation_mode.value,
|
|
84
93
|
state=self.status.state,
|
|
85
|
-
model_info=self.detector_logic.
|
|
94
|
+
model_info=self.detector_logic.model_info, # pylint: disable=protected-access
|
|
86
95
|
target_model=self.target_model.version if self.target_model else None,
|
|
87
96
|
version_control=self.version_control.value
|
|
88
97
|
)
|
|
89
98
|
|
|
90
99
|
def get_model_version_response(self) -> ModelVersionResponse:
|
|
91
|
-
current_version = self.detector_logic.
|
|
100
|
+
current_version = self.detector_logic.model_info.version if self.detector_logic.model_info is not None else 'None' # pylint: disable=protected-access
|
|
92
101
|
target_version = self.target_model.version if self.target_model is not None else 'None'
|
|
93
102
|
loop_version = self.loop_deployment_target.version if self.loop_deployment_target is not None else 'None'
|
|
94
103
|
|
|
@@ -237,7 +246,7 @@ class DetectorNode(Node):
|
|
|
237
246
|
|
|
238
247
|
@self.sio.event
|
|
239
248
|
async def info(sid) -> Dict:
|
|
240
|
-
if self.detector_logic.
|
|
249
|
+
if self.detector_logic.model_info is not None:
|
|
241
250
|
return asdict(self.detector_logic.model_info)
|
|
242
251
|
return {"status": "No model loaded"}
|
|
243
252
|
|
|
@@ -274,7 +283,7 @@ class DetectorNode(Node):
|
|
|
274
283
|
'''upload an image with detections'''
|
|
275
284
|
|
|
276
285
|
detection_data = data.get('detections', {})
|
|
277
|
-
if detection_data and self.detector_logic.
|
|
286
|
+
if detection_data and self.detector_logic.model_info is not None:
|
|
278
287
|
try:
|
|
279
288
|
image_metadata = from_dict(data_class=ImageMetadata, data=detection_data)
|
|
280
289
|
except Exception as e:
|
|
@@ -323,7 +332,7 @@ class DetectorNode(Node):
|
|
|
323
332
|
self.log.debug('not checking for updates; no target model selected')
|
|
324
333
|
return
|
|
325
334
|
|
|
326
|
-
if self.detector_logic.
|
|
335
|
+
if self.detector_logic.model_info is not None:
|
|
327
336
|
current_version = self.detector_logic.model_info.version
|
|
328
337
|
else:
|
|
329
338
|
current_version = None
|
|
@@ -391,9 +400,9 @@ class DetectorNode(Node):
|
|
|
391
400
|
self.log.info('Status sync failed: not connected')
|
|
392
401
|
raise Exception('Status sync failed: not connected')
|
|
393
402
|
|
|
394
|
-
|
|
403
|
+
if self.detector_logic.model_info is not None:
|
|
395
404
|
current_model = self.detector_logic.model_info.version
|
|
396
|
-
|
|
405
|
+
else:
|
|
397
406
|
current_model = None
|
|
398
407
|
|
|
399
408
|
target_model_version = self.target_model.version if self.target_model else None
|
learning_loop_node/node.py
CHANGED
|
@@ -74,6 +74,7 @@ class Node(FastAPI):
|
|
|
74
74
|
self.repeat_loop_lock = asyncio.Lock()
|
|
75
75
|
|
|
76
76
|
self.previous_state: Optional[str] = None
|
|
77
|
+
self.repeat_loop_cycle_sec = 5
|
|
77
78
|
|
|
78
79
|
def log_status_on_change(self, current_state_str: str, full_status: Any):
|
|
79
80
|
if self.previous_state != current_state_str:
|
|
@@ -146,7 +147,7 @@ class Node(FastAPI):
|
|
|
146
147
|
except Exception:
|
|
147
148
|
self.log.exception('error in repeat loop')
|
|
148
149
|
|
|
149
|
-
await asyncio.sleep(
|
|
150
|
+
await asyncio.sleep(self.repeat_loop_cycle_sec)
|
|
150
151
|
|
|
151
152
|
async def _ensure_sio_connection(self):
|
|
152
153
|
if self.socket_connection_broken or self._sio_client is None or not self.sio_client.connected:
|
|
@@ -129,10 +129,6 @@ class MockDetectorLogic(DetectorLogic): # pylint: disable=abstract-method
|
|
|
129
129
|
model_name="mock",
|
|
130
130
|
)])
|
|
131
131
|
|
|
132
|
-
@property
|
|
133
|
-
def is_initialized(self):
|
|
134
|
-
return True
|
|
135
|
-
|
|
136
132
|
def evaluate_with_all_info(self, image: np.ndarray, tags: List[str], source: Optional[str] = None, creation_date: Optional[str] = None):
|
|
137
133
|
return self.image_metadata
|
|
138
134
|
|
|
@@ -51,9 +51,6 @@ def test_rest_detect(test_detector_node: DetectorNode, grouping_key: str):
|
|
|
51
51
|
headers = {grouping_key: '0:0:0:0', 'tags': 'some_tag'}
|
|
52
52
|
|
|
53
53
|
assert isinstance(test_detector_node.detector_logic, TestingDetectorLogic)
|
|
54
|
-
# test_detector_node.detector_logic.mock_is_initialized = True
|
|
55
|
-
# print(test_detector_node.detector_logic.mock_is_initialized)
|
|
56
|
-
# print(test_detector_node.detector_logic.is_initialized)
|
|
57
54
|
response = requests.post(f'http://localhost:{GLOBALS.detector_port}/detect',
|
|
58
55
|
files=image, headers=headers, timeout=30)
|
|
59
56
|
assert response.status_code == 200
|
|
@@ -11,8 +11,8 @@ learning_loop_node/data_classes/socket_response.py,sha256=tIdt-oYf6ULoJIDYQCecNM
|
|
|
11
11
|
learning_loop_node/data_classes/training.py,sha256=FFPsr2AA7ynYz39MLZaFJ0sF_9Axll5HHbAA8nnirp0,5726
|
|
12
12
|
learning_loop_node/data_exchanger.py,sha256=IG5ki3f3IsVuXbyw6q_gUIakgv-GMT6e9nhOhzjKgW4,9055
|
|
13
13
|
learning_loop_node/detector/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
-
learning_loop_node/detector/detector_logic.py,sha256=
|
|
15
|
-
learning_loop_node/detector/detector_node.py,sha256=
|
|
14
|
+
learning_loop_node/detector/detector_logic.py,sha256=s1EFLrk_SFvLJOsIj9b0lp-Oq0DgfVWxT6Q34Vmi_JE,2243
|
|
15
|
+
learning_loop_node/detector/detector_node.py,sha256=6MUdR_WzzcubwUAiaUo7TDF2xs-VkEvB_y1sNsrONYI,25461
|
|
16
16
|
learning_loop_node/detector/exceptions.py,sha256=C6KbNPlSbtfgDrZx2Hbhm7Suk9jVoR3fMRCO0CkrMsQ,196
|
|
17
17
|
learning_loop_node/detector/inbox_filter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
18
|
learning_loop_node/detector/inbox_filter/cam_observation_history.py,sha256=1PHgXRrhSQ34HSFw7mdX8ndRxHf_i1aP5nXXnrZxhAY,3312
|
|
@@ -39,7 +39,7 @@ learning_loop_node/helpers/gdrive_downloader.py,sha256=zeYJciTAJVRpu_eFjwgYLCpIa
|
|
|
39
39
|
learning_loop_node/helpers/log_conf.py,sha256=hqVAa_9NnYEU6N0dcOKmph82p7MpgKqeF_eomTLYzWY,961
|
|
40
40
|
learning_loop_node/helpers/misc.py,sha256=J29iBmsEUAraKKDN1m1NKiHQ3QrP5ub5HBU6cllSP2g,7384
|
|
41
41
|
learning_loop_node/loop_communication.py,sha256=kc7GrkUS14Ka5OICaaOd_LZ61D-6O19GcyDEwckTxvM,7286
|
|
42
|
-
learning_loop_node/node.py,sha256=
|
|
42
|
+
learning_loop_node/node.py,sha256=IRV81q1G3-A6_BLNqB3NBT7T_dN5OXegBoM9JHMJuLM,11030
|
|
43
43
|
learning_loop_node/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
44
44
|
learning_loop_node/rest.py,sha256=omwlRHLnyG-kgCBVnZDk5_SAPobL9g7slWeX21wsPGw,1551
|
|
45
45
|
learning_loop_node/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -48,14 +48,14 @@ learning_loop_node/tests/annotator/conftest.py,sha256=G4ZvdZUdvPp9bYCzg3eEVkGCeX
|
|
|
48
48
|
learning_loop_node/tests/annotator/pytest.ini,sha256=8QdjmawLy1zAzXrJ88or1kpFDhJw0W5UOnDfGGs_igU,262
|
|
49
49
|
learning_loop_node/tests/annotator/test_annotator_node.py,sha256=UWRXRSBc1e795ftkp7xrEXbyR4LYvFDDHRpZGqC3vr8,1974
|
|
50
50
|
learning_loop_node/tests/detector/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
51
|
-
learning_loop_node/tests/detector/conftest.py,sha256=
|
|
51
|
+
learning_loop_node/tests/detector/conftest.py,sha256=gut-RaacarhWJNCvGEz7O7kj3cS7vJ4SvAxCmR87PIw,5263
|
|
52
52
|
learning_loop_node/tests/detector/inbox_filter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
53
53
|
learning_loop_node/tests/detector/inbox_filter/test_observation.py,sha256=k4WYdvnuV7d_r7zI4M2aA8WuBjm0aycQ0vj1rGE2q4w,1370
|
|
54
54
|
learning_loop_node/tests/detector/inbox_filter/test_relevance_group.py,sha256=r-wABFQVsTNTjv7vYGr8wbHfOWy43F_B14ZDWHfiZ-A,7613
|
|
55
55
|
learning_loop_node/tests/detector/inbox_filter/test_unexpected_observations_count.py,sha256=3KKwf-J9oJRMIuuVju2vT9IM9vWhKvswPiXJI8KxmcU,1661
|
|
56
56
|
learning_loop_node/tests/detector/pytest.ini,sha256=8QdjmawLy1zAzXrJ88or1kpFDhJw0W5UOnDfGGs_igU,262
|
|
57
57
|
learning_loop_node/tests/detector/test.jpg,sha256=msA-vHPmvPiro_D102Qmn1fn4vNfooqYYEXPxZUmYpk,161390
|
|
58
|
-
learning_loop_node/tests/detector/test_client_communication.py,sha256=
|
|
58
|
+
learning_loop_node/tests/detector/test_client_communication.py,sha256=PUjnWnY-9RCZe-gqrtWf3o0ylCNH3WuzHoL7v3eAjAQ,8984
|
|
59
59
|
learning_loop_node/tests/detector/test_detector_node.py,sha256=0ZMV6coAvdq-nH8CwY9_LR2tUcH9VLcAB1CWuwHQMpo,3023
|
|
60
60
|
learning_loop_node/tests/detector/test_outbox.py,sha256=IfCz4iBmYA4bm3TK4q2NmWyzQCwZWhUbBrKQNHGxZM4,3007
|
|
61
61
|
learning_loop_node/tests/detector/test_relevance_filter.py,sha256=ZKcCstFWCDxJzKdVlAe8E6sZzv5NiH8mADhaZjokHoU,2052
|
|
@@ -97,6 +97,6 @@ learning_loop_node/trainer/test_executor.py,sha256=6BVGDN_6f5GEMMEvDLSG1yzMybSvg
|
|
|
97
97
|
learning_loop_node/trainer/trainer_logic.py,sha256=eK-01qZzi10UjLMCQX8vy5eW2FoghPj3rzzDC-s3Si4,8792
|
|
98
98
|
learning_loop_node/trainer/trainer_logic_generic.py,sha256=RQqon8JIVzxaNh0KdEe6tMxebsY0DgZllEohHR-AgqU,26846
|
|
99
99
|
learning_loop_node/trainer/trainer_node.py,sha256=Dl4ZQAjjXQggibeBjvhXAoFClw1ZX2Kkt3v_fjrJnCI,4508
|
|
100
|
-
learning_loop_node-0.13.
|
|
101
|
-
learning_loop_node-0.13.
|
|
102
|
-
learning_loop_node-0.13.
|
|
100
|
+
learning_loop_node-0.13.6.dist-info/METADATA,sha256=z7dmbFXZUgUXgs-y0N-w-KwBDo8H2oVngoc1ja2Giok,12761
|
|
101
|
+
learning_loop_node-0.13.6.dist-info/WHEEL,sha256=WGfLGfLX43Ei_YORXSnT54hxFygu34kMpcQdmgmEwCQ,88
|
|
102
|
+
learning_loop_node-0.13.6.dist-info/RECORD,,
|
|
File without changes
|