Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
denniswittich committed Apr 18, 2024
2 parents d9656dc + 11d0b66 commit a916c60
Show file tree
Hide file tree
Showing 69 changed files with 1,553 additions and 1,930 deletions.
5 changes: 5 additions & 0 deletions .syncignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.git/
__pycache__/
.DS_Store
*.tmp
.env
10 changes: 9 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@
"--disable=W0718", // Catching too general exception
"--disable=W0719", // Raising too general exception
"--disable=W1203", // Use % formatting in logging functions and pass the % parameters as arguments
"--disable=W1514" // Using open without explicitly specifying an encoding
"--disable=W1514", // Using open without explicitly specifying an encoding
"--disable=R0902", // Too many instance attributes
"--disable=R0903", // Too few public methods
"--disable=R0912", // Too many branches
"--disable=R0913", // Too many arguments
"--disable=R0914", // Too many local variables
"--disable=R0915", // Too many statements
"--disable=R1732", // Consider using with for resource-allocating operations
"--disable=R0801" // Similar lines in 2 files
],
"[python]": {
"editor.defaultFormatter": "ms-python.autopep8",
Expand Down
5 changes: 2 additions & 3 deletions learning_loop_node/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import logging
import os
import sys

from .converter.converter_node import ConverterNode
# from . import log_conf
from .detector.detector_logic import DetectorLogic
from .detector.detector_node import DetectorNode
from .globals import GLOBALS
from .trainer.trainer_node import TrainerNode

__all__ = ['TrainerNode', 'DetectorNode', 'DetectorLogic', 'GLOBALS']

logging.info('>>>>>>>>>>>>>>>>>> LOOP INITIALIZED <<<<<<<<<<<<<<<<<<<<<<<')
4 changes: 2 additions & 2 deletions learning_loop_node/annotation/annotator_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

class AnnotatorLogic():

def __init__(self):
def __init__(self) -> None:
self._node: Optional[Node] = None

def init(self, node: Node):
def init(self, node: Node) -> None:
self._node = node

@abstractmethod
Expand Down
31 changes: 16 additions & 15 deletions learning_loop_node/annotation/annotator_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from ..data_classes import AnnotationNodeStatus, Context, NodeState, UserInput
from ..data_classes.socket_response import SocketResponse
from ..data_exchanger import DataExchanger
from ..helpers.misc import create_image_folder
from ..helpers.misc import create_image_folder, create_project_folder
from ..node import Node
from .annotator_logic import AnnotatorLogic

Expand All @@ -18,10 +18,11 @@
class AnnotatorNode(Node):

def __init__(self, name: str, annotator_logic: AnnotatorLogic, uuid: Optional[str] = None):
super().__init__(name, uuid)
super().__init__(name, uuid, 'annotation_node')
self.tool = annotator_logic
self.histories: Dict = {}
annotator_logic.init(self)
self.status_sent = False

def register_sio_events(self, sio_client: AsyncClient):

Expand Down Expand Up @@ -50,8 +51,6 @@ async def _handle_user_input(self, user_input_dict: Dict) -> str:
raise

if tool_result.annotation:
if not self.sio_is_initialized():
raise Exception('Socket client waas not initialized')
await self.sio_client.call('update_segmentation_annotation', (user_input.data.context.organization,
user_input.data.context.project,
jsonable_encoder(asdict(tool_result.annotation))), timeout=30)
Expand All @@ -67,6 +66,9 @@ def get_history(self, frontend_id: str) -> Dict:
return self.histories.setdefault(frontend_id, self.tool.create_empty_history())

async def send_status(self):
if self.status_sent:
return

status = AnnotationNodeStatus(
id=self.uuid,
name=self.name,
Expand All @@ -75,33 +77,32 @@ async def send_status(self):
)

self.log.info(f'Sending status {status}')
if self._sio_client is None:
raise Exception('No socket client')
result = await self._sio_client.call('update_annotation_node', jsonable_encoder(asdict(status)), timeout=10)
try:
result = await self.sio_client.call('update_annotation_node', jsonable_encoder(asdict(status)), timeout=10)
except Exception as e:
self.log.error(f'Error for updating: {str(e)}')
return

assert isinstance(result, Dict)
response = from_dict(data_class=SocketResponse, data=result)

if not response.success:
self.log.error(f'Error for updating: Response from loop was : {asdict(response)}')
else:
self.status_sent = True

async def download_image(self, context: Context, uuid: str):
project_folder = Node.create_project_folder(context)
project_folder = create_project_folder(context)
images_folder = create_image_folder(project_folder)

downloader = DataExchanger(context=context, loop_communicator=self.loop_communicator)
await downloader.download_images([uuid], images_folder)

async def get_state(self):
return NodeState.Online

def get_node_type(self):
return 'annotation_node'

async def on_startup(self):
pass

async def on_shutdown(self):
pass

async def on_repeat(self):
pass
await self.send_status()
68 changes: 0 additions & 68 deletions learning_loop_node/converter/converter_logic.py

This file was deleted.

125 changes: 0 additions & 125 deletions learning_loop_node/converter/converter_node.py

This file was deleted.

55 changes: 0 additions & 55 deletions learning_loop_node/converter/tests/test_converter.py

This file was deleted.

Loading

0 comments on commit a916c60

Please sign in to comment.