learning-loop-node 0.10.2__py3-none-any.whl → 0.10.4__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.

@@ -43,6 +43,8 @@ class DetectorNode(Node):
43
43
  self.operation_mode: OperationMode = OperationMode.Startup
44
44
  self.connected_clients: List[str] = []
45
45
 
46
+ self.detection_lock = asyncio.Lock()
47
+
46
48
  self.outbox: Outbox = Outbox()
47
49
  self.data_exchanger = DataExchanger(
48
50
  Context(organization=self.organization, project=self.project),
@@ -300,8 +302,9 @@ class DetectorNode(Node):
300
302
  """Note: raw_image is a numpy array of type uint8, but not in the correrct shape!
301
303
  It can be converted e.g. using cv2.imdecode(raw_image, cv2.IMREAD_COLOR)"""
302
304
  loop = asyncio.get_event_loop()
305
+ await self.detection_lock.acquire()
303
306
  detections: Detections = await loop.run_in_executor(None, self.detector_logic.evaluate, raw_image)
304
-
307
+ self.detection_lock.release()
305
308
  for seg_detection in detections.segmentation_detections:
306
309
  if isinstance(seg_detection.shape, Shape):
307
310
  shapes = ','.join([str(value) for p in seg_detection.shape.points for _,
@@ -17,9 +17,9 @@ class LoopCommunicationException(Exception):
17
17
  class LoopCommunicator():
18
18
  def __init__(self) -> None:
19
19
  host: str = environment_reader.host(default='learning-loop.ai')
20
- ssl_cert_path = environment_reader.ssl_certificate_path()
21
- if ssl_cert_path:
22
- logging.info('Using SSL certificate at %s', ssl_cert_path)
20
+ self.ssl_cert_path = environment_reader.ssl_certificate_path()
21
+ if self.ssl_cert_path:
22
+ logging.info('Using SSL certificate at %s', self.ssl_cert_path)
23
23
  else:
24
24
  logging.info('No SSL certificate path set')
25
25
  self.host: str = host
@@ -28,8 +28,9 @@ class LoopCommunicator():
28
28
  self.organization: str = environment_reader.organization() # used by mock_detector
29
29
  self.project: str = environment_reader.project() # used by mock_detector
30
30
  self.base_url: str = f'http{"s" if "learning-loop.ai" in host else ""}://' + host
31
- if ssl_cert_path:
32
- self.async_client = httpx.AsyncClient(base_url=self.base_url, timeout=Timeout(60.0), verify=ssl_cert_path)
31
+ if self.ssl_cert_path:
32
+ self.async_client = httpx.AsyncClient(
33
+ base_url=self.base_url, timeout=Timeout(60.0), verify=self.ssl_cert_path)
33
34
  else:
34
35
  self.async_client = httpx.AsyncClient(base_url=self.base_url, timeout=Timeout(60.0))
35
36
  self.async_client.cookies.clear()
@@ -1,5 +1,6 @@
1
1
  import asyncio
2
2
  import logging
3
+ import ssl
3
4
  import sys
4
5
  from abc import abstractmethod
5
6
  from contextlib import asynccontextmanager
@@ -8,6 +9,7 @@ from typing import Any, Optional
8
9
 
9
10
  import aiohttp
10
11
  import socketio
12
+ from aiohttp import TCPConnector
11
13
  from fastapi import FastAPI
12
14
  from socketio import AsyncClient
13
15
 
@@ -122,8 +124,19 @@ class Node(FastAPI):
122
124
  """Create a socket.io client that communicates with the learning loop and register the events.
123
125
  Note: The method is called in startup and soft restart of detector, so the _sio_client should always be available."""
124
126
 
125
- self._sio_client = AsyncClient(request_timeout=20,
126
- http_session=aiohttp.ClientSession(cookies=self.loop_communicator.get_cookies()))
127
+ if self.loop_communicator.ssl_cert_path:
128
+ logging.info(f'SIO using SSL certificate path: {self.loop_communicator.ssl_cert_path}')
129
+ ssl_context = ssl.create_default_context(cafile=self.loop_communicator.ssl_cert_path)
130
+ ssl_context.check_hostname = False
131
+ ssl_context.verify_mode = ssl.CERT_REQUIRED
132
+ connector = TCPConnector(ssl=ssl_context)
133
+ self._sio_client = AsyncClient(request_timeout=20,
134
+ http_session=aiohttp.ClientSession(cookies=self.loop_communicator.get_cookies(),
135
+ connector=connector))
136
+
137
+ else:
138
+ self._sio_client = AsyncClient(request_timeout=20,
139
+ http_session=aiohttp.ClientSession(cookies=self.loop_communicator.get_cookies()))
127
140
 
128
141
  # pylint: disable=protected-access
129
142
  self.sio_client._trigger_event = ensure_socket_response(self.sio_client._trigger_event)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: learning-loop-node
3
- Version: 0.10.2
3
+ Version: 0.10.4
4
4
  Summary: Python Library for Nodes which connect to the Zauberzeug Learning Loop
5
5
  Home-page: https://github.com/zauberzeug/learning_loop_node
6
6
  License: MIT
@@ -62,6 +62,7 @@ You can configure connection to our Learning Loop by specifying the following en
62
62
  | LOOP_HOST | HOST | Learning Loop address (e.g. learning-loop.ai) | all |
63
63
  | LOOP_USERNAME | USERNAME | Learning Loop user name | all besides Detector |
64
64
  | LOOP_PASSWORD | PASSWORD | Learning Loop password | all besides Detector |
65
+ | LOOP_SSL_CERT_PATH | - | Path to the SSL certificate | all (opt.) |
65
66
  | LOOP_ORGANIZATION | ORGANIZATION | Organization name | Detector |
66
67
  | LOOP_PROJECT | PROJECT | Project name | Detector |
67
68
  | MIN_UNCERTAIN_THRESHOLD | PROJECT | smallest confidence (float) at which auto-upload will happen | Detector |
@@ -13,7 +13,7 @@ learning_loop_node/data_classes/training.py,sha256=hnMHZMk-WNRERyo7U97qL09v1tIdh
13
13
  learning_loop_node/data_exchanger.py,sha256=hxF0zANA35f5EV8tkQ4yjelrKuvafMaKUya0CCjVrK0,8221
14
14
  learning_loop_node/detector/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  learning_loop_node/detector/detector_logic.py,sha256=se0jRFbV7BfTvCuCI3gcUllSYIZ5dxTkvdISe6pPTRg,1660
16
- learning_loop_node/detector/detector_node.py,sha256=Qmj87e5-mmS5SnT_VlfZ1I6vhS6XWzt60H9w82LiZbk,16649
16
+ learning_loop_node/detector/detector_node.py,sha256=k05ZXOK0OiKg4U7IMSFz-N-w1DmLvB3WF5MzMkkByP4,16776
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=TD346I9ymtIP0_CJXCIKMRuiXbfVVanXNu_iHAwDd7Q,3318
19
19
  learning_loop_node/detector/inbox_filter/relevance_filter.py,sha256=s2FuwZ-tD_5obkSutstjc8pE_hLGbrv9WjrEO9t8rJ8,1011
@@ -41,8 +41,8 @@ learning_loop_node/helpers/environment_reader.py,sha256=OtCTDc0KT9r-SMygkZB_Mw-Z
41
41
  learning_loop_node/helpers/gdrive_downloader.py,sha256=zeYJciTAJVRpu_eFjwgYLCpIa6hU1d71anqEBb564Rk,1145
42
42
  learning_loop_node/helpers/log_conf.py,sha256=3yd-jaMOeD5cRIgA5w_BH2L5odf8c4-ZjD89Bdqwe44,824
43
43
  learning_loop_node/helpers/misc.py,sha256=j4is8Rv0ttnCqF-R-wP3xwEi67OI6IBJav5Woo5lyDk,7701
44
- learning_loop_node/loop_communication.py,sha256=t3G6wvdRCjXxUFT2QpLdRHrSEcI7N272gAvFTVyNSuU,6534
45
- learning_loop_node/node.py,sha256=jpTP3gnGxFDF7tq9H7MVfVIIHm8e7bYA5euttHNJAEg,7252
44
+ learning_loop_node/loop_communication.py,sha256=rG5MdavSTaREZ6OWfAUIT_qkkYPw3is2_FujLmHQeIc,6576
45
+ learning_loop_node/node.py,sha256=pJg3mO7Egwtu7ewzWWgEXMtCG17u7yZjFt-KeN9n7rM,8010
46
46
  learning_loop_node/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
47
47
  learning_loop_node/pytest.ini,sha256=8QdjmawLy1zAzXrJ88or1kpFDhJw0W5UOnDfGGs_igU,262
48
48
  learning_loop_node/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -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.2.dist-info/METADATA,sha256=CHv6dBGvmdhieoPsmN_PrzqQNi26OoVJoRW29thMGNc,9158
84
- learning_loop_node-0.10.2.dist-info/WHEEL,sha256=WGfLGfLX43Ei_YORXSnT54hxFygu34kMpcQdmgmEwCQ,88
85
- learning_loop_node-0.10.2.dist-info/RECORD,,
83
+ learning_loop_node-0.10.4.dist-info/METADATA,sha256=bOfPBBjEdohsOEBpAD7grcYOQpo5d7akcNrbxmA3hdY,9287
84
+ learning_loop_node-0.10.4.dist-info/WHEEL,sha256=WGfLGfLX43Ei_YORXSnT54hxFygu34kMpcQdmgmEwCQ,88
85
+ learning_loop_node-0.10.4.dist-info/RECORD,,