Skip to content

Commit

Permalink
feat: intent for "wake me"
Browse files Browse the repository at this point in the history
closes #119
  • Loading branch information
mikejgray committed Oct 29, 2024
1 parent ea25ae7 commit 91b49ec
Show file tree
Hide file tree
Showing 9 changed files with 196 additions and 5 deletions.
163 changes: 163 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,166 @@
*.pyc
__pycache__/
!.github/*

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
3 changes: 2 additions & 1 deletion __init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 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.
# Copyright 2008-2024 Neongecko.com Inc.
# Contributors: Daniel McKnight, Guy Daniels, Elon Gasper, Richard Leeds,
# Regina Bloomstine, Casimiro Ferreira, Andrii Pernatii, Kirill Hrymailo
# BSD-3 License
Expand Down Expand Up @@ -218,6 +218,7 @@ def on_ready(self, _: Message):
self._update_homescreen(True, True)

# Intent Handlers
@intent_handler("wake_me.intent")
@intent_handler(IntentBuilder("CreateAlarm").require("set")
.require("alarm").optionally("playable")
.optionally("weekdays").optionally("weekends")
Expand Down
1 change: 1 addition & 0 deletions locale/en-us/intent/wake_me.intent
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
wake me (|up )(at|in) {time}
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ neon-utils[network]~=1.2,>=1.11.1a3
combo_lock~=0.2
ovos-utils~=0.0, >=0.0.32
ovos-bus-client~=0.0,>=0.0.3
ovos-workshop~=0.0,>=0.0.12
ovos-workshop~=0.0,>=0.0.12
ovos-plugin-manager<1.0.0
ovos-core<1.0.0
2 changes: 2 additions & 0 deletions requirements/test.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
neon-minerva[padatious]~=0.2
mock
pytest
5 changes: 5 additions & 0 deletions test/test_intents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ en-us:
- do i have any upcoming events
- list my alarms
- what are the reminders
wake_me.intent:
- wake me up at {time}
- wake me up in {time}
- wake me at {time}
- wake me in {time}
TimerStatus:
- how much time is left
- how long on that timer
Expand Down
1 change: 1 addition & 0 deletions test/test_resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ intents:
- list_alerts.intent
- quiet_hours_start.intent
- quiet_hours_end.intent
- wake_me.intent

adapt:
- 'CreateAlarm'
Expand Down
20 changes: 18 additions & 2 deletions test/test_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import lingua_franca
import pytest
import random
import sys
import shutil
import unittest
import datetime as dt
Expand Down Expand Up @@ -2297,6 +2296,24 @@ def _validate_alert_default_params(reminder: Alert):
self.assertEqual(rotate_logs_reminder.repeat_frequency,
dt.timedelta(hours=8))

def test_wake_me_intent(self):
from skill_alerts.util.parse_utils import build_alert_from_intent
sea_tz = gettz("America/Los_Angeles")
wake_me_up = _get_message_from_file("wake_me_up_at_time_alarm.json")
wake_me_in = _get_message_from_file("wake_me_up_in_time_alarm.json")

wake_me_up_alert = build_alert_from_intent(wake_me_up, AlertType.ALARM,
sea_tz)
wake_me_in_alert = build_alert_from_intent(wake_me_in, AlertType.ALARM,
sea_tz)

self.assertEqual(wake_me_up_alert.alert_name, "7:00 AM alarm")
self.assertEqual(wake_me_in_alert.alert_name, "in 8 hours alarm")
self.assertEqual(wake_me_up_alert.next_expiration.time(),
dt.time(hour=7))
self.assertAlmostEqual(wake_me_in_alert.next_expiration.timestamp(),
(dt.datetime.now(sea_tz) +
dt.timedelta(hours=8)).timestamp(), delta=2)

class TestUIModels(unittest.TestCase):
lingua_franca.load_language('en')
Expand Down Expand Up @@ -2386,6 +2403,5 @@ def test_build_alarm_data(self):
self.assertEqual(metric_display['alarmIndex'],
get_alert_id(metric_alarm))


if __name__ == '__main__':
pytest.main()
2 changes: 1 addition & 1 deletion util/parse_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 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.
# Copyright 2008-2024 Neongecko.com Inc.
# Contributors: Daniel McKnight, Guy Daniels, Elon Gasper, Richard Leeds,
# Regina Bloomstine, Casimiro Ferreira, Andrii Pernatii, Kirill Hrymailo
# BSD-3 License
Expand Down

0 comments on commit 91b49ec

Please sign in to comment.