Skip to content

Commit

Permalink
Update automation and cleanup for release (#176)
Browse files Browse the repository at this point in the history
* Update automation to latest standards
Update docs and meta to prep for PyPI release
Add Python3.11 unit tests

* Refactor autocorrect LGPL dependency to optional requirements
Update references to autocorrect
Remove unused `requirements.txt`

* Update license excluded packages
Add missing `neon-utils` dependency

* Exclude tqdm (MPL) and dnspython (ISC) from license tests

* Update pytest version to troubleshoot unit test failures

* Remove and annotate Python 3.10-3.11 test failures

---------

Co-authored-by: Daniel McKnight <[email protected]>
  • Loading branch information
NeonDaniel and NeonDaniel authored Nov 29, 2023
1 parent d50dafb commit bfaffd9
Show file tree
Hide file tree
Showing 14 changed files with 78 additions and 76 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/license_tests.yml
Original file line number Diff line number Diff line change
@@ -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).*'
27 changes: 27 additions & 0 deletions .github/workflows/propose_release.yml
Original file line number Diff line number Diff line change
@@ -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 }}
17 changes: 4 additions & 13 deletions .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
@@ -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
26 changes: 7 additions & 19 deletions .github/workflows/publish_test_build.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
21 changes: 0 additions & 21 deletions .github/workflows/pull_master.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
11 changes: 8 additions & 3 deletions chatbot_core/utils/bot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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}")
Expand Down
12 changes: 11 additions & 1 deletion chatbot_core/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 0 additions & 11 deletions requirements.txt

This file was deleted.

1 change: 1 addition & 0 deletions requirements/extra-lgpl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
autocorrect~=2.2.2
2 changes: 1 addition & 1 deletion requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion requirements/test_requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pytest~=6.1.2
pytest~=7.4
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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")}
)

0 comments on commit bfaffd9

Please sign in to comment.