Skip to content

Commit

Permalink
0.1.0 (#14)
Browse files Browse the repository at this point in the history
# Changelog

## [0.0.2a6](https://github.com/NeonGeckoCom/neon-minerva/tree/0.0.2a6)
(2023-12-08)

[Full
Changelog](0.0.2a5...0.0.2a6)

**Merged pull requests:**

- Move packages with system dependencies to `padatious` extras
[\#13](#13)
([NeonDaniel](https://github.com/NeonDaniel))

## [0.0.2a5](https://github.com/NeonGeckoCom/neon-minerva/tree/0.0.2a5)
(2023-12-08)

[Full
Changelog](0.0.1...0.0.2a5)

**Merged pull requests:**

- Update GHA to publish pre-releases
[\#12](#12)
([NeonDaniel](https://github.com/NeonDaniel))
- Fix bug causing dialog tests to pass when translations are missing
[\#11](#11)
([NeonDaniel](https://github.com/NeonDaniel))
- Add support for CBF Submind tests
[\#10](#10)
([NeonDaniel](https://github.com/NeonDaniel))
- Add compat. reference for `bus.emitter`
[\#9](#9)
([NeonDaniel](https://github.com/NeonDaniel))
- Skill Test Class
[\#5](#5)
([NeonDaniel](https://github.com/NeonDaniel))



\* *This Changelog was automatically generated by
[github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
  • Loading branch information
NeonDaniel authored Dec 11, 2023
2 parents 075ebbc + 9a68cf4 commit e60c804
Show file tree
Hide file tree
Showing 17 changed files with 361 additions and 23 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/publish_test_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ on:
- 'neon_minerva/version.py'

jobs:
build_and_publish_pypi:
publish_alpha_release:
uses: neongeckocom/.github/.github/workflows/publish_alpha_release.yml@master
secrets: inherit
with:
version_file: "neon_minerva/version.py"
setup_py: "setup.py"
publish_prerelease: true
22 changes: 15 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
# Changelog

## [0.0.1](https://github.com/NeonGeckoCom/neon-minerva/tree/0.0.1) (2023-10-26)
## [0.0.2a6](https://github.com/NeonGeckoCom/neon-minerva/tree/0.0.2a6) (2023-12-08)

[Full Changelog](https://github.com/NeonGeckoCom/neon-minerva/compare/1f81d6670a144b65069a882623ff3ef44ae93582...0.0.1)
[Full Changelog](https://github.com/NeonGeckoCom/neon-minerva/compare/0.0.2a5...0.0.2a6)

**Merged pull requests:**

- Update GitHub release automation [\#7](https://github.com/NeonGeckoCom/neon-minerva/pull/7) ([NeonDaniel](https://github.com/NeonDaniel))
- Update GitHub release automation [\#6](https://github.com/NeonGeckoCom/neon-minerva/pull/6) ([NeonDaniel](https://github.com/NeonDaniel))
- Loosen padacioso dependency spec for neon-core compat. [\#4](https://github.com/NeonGeckoCom/neon-minerva/pull/4) ([NeonDaniel](https://github.com/NeonDaniel))
- Add integration tests [\#3](https://github.com/NeonGeckoCom/neon-minerva/pull/3) ([NeonDaniel](https://github.com/NeonDaniel))
- Initial implementation of portable skill tests [\#1](https://github.com/NeonGeckoCom/neon-minerva/pull/1) ([NeonDaniel](https://github.com/NeonDaniel))
- Move packages with system dependencies to `padatious` extras [\#13](https://github.com/NeonGeckoCom/neon-minerva/pull/13) ([NeonDaniel](https://github.com/NeonDaniel))

## [0.0.2a5](https://github.com/NeonGeckoCom/neon-minerva/tree/0.0.2a5) (2023-12-08)

[Full Changelog](https://github.com/NeonGeckoCom/neon-minerva/compare/0.0.1...0.0.2a5)

**Merged pull requests:**

- Update GHA to publish pre-releases [\#12](https://github.com/NeonGeckoCom/neon-minerva/pull/12) ([NeonDaniel](https://github.com/NeonDaniel))
- Fix bug causing dialog tests to pass when translations are missing [\#11](https://github.com/NeonGeckoCom/neon-minerva/pull/11) ([NeonDaniel](https://github.com/NeonDaniel))
- Add support for CBF Submind tests [\#10](https://github.com/NeonGeckoCom/neon-minerva/pull/10) ([NeonDaniel](https://github.com/NeonDaniel))
- Add compat. reference for `bus.emitter` [\#9](https://github.com/NeonGeckoCom/neon-minerva/pull/9) ([NeonDaniel](https://github.com/NeonDaniel))
- Skill Test Class [\#5](https://github.com/NeonGeckoCom/neon-minerva/pull/5) ([NeonDaniel](https://github.com/NeonDaniel))



Expand Down
58 changes: 57 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ 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
If testing Padatious intents, the following system packages must be
installed before installing this package:
```shell
sudo apt install swig libfann-dev
Expand All @@ -17,6 +17,11 @@ To install this package from PyPI, simply run:
pip install neon-minerva
```

If testing with Padatious, install with the `padatious` extras:
```shell
pip install neon-minerva[padatious]
```

## Usage
This package provides a CLI for local testing of skills. Skills installed with
`pip` can be specified by entrypoint, or skills cloned locally can be specified
Expand All @@ -36,3 +41,54 @@ To test that skill intents match as expected for all supported languages,
the skill's root directory
> - <test-file\> is a relative or absolute path to the resource test file, usually `test_intents.yaml`
> - The `--padacioso` flag can be added to test with Padacioso instead of Padatious for relevant intents
## Advanced Usage
In addition to convenient CLI methods, this package also provides test cases that
may be extended.

### Skill Unit Tests
`neon_minerva.tests.skill_unit_test_base` provides `SkillTestCase`, a class
that supplies boilerplate setup/teardown/mocking for testing a skill. An example
skill test implementation could look like:

```python
from os import environ
from neon_minerva.tests.skill_unit_test_base import SkillTestCase

environ['TEST_SKILL_ENTRYPOINT'] = "my_skill.test"

class MySkillTest(SkillTestCase):
def test_skill_init(self):
self.assertEqual(self.skill.skill_id, "my_skill.test")
...
```

Be sure to review the base class for mocked methods and test paths as these may
change in the future.

### Chatbot Unit Tests
`neon_minerva.chatbots` contains mocked data for testing as well as some utility
methods. `neon_minerva.tests.chatbot_v1_test_base` provides `TestSubmind` which
may be extended to test a submind bot in a mocked v1 environment. For example:

```python
from os import environ
from datetime import datetime
from chatbot_core.utils.enum import ConversationState

from neon_minerva.tests.chatbot_v1_test_base import TestSubmind
from neon_minerva.chatbots.test_constants import PROMPT, RESPONSES

environ["TEST_BOT_ENTRYPOINT"] = "tester"


class TestTester(TestSubmind):
def test_submind_chatbot(self):
self.submind.state = ConversationState.RESP
response = self.submind.ask_chatbot("testrunner", PROMPT,
datetime.now().strftime(
"%I:%M:%S %p"))
self.assertIsInstance(response, str)
self.assertIsNotNone(response)
```
> Make sure to install the `chatbots` extra to use this test case
18 changes: 18 additions & 0 deletions neon_minerva/chatbots/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Development System
#
# Copyright 2008-2023 Neongecko.com Inc. | All Rights Reserved
#
# Notice of License - Duplicating this Notice of License near the start of any file containing
# a derivative of this software is a condition of license for this software.
# Friendly Licensing:
# No charge, open source royalty free use of the Neon AI software source and object is offered for
# educational users, noncommercial enthusiasts, Public Benefit Corporations (and LLCs) and
# Social Purpose Corporations (and LLCs). Developers can contact [email protected]
# For commercial licensing, distribution of derivative works or redistribution please contact [email protected]
# Distributed on an "AS IS” basis without warranties or conditions of any kind, either express or implied.
# Trademarks of Neongecko: Neon AI(TM), Neon Assist (TM), Neon Communicator(TM), Klat(TM)
# Authors: Guy Daniels, Daniel McKnight, Regina Bloomstine, Elon Gasper, Richard Leeds
#
# Specialized conversational reconveyance options from Conversation Processing Intelligence Corp.
# US Patents 2008-2023: US7424516, US20140161250, US20140177813, US8638908, US8068604, US8553852, US10530923, US10530924
# China Patent: CN102017585 - Europe Patent: EU2156652 - Patents Pending
74 changes: 74 additions & 0 deletions neon_minerva/chatbots/test_constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Development System
#
# Copyright 2008-2023 Neongecko.com Inc. | All Rights Reserved
#
# Notice of License - Duplicating this Notice of License near the start of any file containing
# a derivative of this software is a condition of license for this software.
# Friendly Licensing:
# No charge, open source royalty free use of the Neon AI software source and object is offered for
# educational users, noncommercial enthusiasts, Public Benefit Corporations (and LLCs) and
# Social Purpose Corporations (and LLCs). Developers can contact [email protected]
# For commercial licensing, distribution of derivative works or redistribution please contact [email protected]
# Distributed on an "AS IS” basis without warranties or conditions of any kind, either express or implied.
# Trademarks of Neongecko: Neon AI(TM), Neon Assist (TM), Neon Communicator(TM), Klat(TM)
# Authors: Guy Daniels, Daniel McKnight, Regina Bloomstine, Elon Gasper, Richard Leeds
#
# Specialized conversational reconveyance options from Conversation Processing Intelligence Corp.
# US Patents 2008-2023: US7424516, US20140161250, US20140177813, US8638908, US8068604, US8553852, US10530923, US10530924
# China Patent: CN102017585 - Europe Patent: EU2156652 - Patents Pending

PROMPT = "hello!"

RESPONSES = {"Ned": "Hi, I'm Ned. How are you, testrunner?",
"Eliza": "Hello... I'm glad you could drop by today.",
"terry": "Hey",
"Ima": "I am ready to talk",
"wolfram": "Hello, human",
"kbot": "hello!",
"alice": "Hi there!",
"abstain": ""}

VOTES_BY_USER = {
'1prompt1': {
'bot1': [],
'bot2': ['bot1'],
'bot3': [],
'bot4': [],
'abstain': ['bot2', 'bot3', 'bot4']
},
'2prompt2': {
'bot1': [],
'bot2': [],
'bot4': [],
'abstain': ['bot1', 'bot2', 'bot4']
},
'3prompt3': {
'bot1': [],
'bot2': ['bot1'],
'bot3': [],
'bot4': [],
'abstain': ['bot2', 'bot3', 'bot4']
}
}

SELECTIONS = {
'bot1': [('prompt1', 'bot2'), ('prompt2', 'abstain'), ('prompt3', 'bot2')],
'bot2': [('prompt1', 'abstain'), ('prompt2', 'abstain'), ('prompt3', 'abstain')],
'bot3': [('prompt1', 'abstain'), ('prompt3', 'abstain')],
'bot4': [('prompt1', 'abstain'), ('prompt2', 'abstain'), ('prompt3', 'abstain')]
}

SELECTION_HISTORY = ['bot2', 'bot2', 'bot2']

PARTICIPANT_HISTORY = [(), # element 0 is expected to be an empty tuple
('bot1', 'bot2', 'bot3', 'bot4'),
('bot1', 'bot2', 'bot3', 'bot4')]

# ContextKeeper constants
RECENT_USERS = [f"user{number}" for number in range(20)]
RECENT_SHOUTS = [
"Who is the president of Ukraine?",
"Who is the president of the US?",
"What is the distance between them?",
"When was he born?"
]
31 changes: 31 additions & 0 deletions neon_minerva/chatbots/util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Development System
#
# Copyright 2008-2023 Neongecko.com Inc. | All Rights Reserved
#
# Notice of License - Duplicating this Notice of License near the start of any file containing
# a derivative of this software is a condition of license for this software.
# Friendly Licensing:
# No charge, open source royalty free use of the Neon AI software source and object is offered for
# educational users, noncommercial enthusiasts, Public Benefit Corporations (and LLCs) and
# Social Purpose Corporations (and LLCs). Developers can contact [email protected]
# For commercial licensing, distribution of derivative works or redistribution please contact [email protected]
# Distributed on an "AS IS” basis without warranties or conditions of any kind, either express or implied.
# Trademarks of Neongecko: Neon AI(TM), Neon Assist (TM), Neon Communicator(TM), Klat(TM)
# Authors: Guy Daniels, Daniel McKnight, Regina Bloomstine, Elon Gasper, Richard Leeds
#
# Specialized conversational reconveyance options from Conversation Processing Intelligence Corp.
# US Patents 2008-2023: US7424516, US20140161250, US20140177813, US8638908, US8068604, US8553852, US10530923, US10530924
# China Patent: CN102017585 - Europe Patent: EU2156652 - Patents Pending
import pkg_resources


def load_chatbot(name: str):
try:
from importlib_metadata import entry_points
bot_entrypoints = entry_points(group="neon.plugin.chatbot")
except ImportError:
bot_entrypoints = pkg_resources.iter_entry_points("neon.plugin.chatbot")

for bot in bot_entrypoints:
if bot.name == name:
return bot.load()
2 changes: 1 addition & 1 deletion neon_minerva/intent_services/padatious.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from padatious import IntentContainer
from ovos_utils.log import LOG
from ovos_utils.messagebus import FakeBus

Expand All @@ -36,6 +35,7 @@

class PadatiousContainer:
def __init__(self, lang: str, cache_path: str, bus: FakeBus):
from padatious import IntentContainer
self.cache_dir = cache_path
self.lang = lang.lower()
self.bus = bus
Expand Down
7 changes: 5 additions & 2 deletions neon_minerva/skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@ def get_skill_object(skill_entrypoint: str, bus: FakeBus,
@param skill_entrypoint: Skill plugin entrypoint or directory path
@param bus: FakeBus instance to bind to skill for testing
@param skill_id: skill_id to initialize skill with
@param config_patch: Configuration update to apply
@returns: Initialized skill object
"""
if config_patch:
from ovos_config.config import update_mycroft_config
update_mycroft_config(config_patch)
from ovos_config.config import update_mycroft_config, Configuration
user_config = update_mycroft_config(config_patch)
if user_config not in Configuration.xdg_configs:
Configuration.xdg_configs.append(user_config)
if isdir(skill_entrypoint):
LOG.info(f"Loading local skill: {skill_entrypoint}")
from ovos_workshop.skill_launcher import SkillLoader
Expand Down
50 changes: 50 additions & 0 deletions neon_minerva/tests/chatbot_v1_test_base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Development System
#
# Copyright 2008-2023 Neongecko.com Inc. | All Rights Reserved
#
# Notice of License - Duplicating this Notice of License near the start of any file containing
# a derivative of this software is a condition of license for this software.
# Friendly Licensing:
# No charge, open source royalty free use of the Neon AI software source and object is offered for
# educational users, noncommercial enthusiasts, Public Benefit Corporations (and LLCs) and
# Social Purpose Corporations (and LLCs). Developers can contact [email protected]
# For commercial licensing, distribution of derivative works or redistribution please contact [email protected]
# Distributed on an "AS IS” basis without warranties or conditions of any kind, either express or implied.
# Trademarks of Neongecko: Neon AI(TM), Neon Assist (TM), Neon Communicator(TM), Klat(TM)
# Authors: Guy Daniels, Daniel McKnight, Regina Bloomstine, Elon Gasper, Richard Leeds
#
# Specialized conversational reconveyance options from Conversation Processing Intelligence Corp.
# US Patents 2008-2023: US7424516, US20140161250, US20140177813, US8638908, US8068604, US8553852, US10530923, US10530924
# China Patent: CN102017585 - Europe Patent: EU2156652 - Patents Pending


import unittest

from os import getenv
from time import sleep
from chatbot_core.utils import clean_up_bot
from klat_connector import start_socket
from klat_connector.mach_server import MachKlatServer
from neon_minerva.chatbots.util import load_chatbot


class TestSubmind(unittest.TestCase):
# Initialize a server for testing
server = MachKlatServer()
sleep(1)
socket = start_socket("0.0.0.0")
submind = None

@classmethod
def setUpClass(cls) -> None:
# Determine submind to test
submind_entrypoint = getenv("TEST_BOT_ENTRYPOINT")
bot_class = load_chatbot(submind_entrypoint)
# Initialize a submind instance
cls.submind = bot_class(cls.socket, "Private", "testrunner",
"testpassword", on_server=False)

@classmethod
def tearDownClass(cls) -> None:
clean_up_bot(cls.submind)
cls.server.shutdown_server()
Loading

0 comments on commit e60c804

Please sign in to comment.