Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Outline Unit Tests #158

Merged
merged 10 commits into from
May 26, 2023
19 changes: 18 additions & 1 deletion ovos_plugin_manager/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,19 @@
from ovos_plugin_manager.utils import load_plugin, find_plugins, PluginTypes
from ovos_plugin_manager.utils import PluginTypes
from ovos_plugin_manager.plugin_entry import OpenVoiceOSPlugin
from ovos_utils.log import LOG


def find_plugins(*args, **kwargs):
# TODO: Deprecate in 0.1.0
LOG.warning("This reference is deprecated. "
"Import from ovos_plugin_manager.utils directly")
from ovos_plugin_manager.utils import find_plugins
return find_plugins(*args, **kwargs)


def load_plugin(*args, **kwargs):
# TODO: Deprecate in 0.1.0
LOG.warning("This reference is deprecated. "
"Import from ovos_plugin_manager.utils directly")
from ovos_plugin_manager.utils import load_plugin
return load_plugin(*args, **kwargs)
11 changes: 10 additions & 1 deletion ovos_plugin_manager/audio.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
from ovos_plugin_manager.utils import PluginConfigTypes, find_plugins, PluginTypes
from ovos_plugin_manager.utils import PluginConfigTypes, PluginTypes
from ovos_utils.log import LOG
from ovos_utils.messagebus import get_mycroft_bus
from ovos_config import Configuration


def find_plugins(*args, **kwargs):
# TODO: Deprecate in 0.1.0
LOG.warning("This reference is deprecated. "
"Import from ovos_plugin_manager.utils directly")
from ovos_plugin_manager.utils import find_plugins
return find_plugins(*args, **kwargs)


def find_audio_service_plugins() -> dict:
"""
Find all installed plugins
@return: dict plugin names to entrypoints
"""
from ovos_plugin_manager.utils import find_plugins
return find_plugins(PluginTypes.AUDIO)


Expand Down
20 changes: 19 additions & 1 deletion ovos_plugin_manager/audio2ipa.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
from typing import Optional
from ovos_plugin_manager.utils import normalize_lang, load_plugin, find_plugins, PluginTypes, PluginConfigTypes
from ovos_plugin_manager.utils import normalize_lang, PluginTypes, PluginConfigTypes
from ovos_plugin_manager.templates.audio2ipa import Audio2IPA
from ovos_utils.log import LOG


def find_plugins(*args, **kwargs):
# TODO: Deprecate in 0.1.0
LOG.warning("This reference is deprecated. "
"Import from ovos_plugin_manager.utils directly")
from ovos_plugin_manager.utils import find_plugins
return find_plugins(*args, **kwargs)


def load_plugin(*args, **kwargs):
# TODO: Deprecate in 0.1.0
LOG.warning("This reference is deprecated. "
"Import from ovos_plugin_manager.utils directly")
from ovos_plugin_manager.utils import load_plugin
return load_plugin(*args, **kwargs)


def find_audio2ipa_plugins() -> dict:
"""
Find all installed plugins
@return: dict plugin names to entrypoints
"""
from ovos_plugin_manager.utils import find_plugins
return find_plugins(PluginTypes.AUDIO2IPA)


Expand All @@ -18,6 +35,7 @@ def load_audio2ipa_plugin(module_name: str) -> type(Audio2IPA):
@param module_name: Plugin entrypoint name to load
@return: Uninstantiated class
"""
from ovos_plugin_manager.utils import load_plugin
return load_plugin(module_name, PluginTypes.AUDIO2IPA)


Expand Down
22 changes: 20 additions & 2 deletions ovos_plugin_manager/audio_transformers.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
from ovos_plugin_manager.utils import load_plugin, find_plugins, PluginTypes, \
PluginConfigTypes
from ovos_plugin_manager.utils import PluginTypes, PluginConfigTypes
from ovos_plugin_manager.templates.transformers import AudioTransformer
from ovos_utils.log import LOG


def find_plugins(*args, **kwargs):
# TODO: Deprecate in 0.1.0
LOG.warning("This reference is deprecated. "
"Import from ovos_plugin_manager.utils directly")
from ovos_plugin_manager.utils import find_plugins
return find_plugins(*args, **kwargs)


def load_plugin(*args, **kwargs):
# TODO: Deprecate in 0.1.0
LOG.warning("This reference is deprecated. "
"Import from ovos_plugin_manager.utils directly")
from ovos_plugin_manager.utils import load_plugin
return load_plugin(*args, **kwargs)


def find_audio_transformer_plugins() -> dict:
"""
Find all installed plugins
@return: dict plugin names to entrypoints
"""
from ovos_plugin_manager.utils import find_plugins
return find_plugins(PluginTypes.AUDIO_TRANSFORMER)


Expand All @@ -19,6 +36,7 @@ def load_audio_transformer_plugin(module_name: str) -> type(AudioTransformer):
Returns:
class: found audio_transformer plugin class
"""
from ovos_plugin_manager.utils import load_plugin
return load_plugin(module_name, PluginTypes.AUDIO_TRANSFORMER)


