Skip to content

Commit c4d0d26

Browse files
authored
Merge pull request #280 from OpenVoiceOS/release-0.5.4a1
Release 0.5.4a1
2 parents 0cdde42 + 50d115d commit c4d0d26

File tree

4 files changed

+20
-53
lines changed

4 files changed

+20
-53
lines changed

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Changelog
22

3-
## [0.5.3a1](https://github.com/OpenVoiceOS/ovos-plugin-manager/tree/0.5.3a1) (2024-10-23)
3+
## [0.5.4a1](https://github.com/OpenVoiceOS/ovos-plugin-manager/tree/0.5.4a1) (2024-10-24)
44

5-
[Full Changelog](https://github.com/OpenVoiceOS/ovos-plugin-manager/compare/0.5.2...0.5.3a1)
5+
[Full Changelog](https://github.com/OpenVoiceOS/ovos-plugin-manager/compare/0.5.3...0.5.4a1)
66

77
**Merged pull requests:**
88

9-
- fix:deprecate G2P [\#277](https://github.com/OpenVoiceOS/ovos-plugin-manager/pull/277) ([JarbasAl](https://github.com/JarbasAl))
9+
- fix:missing import [\#279](https://github.com/OpenVoiceOS/ovos-plugin-manager/pull/279) ([JarbasAl](https://github.com/JarbasAl))
1010

1111

1212

ovos_plugin_manager/microphone.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
from ovos_plugin_manager.utils import PluginTypes
1+
from ovos_config import Configuration
2+
from ovos_utils.log import LOG, deprecated
3+
24
from ovos_plugin_manager.templates.microphone import Microphone
3-
from ovos_utils.log import LOG
5+
from ovos_plugin_manager.utils import PluginTypes
46

57

68
def find_microphone_plugins() -> dict:
@@ -22,6 +24,7 @@ def load_microphone_plugin(module_name: str) -> type(Microphone):
2224
return load_plugin(module_name, PluginTypes.MIC)
2325

2426

27+
@deprecated("get_microphone_config is deprecated, use Configuration() directly", "1.0.0")
2528
def get_microphone_config(config=None):
2629
"""
2730
Get relevant configuration for factory methods
@@ -45,7 +48,7 @@ def get_class(config=None):
4548
"module": <engine_name>
4649
}
4750
"""
48-
config = get_microphone_config(config)
51+
config = config or Configuration().get("listener", {}).get("microphone", {})
4952
microphone_module = config.get("module")
5053
return load_microphone_plugin(microphone_module)
5154

@@ -60,19 +63,12 @@ def create(cls, config=None):
6063
"module": <engine_name>
6164
}
6265
"""
63-
config = config or Configuration()
64-
if "microphone" in config:
65-
config = config["microphone"]
66-
microphone_config = get_microphone_config(config)
67-
microphone_module = microphone_config.get('module')
66+
config = config or Configuration().get("listener", {}).get("microphone", {})
67+
microphone_module = config.get('module')
68+
microphone_config = config.get(microphone_module, {})
6869
fallback = microphone_config.get("fallback_module")
6970
try:
70-
clazz = OVOSMicrophoneFactory.get_class(microphone_config)
71-
# Note that configuration is expanded for this class of plugins
72-
# since they are dataclasses and don't have the same init signature
73-
# as other plugin types
74-
microphone_config.pop('lang')
75-
microphone_config.pop('module')
71+
clazz = OVOSMicrophoneFactory.get_class(config)
7672
if fallback:
7773
microphone_config.pop('fallback_module')
7874
microphone = clazz(**microphone_config)

ovos_plugin_manager/version.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# START_VERSION_BLOCK
22
VERSION_MAJOR = 0
33
VERSION_MINOR = 5
4-
VERSION_BUILD = 3
5-
VERSION_ALPHA = 0
4+
VERSION_BUILD = 4
5+
VERSION_ALPHA = 1
66
# END_VERSION_BLOCK

test/unittests/test_microphone.py

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,6 @@ def test_load_plugin(self, load_plugin):
131131
load_microphone_plugin("test_mod")
132132
load_plugin.assert_called_once_with("test_mod", self.PLUGIN_TYPE)
133133

134-
@patch("ovos_plugin_manager.utils.config.get_plugin_config")
135-
def test_get_config(self, get_config):
136-
from ovos_plugin_manager.microphone import get_microphone_config
137-
get_microphone_config(self.TEST_CONFIG)
138-
get_config.assert_called_once_with(self.TEST_CONFIG,
139-
self.CONFIG_SECTION)
140-
141134

142135
class TestMicrophoneFactory(unittest.TestCase):
143136
def test_create_microphone(self):
@@ -154,11 +147,9 @@ def _copy_args(*args):
154147
mock_get_class = Mock(side_effect=_copy_args)
155148
OVOSMicrophoneFactory.get_class = mock_get_class
156149

157-
OVOSMicrophoneFactory.create(config=_TEST_CONFIG)
150+
OVOSMicrophoneFactory.create(config=_TEST_CONFIG['microphone'])
158151
mock_get_class.assert_called_once()
159-
self.assertEqual(call_args, ({**_TEST_CONFIG['microphone']['dummy'],
160-
**{"module": "dummy",
161-
"lang": "en-US"}},))
152+
self.assertEqual(call_args, ({**_TEST_CONFIG['microphone']},))
162153
mock_class.assert_called_once_with(**_TEST_CONFIG['microphone']['dummy'])
163154
OVOSMicrophoneFactory.get_class = real_get_class
164155

@@ -171,7 +162,7 @@ def test_create_microphone_fallback(self):
171162

172163
def _copy_args(*args):
173164
nonlocal call_args, bad_call_args
174-
if args[0]["module"] == "bad":
165+
if args[0].get("module", "") == "bad":
175166
bad_call_args = deepcopy(args)
176167
return None
177168
call_args = deepcopy(args)
@@ -180,7 +171,7 @@ def _copy_args(*args):
180171
mock_get_class = Mock(side_effect=_copy_args)
181172
OVOSMicrophoneFactory.get_class = mock_get_class
182173

183-
OVOSMicrophoneFactory.create(config=_FALLBACK_CONFIG)
174+
OVOSMicrophoneFactory.create(config=_FALLBACK_CONFIG['microphone'])
184175
mock_get_class.assert_called()
185176
self.assertEqual(call_args[0]["module"], 'dummy')
186177
self.assertEqual(bad_call_args[0]["module"], 'bad')
@@ -193,27 +184,7 @@ def test_get_class(self, load_plugin):
193184
load_plugin.return_value = mock
194185
from ovos_plugin_manager.microphone import OVOSMicrophoneFactory
195186
# Test valid module
196-
module = OVOSMicrophoneFactory.get_class(_TEST_CONFIG)
187+
module = OVOSMicrophoneFactory.get_class(_TEST_CONFIG['microphone'])
197188
load_plugin.assert_called_once_with("dummy",
198189
PluginTypes.MIC)
199190
self.assertEqual(mock, module)
200-
201-
def test_get_microphone_config(self):
202-
from ovos_plugin_manager.microphone import get_microphone_config
203-
config = copy(_TEST_CONFIG)
204-
dummy_config = get_microphone_config(config)
205-
self.assertEqual(dummy_config, {**_TEST_CONFIG['microphone']['dummy'],
206-
**{'module': 'dummy',
207-
'lang': 'en-US'}})
208-
config = copy(_TEST_CONFIG)
209-
config['microphone']['module'] = 'ovos-microphone-plugin-alsa'
210-
alsa_config = get_microphone_config(config)
211-
self.assertEqual(alsa_config,
212-
{**_TEST_CONFIG['microphone']
213-
['ovos-microphone-plugin-alsa'],
214-
**{'module': 'ovos-microphone-plugin-alsa',
215-
'lang': 'en-US'}})
216-
config = copy(_TEST_CONFIG)
217-
config['microphone']['module'] = 'fake'
218-
fake_config = get_microphone_config(config)
219-
self.assertEqual(fake_config, {'module': 'fake', 'lang': 'en-US'})

0 commit comments

Comments
 (0)