diff --git a/.github/workflows/license_tests.yml b/.github/workflows/license_tests.yml new file mode 100644 index 0000000..05f6450 --- /dev/null +++ b/.github/workflows/license_tests.yml @@ -0,0 +1,12 @@ +name: Run License Tests +on: + push: + workflow_dispatch: + pull_request: + branches: + - master +jobs: + license_tests: + uses: neongeckocom/.github/.github/workflows/license_tests.yml@master + with: + packages-exclude: '^(bs4|nvidia|bitstruct|audioread|klat-connector|chatbot-core|tqdm|dnspython).*' \ No newline at end of file diff --git a/.github/workflows/propose_release.yml b/.github/workflows/propose_release.yml new file mode 100644 index 0000000..81dfe43 --- /dev/null +++ b/.github/workflows/propose_release.yml @@ -0,0 +1,27 @@ +name: Propose Stable Release +on: + workflow_dispatch: + inputs: + release_type: + type: choice + description: Release Type + options: + - patch + - minor + - major +jobs: + update_version: + uses: neongeckocom/.github/.github/workflows/propose_semver_release.yml@master + with: + branch: dev + release_type: ${{ inputs.release_type }} + update_changelog: True + pull_changes: + uses: neongeckocom/.github/.github/workflows/pull_master.yml@master + needs: update_version + with: + pr_reviewer: neonreviewers + pr_assignee: ${{ github.actor }} + pr_draft: false + pr_title: ${{ needs.update_version.outputs.version }} + pr_body: ${{ needs.update_version.outputs.changelog }} \ No newline at end of file diff --git a/.github/workflows/publish_release.yml b/.github/workflows/publish_release.yml index 2dbb6bd..e4b3fa3 100644 --- a/.github/workflows/publish_release.yml +++ b/.github/workflows/publish_release.yml @@ -1,21 +1,12 @@ # This workflow will generate a release distribution and upload it to PyPI -name: Publish GitHub Release +name: Publish Build and GitHub Release on: push: branches: - master jobs: - tag_release: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Get Version - run: | - VERSION=$(python setup.py --version) - echo "VERSION=${VERSION}" >> $GITHUB_ENV - - uses: ncipollo/release-action@v1 - with: - token: ${{secrets.GITHUB_TOKEN}} - tag: ${{env.VERSION}} + build_and_publish_pypi_and_release: + uses: neongeckocom/.github/.github/workflows/publish_stable_release.yml@master + secrets: inherit diff --git a/.github/workflows/publish_test_build.yml b/.github/workflows/publish_test_build.yml index f69e54d..2721648 100644 --- a/.github/workflows/publish_test_build.yml +++ b/.github/workflows/publish_test_build.yml @@ -1,6 +1,6 @@ # This workflow will generate a distribution and upload it to PyPI -name: Increment Alpha Version +name: Publish Alpha Build on: push: branches: @@ -9,21 +9,9 @@ on: - 'version.py' jobs: - build_and_publish: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - ref: ${{ github.head_ref }} - - name: Setup Python - uses: actions/setup-python@v1 - with: - python-version: 3.8 - - name: Increment Version - run: | - VER=$(python setup.py --version) - python version_bump.py - - name: Push Version Change - uses: stefanzweifel/git-auto-commit-action@v4 - with: - commit_message: Increment Version + publish_alpha_release: + uses: neongeckocom/.github/.github/workflows/publish_alpha_release.yml@master + secrets: inherit + with: + version_file: "version.py" + publish_prerelease: true diff --git a/.github/workflows/pull_master.yml b/.github/workflows/pull_master.yml deleted file mode 100644 index 46c30d2..0000000 --- a/.github/workflows/pull_master.yml +++ /dev/null @@ -1,21 +0,0 @@ -# This workflow will generate a PR for changes in cert into master - -name: Pull to Master -on: - push: - branches: - - dev - - cert - workflow_dispatch: - -jobs: - pull_changes: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: pull-request-action - uses: repo-sync/pull-request@v2 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - pr_reviewer: 'neonreviewers' - pr_assignee: 'neondaniel' \ No newline at end of file diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 5c47c5e..5e6ef21 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -9,7 +9,8 @@ jobs: unit_tests: strategy: matrix: - python-version: [ 3.7, 3.8, 3.9, '3.10' ] + python-version: [ 3.7, 3.8, 3.9 ] + # TODO: 3.10 and 3.11 need support in klat-connector max-parallel: 1 runs-on: ubuntu-latest timeout-minutes: 15 diff --git a/README.md b/README.md index 5df3c03..c0ce978 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,4 @@ # Chatbot Core -![Unit Tests](https://github.com/NeonGeckoCom/chatbot-core/workflows/Run%20Unit%20Tests/badge.svg) - Bots using this framework connect to the Klat server and respond to user shouts. Bots will respond individually, like any other user in the conversation. diff --git a/chatbot_core/utils/bot_utils.py b/chatbot_core/utils/bot_utils.py index 407590a..0e55d50 100644 --- a/chatbot_core/utils/bot_utils.py +++ b/chatbot_core/utils/bot_utils.py @@ -31,7 +31,6 @@ from threading import Thread, current_thread from mycroft_bus_client import Message, MessageBusClient -from autocorrect import Speller from nltk.translate.bleu_score import sentence_bleu from nltk import word_tokenize @@ -605,12 +604,18 @@ def grammar_check(func): Checks grammar for output of passed function :param func: function to consider """ - spell = Speller() + try: + from autocorrect import Speller + spell = Speller() + except ImportError: + LOG.error("autocorrect module not available. Install " + "`chatbot-core[extra-lgpl]` to use autocorrect.") + spell = None def wrapper(*args, **kwargs): LOG.debug("Entered decorator") output = func(*args, **kwargs) - if output: + if output and spell: LOG.debug(f"Received output: {output}") output = spell(output) LOG.debug(f"Processed output: {output}") diff --git a/chatbot_core/v1/__init__.py b/chatbot_core/v1/__init__.py index 0c604d8..9d8dc75 100644 --- a/chatbot_core/v1/__init__.py +++ b/chatbot_core/v1/__init__.py @@ -35,13 +35,23 @@ from chatbot_core.utils import init_message_bus, make_logger, ConversationState,ConversationControls,\ remove_prefix, generate_random_response, BotTypes from chatbot_core.chatbot_abc import ChatBotABC +from chatbot_core.utils.logger import LOG from mycroft_bus_client import Message, MessageBusClient -from autocorrect import Speller from nltk.translate.bleu_score import sentence_bleu from nltk import word_tokenize import jellyfish import spacy +try: + from autocorrect import Speller + + spell = Speller() +except ImportError: + LOG.error("autocorrect module not available. Install " + "`chatbot-core[extra-lgpl]` to use autocorrect.") + spell = None + + class ChatBot(KlatApi, ChatBotABC): def __init__(self, *args, **kwargs): socket, domain, username, password, on_server, is_prompter = self.parse_init(*args, **kwargs) diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index a8c8e22..0000000 --- a/requirements.txt +++ /dev/null @@ -1,11 +0,0 @@ -mycroft-messagebus-client -psutil~=5.7.3 -pytest~=6.1.2 -setuptools~=50.3.2 -PyYAML~=5.3.1 -autocorrect~=2.2.2 -jellyfish~=0.8.2 -nltk~=3.5 -spacy~=2.3.1 -https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.3.1/en_core_web_sm-2.3.1.tar.gz -klat-connector>=0.6.2a14 \ No newline at end of file diff --git a/requirements/extra-lgpl.txt b/requirements/extra-lgpl.txt new file mode 100644 index 0000000..cde31c4 --- /dev/null +++ b/requirements/extra-lgpl.txt @@ -0,0 +1 @@ +autocorrect~=2.2.2 diff --git a/requirements/requirements.txt b/requirements/requirements.txt index d712c83..0653aeb 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -2,7 +2,7 @@ mycroft-messagebus-client klat-connector>=0.6.2a15 psutil~=5.7.3 setuptools~=50.3.2 -autocorrect~=2.2.2 jellyfish~=0.8.2 nltk~=3.5 spacy~=2.3.1 +neon_utils~=1.0 \ No newline at end of file diff --git a/requirements/test_requirements.txt b/requirements/test_requirements.txt index da6ef2f..8aaecd9 100644 --- a/requirements/test_requirements.txt +++ b/requirements/test_requirements.txt @@ -1 +1 @@ -pytest~=6.1.2 \ No newline at end of file +pytest~=7.4 \ No newline at end of file diff --git a/setup.py b/setup.py index 7b87cdb..51ce4a1 100644 --- a/setup.py +++ b/setup.py @@ -54,8 +54,8 @@ def get_requirements(requirements_filename: str): setuptools.setup( name="chatbot-core", version=version, - author="NeonDaniel", - author_email="daniel@neon.ai", + author="Neongecko", + author_email="developers@neon.ai", description="Core utilities for Klat chatbots", long_description=long_description, long_description_content_type="text/markdown", @@ -70,5 +70,6 @@ def get_requirements(requirements_filename: str): "stop-klat-bots=chatbot_core.utils:cli_stop_bots", "debug-klat-bots=chatbot_core.utils:debug_bots", "start-klat-prompter=chatbot_core.utils:cli_start_prompter"]}, - install_requires=get_requirements("requirements.txt") + install_requires=get_requirements("requirements.txt"), + extras_requires={"extra-lgpl": get_requirements("extra-lgpl.txt")} )