Expand Down
22 changes: 20 additions & 2 deletions ovos_plugin_manager/coreference.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,35 @@
from typing import Optional

from ovos_plugin_manager.utils import normalize_lang, load_plugin, \
find_plugins, PluginTypes, PluginConfigTypes
from ovos_plugin_manager.utils import normalize_lang, PluginTypes, \
PluginConfigTypes
from ovos_config import Configuration
from ovos_utils.log import LOG
from ovos_plugin_manager.templates.coreference import CoreferenceSolverEngine, \
replace_coreferences


def find_plugins(*args, **kwargs):
# TODO: Deprecate in 0.1.0
LOG.warning("This reference is deprecated. "
"Import from ovos_plugin_manager.utils directly")
from ovos_plugin_manager.utils import find_plugins
return find_plugins(*args, **kwargs)


def load_plugin(*args, **kwargs):
# TODO: Deprecate in 0.1.0
LOG.warning("This reference is deprecated. "
"Import from ovos_plugin_manager.utils directly")
from ovos_plugin_manager.utils import load_plugin
return load_plugin(*args, **kwargs)


def find_coref_plugins() -> dict:
"""
Find all installed plugins
@return: dict plugin names to entrypoints
"""
from ovos_plugin_manager.utils import find_plugins
return find_plugins(PluginTypes.COREFERENCE_SOLVER)


Expand All @@ -22,6 +39,7 @@ def load_coref_plugin(module_name: str) -> type(CoreferenceSolverEngine):
@param module_name: Plugin entrypoint name to load
@return: Uninstantiated class
"""
from ovos_plugin_manager.utils import load_plugin
return load_plugin(module_name, PluginTypes.COREFERENCE_SOLVER)


Expand Down
21 changes: 19 additions & 2 deletions ovos_plugin_manager/g2p.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
from typing import Optional

from ovos_plugin_manager.utils import normalize_lang, load_plugin, find_plugins, PluginTypes, PluginConfigTypes
from ovos_plugin_manager.utils import normalize_lang, PluginTypes, PluginConfigTypes
from ovos_plugin_manager.templates.g2p import Grapheme2PhonemePlugin, PhonemeAlphabet
from ovos_utils.log import LOG
from ovos_config import Configuration


def find_plugins(*args, **kwargs):
# TODO: Deprecate in 0.1.0
LOG.warning("This reference is deprecated. "
"Import from ovos_plugin_manager.utils directly")
from ovos_plugin_manager.utils import find_plugins
return find_plugins(*args, **kwargs)


def load_plugin(*args, **kwargs):
# TODO: Deprecate in 0.1.0
LOG.warning("This reference is deprecated. "
"Import from ovos_plugin_manager.utils directly")
from ovos_plugin_manager.utils import load_plugin
return load_plugin(*args, **kwargs)


def find_g2p_plugins() -> dict:
"""
Find all installed plugins
@return: dict plugin names to entrypoints
"""
from ovos_plugin_manager.utils import find_plugins
return find_plugins(PluginTypes.PHONEME)


Expand All @@ -20,6 +37,7 @@ def load_g2p_plugin(module_name: str) -> Grapheme2PhonemePlugin:
@param module_name: Plugin entrypoint name to load
@return: Uninstantiated class
"""
from ovos_plugin_manager.utils import load_plugin
return load_plugin(module_name, PluginTypes.PHONEME)


Expand Down Expand Up @@ -75,7 +93,6 @@ def get_g2p_config(config: Optional[dict] = None) -> dict:
return get_plugin_config(config, "g2p")



