-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Includes intent tests with CLI entrypoint
- Loading branch information
1 parent
1f81d66
commit 4f9d482
Showing
16 changed files
with
642 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
name: Run License Tests | ||
on: | ||
push: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
license_tests: | ||
uses: neongeckocom/.github/.github/workflows/license_tests.yml@master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# This workflow will generate a release distribution and upload it to PyPI | ||
|
||
name: Publish Build and GitHub Release | ||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build_and_publish_pypi_and_release: | ||
uses: neongeckocom/.github/.github/workflows/publish_stable_release.yml@master | ||
secrets: inherit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# This workflow will generate a distribution and upload it to PyPI | ||
|
||
name: Publish Alpha Build | ||
on: | ||
push: | ||
branches: | ||
- dev | ||
paths-ignore: | ||
- 'neon_minerva/version.py' | ||
|
||
jobs: | ||
build_and_publish_pypi: | ||
uses: neongeckocom/.github/.github/workflows/publish_alpha_release.yml@master | ||
secrets: inherit | ||
with: | ||
version_file: "neon_minerva/version.py" | ||
setup_py: "setup.py" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# This workflow will generate a PR for changes in cert into master | ||
|
||
name: Pull to Master | ||
on: | ||
push: | ||
branches: | ||
- dev | ||
|
||
jobs: | ||
pull_changes: | ||
uses: neongeckocom/.github/.github/workflows/pull_master.yml@master | ||
with: | ||
pr_reviewer: neonreviewers | ||
pr_assignee: neondaniel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# This workflow will run unit tests | ||
|
||
name: Run Unit Tests | ||
on: | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
py_build_tests: | ||
uses: neongeckocom/.github/.github/workflows/python_build_tests.yml@master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Development System | ||
# All trademark and other rights reserved by their respective owners | ||
# Copyright 2008-2021 Neongecko.com Inc. | ||
# BSD-3 License | ||
|
||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the | ||
following conditions are met: | ||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following | ||
disclaimer. | ||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following | ||
disclaimer in the documentation and/or other materials provided with the distribution. | ||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products | ||
derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Neon Minerva | ||
Neon Minerva (Modular INtelligent Evaluation for a Reliable Voice Assistant) | ||
provides tools for testing skills. | ||
|
||
Install the Iris Python package with: `pip install neon-minerva` | ||
The `minerva` entrypoint is available to interact with a bus via CLI. | ||
Help is available via `minerva --help`. | ||
|
||
## Installation | ||
Since skill intents may use Padatious, the following system packages must be | ||
installed before installing this package: | ||
```shell | ||
sudo apt install swig libfann-dev | ||
``` | ||
To install this package from PyPI, simply run: | ||
```shell | ||
pip install neon-minerva | ||
``` | ||
|
||
## Usage | ||
This package provides a CLI for local testing of skills. Note that skills should | ||
be installed before testing and testing a skill that hasn't been installed with | ||
`pip` is not currently supported. | ||
|
||
### Resource Tests | ||
To test that skill resources are defined for all supported languages, | ||
`minerva test-resources <skill-entrypoint> <test-file>` | ||
> - <skill-entrypoint\> is the string entrypoint for the skill to test as specified in `setup.py` | ||
> - <test-file\> is a relative or absolute path to the resource test file, usually `test_resources.yaml` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Development System | ||
# All trademark and other rights reserved by their respective owners | ||
# Copyright 2008-2021 Neongecko.com Inc. | ||
# BSD-3 | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# 1. Redistributions of source code must retain the above copyright notice, | ||
# this list of conditions and the following disclaimer. | ||
# 2. Redistributions in binary form must reproduce the above copyright notice, | ||
# this list of conditions and the following disclaimer in the documentation | ||
# and/or other materials provided with the distribution. | ||
# 3. Neither the name of the copyright holder nor the names of its | ||
# contributors may be used to endorse or promote products derived from this | ||
# software without specific prior written permission. | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR | ||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, | ||
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Development System | ||
# All trademark and other rights reserved by their respective owners | ||
# Copyright 2008-2021 Neongecko.com Inc. | ||
# BSD-3 | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# 1. Redistributions of source code must retain the above copyright notice, | ||
# this list of conditions and the following disclaimer. | ||
# 2. Redistributions in binary form must reproduce the above copyright notice, | ||
# this list of conditions and the following disclaimer in the documentation | ||
# and/or other materials provided with the distribution. | ||
# 3. Neither the name of the copyright holder nor the names of its | ||
# contributors may be used to endorse or promote products derived from this | ||
# software without specific prior written permission. | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR | ||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, | ||
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
import os | ||
import click | ||
|
||
from os.path import expanduser, relpath, isfile | ||
from click_default_group import DefaultGroup | ||
from unittest.runner import TextTestRunner | ||
from unittest import makeSuite | ||
|
||
from neon_minerva.version import __version__ | ||
|
||
|
||
def _init_test_dir(): | ||
from os.path import join | ||
from os import makedirs | ||
from tempfile import mkdtemp | ||
base_dir = mkdtemp() | ||
config = join(base_dir, "config") | ||
data = join(base_dir, "data") | ||
makedirs(config, exist_ok=True) | ||
makedirs(data, exist_ok=True) | ||
os.environ["XDG_CONFIG_HOME"] = config | ||
os.environ["XDG_DATA_HOME"] = data | ||
|
||
|
||
@click.group("minerva", cls=DefaultGroup, | ||
no_args_is_help=True, invoke_without_command=True, | ||
help="Minerva: Modular INtelligent Evaluation for a Reliable " | ||
"Voice Assistant.\n\n" | ||
"See also: minerva COMMAND --help") | ||
@click.option("--version", "-v", is_flag=True, required=False, | ||
help="Print the current version") | ||
def neon_minerva_cli(version: bool = False): | ||
if version: | ||
click.echo(f"Minerva version {__version__}") | ||
|
||
|
||
@neon_minerva_cli.command | ||
@click.argument("skill_entrypoint") | ||
@click.argument("test_file") | ||
def test_resources(skill_entrypoint, test_file): | ||
_init_test_dir() | ||
os.environ["TEST_SKILL_ENTRYPOINT"] = skill_entrypoint | ||
test_file = expanduser(test_file) | ||
if not isfile(test_file): | ||
test_file = relpath(test_file) | ||
if not isfile(test_file): | ||
click.echo(f"Could not find test file: {test_file}") | ||
exit(2) | ||
os.environ["RESOURCE_TEST_FILE"] = test_file | ||
from neon_minerva.tests.test_skill_resources import TestSkillLoading | ||
TextTestRunner().run(makeSuite(TestSkillLoading)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Framework | ||
# All trademark and other rights reserved by their respective owners | ||
# Copyright 2008-2022 Neongecko.com Inc. | ||
# Contributors: Daniel McKnight, Guy Daniels, Elon Gasper, Richard Leeds, | ||
# Regina Bloomstine, Casimiro Ferreira, Andrii Pernatii, Kirill Hrymailo | ||
# BSD-3 License | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# 1. Redistributions of source code must retain the above copyright notice, | ||
# this list of conditions and the following disclaimer. | ||
# 2. Redistributions in binary form must reproduce the above copyright notice, | ||
# this list of conditions and the following disclaimer in the documentation | ||
# and/or other materials provided with the distribution. | ||
# 3. Neither the name of the copyright holder nor the names of its | ||
# contributors may be used to endorse or promote products derived from this | ||
# software without specific prior written permission. | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR | ||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, | ||
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
class IntentException(Exception): | ||
""" | ||
Base exception for an intent error | ||
""" | ||
|
||
class IntentNotMatched(IntentException): | ||
""" | ||
Exception indicating an intent match was expected but not found | ||
""" | ||
|
||
|
||
class ConfidenceTooLow(IntentException): | ||
""" | ||
Exception indicating an intent match confidence was below specified minimum. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Development System | ||
# All trademark and other rights reserved by their respective owners | ||
# Copyright 2008-2021 Neongecko.com Inc. | ||
# BSD-3 | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# 1. Redistributions of source code must retain the above copyright notice, | ||
# this list of conditions and the following disclaimer. | ||
# 2. Redistributions in binary form must reproduce the above copyright notice, | ||
# this list of conditions and the following disclaimer in the documentation | ||
# and/or other materials provided with the distribution. | ||
# 3. Neither the name of the copyright holder nor the names of its | ||
# contributors may be used to endorse or promote products derived from this | ||
# software without specific prior written permission. | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR | ||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, | ||
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
from typing import Optional | ||
|
||
import yaml | ||
|
||
from os.path import expanduser, isfile | ||
|
||
from ovos_utils.messagebus import FakeBus | ||
from ovos_workshop.skills.base import BaseSkill | ||
|
||
|
||
def get_skill_object(skill_entrypoint: str, bus: FakeBus, | ||
skill_id: str, config_patch: Optional[dict] = None) -> BaseSkill: | ||
""" | ||
Get an initialized skill object by entrypoint with the requested skill_id. | ||
@param skill_entrypoint: Skill plugin entrypoint | ||
@param bus: FakeBus instance to bind to skill for testing | ||
@param skill_id: skill_id to initialize skill with | ||
@returns: Initialized skill object | ||
""" | ||
if config_patch: | ||
from ovos_config.config import update_mycroft_config | ||
update_mycroft_config(config_patch) | ||
from ovos_plugin_manager.skills import find_skill_plugins | ||
plugins = find_skill_plugins() | ||
if skill_entrypoint not in plugins: | ||
raise ValueError(f"Requested skill not found: {skill_entrypoint}") | ||
plugin = plugins[skill_entrypoint] | ||
skill = plugin(bus=bus, skill_id=skill_id) | ||
return skill | ||
|
||
|
||
def load_resource_tests(test_file: str) -> dict: | ||
""" | ||
Load resource tests from a file | ||
@param test_file: Test file to load | ||
@returns: Loaded test spec | ||
""" | ||
test_file = expanduser(test_file) | ||
if not isfile(test_file): | ||
raise FileNotFoundError(test_file) | ||
with open(test_file) as f: | ||
resources = yaml.safe_load(f) | ||
return resources | ||
|
||
|
||
if __name__ == "__main__": | ||
get_skill_object("skill-about.neongeckocom", FakeBus(), "test") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Development System | ||
# All trademark and other rights reserved by their respective owners | ||
# Copyright 2008-2021 Neongecko.com Inc. | ||
# BSD-3 | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# 1. Redistributions of source code must retain the above copyright notice, | ||
# this list of conditions and the following disclaimer. | ||
# 2. Redistributions in binary form must reproduce the above copyright notice, | ||
# this list of conditions and the following disclaimer in the documentation | ||
# and/or other materials provided with the distribution. | ||
# 3. Neither the name of the copyright holder nor the names of its | ||
# contributors may be used to endorse or promote products derived from this | ||
# software without specific prior written permission. | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR | ||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, | ||
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Oops, something went wrong.