Skip to content

Commit

Permalink
Merge pull request #142 from OpenVoiceOS/release-1.0.3a1
Browse files Browse the repository at this point in the history
Release 1.0.3a1
  • Loading branch information
JarbasAl authored Nov 21, 2024
2 parents 942f63c + ae54a4f commit 870cbd3
Show file tree
Hide file tree
Showing 15 changed files with 18 additions and 262 deletions.
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Changelog

## [1.0.2a1](https://github.com/OpenVoiceOS/ovos-bus-client/tree/1.0.2a1) (2024-11-15)
## [1.0.3a1](https://github.com/OpenVoiceOS/ovos-bus-client/tree/1.0.3a1) (2024-11-21)

[Full Changelog](https://github.com/OpenVoiceOS/ovos-bus-client/compare/1.0.1...1.0.2a1)
[Full Changelog](https://github.com/OpenVoiceOS/ovos-bus-client/compare/1.0.2...1.0.3a1)

**Merged pull requests:**

- fix: image urls [\#138](https://github.com/OpenVoiceOS/ovos-bus-client/pull/138) ([JarbasAl](https://github.com/JarbasAl))
- fix: remove dead code [\#141](https://github.com/OpenVoiceOS/ovos-bus-client/pull/141) ([JarbasAl](https://github.com/JarbasAl))



Expand Down
31 changes: 1 addition & 30 deletions ovos_bus_client/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,8 @@
from ovos_bus_client.message import Message, CollectionMessage, GUIMessage
from ovos_bus_client.session import SessionManager, Session

try:
from mycroft_bus_client import MessageBusClient as _MessageBusClientBase
except ImportError:
# TODO - code in the wild does isinstance checks
# this conditional subclassing should be removed ASAP, it is only here for the migration period
# mycroft_bus_client is abandonware until further notice from MycroftAI

class _MessageBusClientBase:
pass


class MessageBusClient(_MessageBusClientBase):
class MessageBusClient:
"""The Mycroft Messagebus Client
The Messagebus client connects to the Mycroft messagebus service
Expand Down Expand Up @@ -435,22 +425,3 @@ def on_message(self, *args):

parsed_message = GUIMessage.deserialize(message)
self.emitter.emit(parsed_message.msg_type, parsed_message)


@deprecated("No direct replacement", "0.1.0")
def echo():
"""
Echo function repeating all input from a user.
"""

from ovos_bus_client.util import create_echo_function
# TODO: Deprecate in 0.1.0
message_bus_client = MessageBusClient()

def repeat_utterance(message):
message.msg_type = 'speak'
message_bus_client.emit(message)

message_bus_client.on('message', create_echo_function(None))
message_bus_client.on('recognizer_loop:utterance', repeat_utterance)
message_bus_client.run_forever()
12 changes: 1 addition & 11 deletions ovos_bus_client/client/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,8 @@
from uuid import uuid4
import time

try:
from mycroft_bus_client.client.collector import MessageCollector as _MessageCollectorBase
except ImportError:
# TODO - code in the wild does isinstance checks
# this conditional subclassing should be removed ASAP, it is only here for the migration period
# mycroft_bus_client is abandonware until further notice from MycroftAI

class _MessageCollectorBase:
pass


class MessageCollector(_MessageCollectorBase):
class MessageCollector:
"""Collect multiple response.
This class encapsulates the logic for collecting messages from
Expand Down
11 changes: 0 additions & 11 deletions ovos_bus_client/client/waiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#

from threading import Event
from typing import List, Union

try:
from mycroft_bus_client.client.waiter import MessageWaiter as _MessageWaiterBase
except ImportError:
# TODO - code in the wild does isinstance checks
# this conditional subclassing should be removed ASAP, it is only here for the migration period
# mycroft_bus_client is abandonware until further notice from MycroftAI

class _MessageWaiterBase:
pass


class MessageWaiter:
"""Wait for a single message.
Expand Down
73 changes: 7 additions & 66 deletions ovos_bus_client/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,44 +30,8 @@
from ovos_utils.security import encrypt, decrypt
from ovos_config.config import Configuration

try:
from lingua_franca.parse import normalize
except ImportError:
# optional LF import
def normalize(text, *args, **kwargs):
return text

try:
from mycroft_bus_client.message import Message as _MsgBase, \
CollectionMessage as _CollectionMsgBase

except ImportError:

# TODO - code in the wild does isinstance checks
# this conditional subclassing should be removed ASAP, it is only here for the migration period
# mycroft_bus_client is abandonware until further notice from MycroftAI

class _MsgBase:
pass


class _CollectionMsgBase(_MsgBase):
pass


class _MessageMeta(type):
""" To override isinstance checks we need to use a metaclass """

def __instancecheck__(self, instance):
try:
from mycroft_bus_client.message import Message as _MycroftMessage
return isinstance(instance, _MycroftMessage) or \
super().__instancecheck__(instance)
except:
return super().__instancecheck__(instance)


class Message(_MsgBase, metaclass=_MessageMeta):
class Message:
"""Holds and manipulates data sent over the websocket
Message objects will be used to send information back and forth
Expand Down Expand Up @@ -165,7 +129,7 @@ def _json_load(value):
return obj

@staticmethod
def deserialize(value: str) -> _MsgBase:
def deserialize(value: str) -> 'Message':
"""
This takes a string and constructs a message object.
Expand All @@ -186,7 +150,7 @@ def deserialize(value: str) -> _MsgBase:
obj.get('data') or {},
obj.get('context') or {})

def forward(self, msg_type: str, data: dict = None) -> _MsgBase:
def forward(self, msg_type: str, data: dict = None) -> 'Message':
"""
Keep context and forward message
Expand All @@ -204,8 +168,7 @@ def forward(self, msg_type: str, data: dict = None) -> _MsgBase:
data = data or {}
return Message(msg_type, data, context=self.context)

def reply(self, msg_type: str, data: dict = None,
context: dict = None) -> _MsgBase:
def reply(self, msg_type: str, data: dict = None, context: dict = None) -> 'Message':
"""
Construct a reply message for a given message
Expand Down Expand Up @@ -240,7 +203,7 @@ def reply(self, msg_type: str, data: dict = None,
new_context['source'] = s
return Message(msg_type, data, context=new_context)

def response(self, data: dict = None, context: dict = None) -> _MsgBase:
def response(self, data: dict = None, context: dict = None) -> 'Message':
"""
Construct a response message for the message
Expand All @@ -255,8 +218,7 @@ def response(self, data: dict = None, context: dict = None) -> _MsgBase:
"""
return self.reply(self.msg_type + '.response', data, context)

def publish(self, msg_type: str, data: dict,
context: dict = None) -> _MsgBase:
def publish(self, msg_type: str, data: dict, context: dict = None) -> 'Message':
"""
Copy the original context and add passed in context. Delete
any target in the new context. Return a new message object with
Expand All @@ -280,27 +242,6 @@ def publish(self, msg_type: str, data: dict,

return Message(msg_type, data, context=new_context)

@deprecated("This method is deprecated with no replacement", "0.1.0")
def utterance_remainder(self):
"""
DEPRECATED - mycroft-core hack, used by some skills in the wild
For intents get the portion not consumed by Adapt.
For example: if they say 'Turn on the family room light' and there are
entity matches for "turn on" and "light", then it will leave behind
" the family room " which is then normalized to "family room".
Returns:
str: Leftover words or None if not an utterance.
"""
utt = normalize(self.data.get("utterance", ""))
if utt and "__tags__" in self.data:
for token in self.data["__tags__"]:
# Substitute only whole words matching the token
utt = re.sub(r'\b' + token.get("key", "") + r"\b", "", utt)
return normalize(utt)


def encrypt_as_dict(key: str, data: str, nonce=None) -> dict:
ciphertext, tag, nonce = encrypt(key, data, nonce=nonce)
Expand Down Expand Up @@ -340,7 +281,7 @@ def dig_for_message(max_records: int = 10) -> Optional[Message]:
return None


class CollectionMessage(Message, _CollectionMsgBase):
class CollectionMessage(Message):
"""Extension of the Message class for use with collect handlers.
The class provides the convenience methods success and failure to report
Expand Down
2 changes: 1 addition & 1 deletion ovos_bus_client/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from ovos_bus_client.message import dig_for_message, Message
from ovos_bus_client.session import SessionManager
from ovos_bus_client.util.scheduler import EventScheduler
from ovos_bus_client.util.utils import create_echo_function


_DEFAULT_WS_CONFIG = {"host": "0.0.0.0",
"port": 8181,
Expand Down
16 changes: 2 additions & 14 deletions ovos_bus_client/util/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@

from ovos_config.config import Configuration
from ovos_config.locations import get_xdg_data_save_path, get_xdg_config_save_path
from ovos_utils.log import LOG, log_deprecation
from ovos_utils.events import EventContainer as _EventContainer
from ovos_utils.events import EventSchedulerInterface as _SchedulerInterface
from ovos_utils.log import LOG
from ovos_utils.events import EventContainer, EventSchedulerInterface
from ovos_bus_client.message import Message


Expand Down Expand Up @@ -349,14 +348,3 @@ def shutdown(self):
self.store()
raise e


class EventContainer(_EventContainer):
def __init__(self, *args, **kwargs):
log_deprecation("Import from `ovos_utils.events`", "0.1.0")
_EventContainer.__init__(self, *args, **kwargs)


class EventSchedulerInterface(_SchedulerInterface):
def __init__(self, *args, **kwargs):
log_deprecation("Import from `ovos_utils.events`", "0.1.0")
_SchedulerInterface.__init__(self, *args, **kwargs)
55 changes: 0 additions & 55 deletions ovos_bus_client/util/utils.py

This file was deleted.

4 changes: 2 additions & 2 deletions ovos_bus_client/version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# START_VERSION_BLOCK
VERSION_MAJOR = 1
VERSION_MINOR = 0
VERSION_BUILD = 2
VERSION_ALPHA = 0
VERSION_BUILD = 3
VERSION_ALPHA = 1
# END_VERSION_BLOCK
1 change: 0 additions & 1 deletion test/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
pytest
pytest-cov
mycroft-messagebus-client
14 changes: 0 additions & 14 deletions test/unittests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,7 @@
WS_CONF = {"websocket": {"host": "testhost", "port": 1337, "route": "/core", "ssl": False}}


class TestClient(unittest.TestCase):
def test_echo(self):
from ovos_bus_client.client.client import echo

# TODO

def test_inheritance(self):
from mycroft_bus_client.client import MessageBusClient as _Client

self.assertTrue(issubclass(MessageBusClient, _Client))


class TestMessageBusClient(unittest.TestCase):
from ovos_bus_client.client.client import MessageBusClient

client = MessageBusClient()

def test_build_url(self):
Expand Down
15 changes: 0 additions & 15 deletions test/unittests/test_compat.py

This file was deleted.

Loading

0 comments on commit 870cbd3

Please sign in to comment.