class OVOSG2PFactory:
""" replicates the base mycroft class, but uses only OPM enabled plugins"""
MAPPINGS = {
Expand Down
26 changes: 23 additions & 3 deletions ovos_plugin_manager/gui.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
from typing import List, Optional

from ovos_plugin_manager.utils import load_plugin, find_plugins, PluginTypes, \
PluginConfigTypes
from ovos_plugin_manager.utils import PluginTypes, PluginConfigTypes
from ovos_plugin_manager.templates.gui import GUIExtension
from ovos_utils.log import LOG


def find_gui_plugins() -> dict:
def find_plugins(*args, **kwargs):
# TODO: Deprecate in 0.1.0
LOG.warning("This reference is deprecated. "
"Import from ovos_plugin_manager.utils directly")
from ovos_plugin_manager.utils import find_plugins
return find_plugins(*args, **kwargs)


def load_plugin(*args, **kwargs):
# TODO: Deprecate in 0.1.0
LOG.warning("This reference is deprecated. "
"Import from ovos_plugin_manager.utils directly")
from ovos_plugin_manager.utils import load_plugin
return load_plugin(*args, **kwargs)


def find_gui_plugins() -> dict:
"""
Find all installed plugins
@return: dict plugin names to entrypoints
"""
from ovos_plugin_manager.utils import find_plugins
return find_plugins(PluginTypes.GUI)


Expand All @@ -17,6 +36,7 @@ def load_gui_plugin(module_name: str) -> type(GUIExtension):
@param module_name: Plugin entrypoint name to load
@return: Uninstantiated class
"""
from ovos_plugin_manager.utils import load_plugin
return load_plugin(module_name, PluginTypes.GUI)


Expand Down
21 changes: 19 additions & 2 deletions ovos_plugin_manager/keywords.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
from ovos_plugin_manager.utils import normalize_lang, load_plugin, \
find_plugins, PluginTypes, PluginConfigTypes
from ovos_plugin_manager.utils import normalize_lang, PluginTypes, PluginConfigTypes
from ovos_config import Configuration
from ovos_utils.log import LOG
from ovos_plugin_manager.templates.keywords import KeywordExtractor


def find_plugins(*args, **kwargs):
# TODO: Deprecate in 0.1.0
LOG.warning("This reference is deprecated. "
"Import from ovos_plugin_manager.utils directly")
from ovos_plugin_manager.utils import find_plugins
return find_plugins(*args, **kwargs)


def load_plugin(*args, **kwargs):
# TODO: Deprecate in 0.1.0
LOG.warning("This reference is deprecated. "
"Import from ovos_plugin_manager.utils directly")
from ovos_plugin_manager.utils import load_plugin
return load_plugin(*args, **kwargs)


def find_keyword_extract_plugins() -> dict:
"""
Find all installed plugins
@return: dict plugin names to entrypoints
"""
from ovos_plugin_manager.utils import find_plugins
return find_plugins(PluginTypes.KEYWORD_EXTRACTION)


Expand All @@ -19,6 +35,7 @@ def load_keyword_extract_plugin(module_name: str) -> type(KeywordExtractor):
@param module_name: Plugin entrypoint name to load
@return: Uninstantiated class
"""
from ovos_plugin_manager.utils import load_plugin
return load_plugin(module_name, PluginTypes.KEYWORD_EXTRACTION)


Expand Down
23 changes: 21 additions & 2 deletions ovos_plugin_manager/language.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,31 @@
from ovos_config import Configuration
from ovos_plugin_manager.templates.language import LanguageTranslator, \
LanguageDetector
from ovos_plugin_manager.utils import load_plugin, find_plugins, PluginTypes, \
PluginConfigTypes
from ovos_plugin_manager.utils import PluginTypes, PluginConfigTypes


def find_plugins(*args, **kwargs):
# TODO: Deprecate in 0.1.0
LOG.warning("This reference is deprecated. "
"Import from ovos_plugin_manager.utils directly")
from ovos_plugin_manager.utils import find_plugins
return find_plugins(*args, **kwargs)


def load_plugin(*args, **kwargs):
# TODO: Deprecate in 0.1.0
LOG.warning("This reference is deprecated. "
"Import from ovos_plugin_manager.utils directly")
from ovos_plugin_manager.utils import load_plugin
return load_plugin(*args, **kwargs)


def find_tx_plugins() -> dict:
"""
Find all installed plugins
@return: dict plugin names to entrypoints
"""
from ovos_plugin_manager.utils import find_plugins
return find_plugins(PluginTypes.TRANSLATE)


Expand All @@ -22,6 +38,7 @@ def load_tx_plugin(module_name: str) -> type(LanguageTranslator):
@param module_name: Plugin entrypoint name to load
@return: Uninstantiated class
"""
from ovos_plugin_manager.utils import load_plugin
return load_plugin(module_name, PluginTypes.TRANSLATE)


Expand Down Expand Up @@ -49,6 +66,7 @@ def find_lang_detect_plugins():
Find all installed plugins
@return: dict plugin names to entrypoints
"""
from ovos_plugin_manager.utils import find_plugins
return find_plugins(PluginTypes.LANG_DETECT)


Expand All @@ -58,6 +76,7 @@ def load_lang_detect_plugin(module_name: str) -> type(LanguageDetector):
@param module_name: Plugin entrypoint name to load
@return: Uninstantiated class
"""
from ovos_plugin_manager.utils import load_plugin
return load_plugin(module_name, PluginTypes.LANG_DETECT)


Expand Down
Loading