Skip to content

Commit 27f61cf

Browse files
authored
Refactor Zenoh message modules and session handling (#53)
* Refactor Zenoh message modules and session handling Moved message definitions from 'zenoh_idl' to new 'zenoh_msgs/idl' package and updated imports accordingly. Added 'zenoh_msgs/session.py' to encapsulate Zenoh session creation logic, replacing direct usage of zenoh.open() in audio stream modules. Cleaned up old 'zenoh_idl' package and updated __init__.py files for new structure. * Update package include from zenoh_idl to zenoh_msgs Changed the included package in pyproject.toml from 'zenoh_idl' to 'zenoh_msgs' to reflect the correct package structure. * Fix import
1 parent b340d84 commit 27f61cf

11 files changed

Lines changed: 129 additions & 11 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ packages = [
88
{ include = "om1_speech", from = "src" },
99
{ include = "om1_utils", from = "src" },
1010
{ include = "om1_vlm", from = "src" },
11-
{ include = "zenoh_idl", from = "src" }
11+
{ include = "zenoh_msgs", from = "src" }
1212
]
1313

1414
[tool.poetry.scripts]

src/om1_speech/audio/audio_input_stream.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@
99
from typing import Any, Callable, Dict, Generator, List, Optional, Tuple, Union
1010

1111
import pyaudio
12-
import zenoh
1312

14-
from zenoh_idl.status_msgs import AudioStatus
15-
from zenoh_idl.std_msgs import String, prepare_header
13+
from zenoh_msgs import AudioStatus, String, open_zenoh_session, prepare_header
1614

1715
root_package_name = __name__.split(".")[0] if "." in __name__ else __name__
1816
logger = logging.getLogger(root_package_name)
@@ -101,7 +99,7 @@ def __init__(
10199
self.audio_status = None
102100

103101
try:
104-
self.session = zenoh.open(zenoh.Config())
102+
self.session = open_zenoh_session()
105103
self.pub = self.session.declare_publisher(self.topic)
106104
self.session.declare_subscriber(self.topic, self.zenoh_audio_message)
107105
except Exception as e:

src/om1_speech/audio/audio_output_stream.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010
from typing import Callable, Dict, Optional
1111

1212
import requests
13-
import zenoh
1413

15-
from zenoh_idl.status_msgs import AudioStatus
16-
from zenoh_idl.std_msgs import String, prepare_header
14+
from zenoh_msgs import AudioStatus, String, open_zenoh_session, prepare_header
1715

1816
root_package_name = __name__.split(".")[0] if "." in __name__ else __name__
1917
logger = logging.getLogger(root_package_name)
@@ -61,7 +59,7 @@ def __init__(
6159
self.audio_status = None
6260

6361
try:
64-
self.session = zenoh.open(zenoh.Config())
62+
self.session = open_zenoh_session()
6563
self.pub = self.session.declare_publisher(self.topic)
6664
self.session.declare_subscriber(self.topic, self.zenoh_audio_message)
6765
except Exception as e:

src/om1_utils/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
from . import http, logging, ws
2+
from .logging import LoggingConfig, get_logging_config, setup_logging
23
from .singleton import singleton
34

4-
__all__ = ["ws", "http", "logging", "singleton"]
5+
__all__ = [
6+
"ws",
7+
"http",
8+
"logging",
9+
"singleton",
10+
"setup_logging",
11+
"get_logging_config",
12+
"LoggingConfig",
13+
]

src/om1_vlm/video/video_stream_blur_face.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import cv2
1414
import numpy as np
1515

16-
from om1_utils.logging import LoggingConfig, get_logging_config, setup_logging
16+
from om1_utils import LoggingConfig, get_logging_config, setup_logging
1717

1818
from ..anonymizationSys.scrfd_trt_pixelate import (
1919
CONF_THRES,

src/zenoh_idl/__init__.py

Whitespace-only changes.

src/zenoh_msgs/__init__.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from .idl import (
2+
AudioStatus,
3+
CameraStatus,
4+
ColorRGBA,
5+
Duration,
6+
Header,
7+
MotionStatus,
8+
String,
9+
Time,
10+
prepare_header,
11+
status_msgs,
12+
std_msgs,
13+
)
14+
from .session import create_zenoh_config, open_zenoh_session
15+
16+
__all__ = [
17+
"std_msgs",
18+
"status_msgs",
19+
"AudioStatus",
20+
"CameraStatus",
21+
"MotionStatus",
22+
"Header",
23+
"String",
24+
"prepare_header",
25+
"Time",
26+
"Duration",
27+
"ColorRGBA",
28+
"create_zenoh_config",
29+
"open_zenoh_session",
30+
]

src/zenoh_msgs/idl/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from .status_msgs import AudioStatus, CameraStatus, MotionStatus
2+
from .std_msgs import ColorRGBA, Duration, Header, String, Time, prepare_header
3+
4+
__all__ = [
5+
"AudioStatus",
6+
"CameraStatus",
7+
"MotionStatus",
8+
"Header",
9+
"String",
10+
"prepare_header",
11+
"Time",
12+
"Duration",
13+
"ColorRGBA",
14+
]

0 commit comments

Comments
 (0)