Skip to content

Commit

Permalink
Merge branch 'OpenVoiceOS:dev' into feat/aiy_voicebonnet
Browse files Browse the repository at this point in the history
  • Loading branch information
builderjer authored Dec 3, 2023
2 parents 5df4840 + 7dcc31b commit 8c2f42c
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 30 deletions.
96 changes: 96 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,101 @@
# Changelog

## [Unreleased](https://github.com/OpenVoiceOS/ovos-PHAL/tree/HEAD)

[Full Changelog](https://github.com/OpenVoiceOS/ovos-PHAL/compare/V0.0.5a12...HEAD)

**Fixed bugs:**

- fix/PHAL admin service status [\#25](https://github.com/OpenVoiceOS/ovos-PHAL/pull/25) ([JarbasAl](https://github.com/JarbasAl))

## [V0.0.5a12](https://github.com/OpenVoiceOS/ovos-PHAL/tree/V0.0.5a12) (2023-09-19)

[Full Changelog](https://github.com/OpenVoiceOS/ovos-PHAL/compare/V0.0.5a11...V0.0.5a12)

**Implemented enhancements:**

- load either user or admin [\#24](https://github.com/OpenVoiceOS/ovos-PHAL/pull/24) ([emphasize](https://github.com/emphasize))

## [V0.0.5a11](https://github.com/OpenVoiceOS/ovos-PHAL/tree/V0.0.5a11) (2023-09-12)

[Full Changelog](https://github.com/OpenVoiceOS/ovos-PHAL/compare/V0.0.5a10...V0.0.5a11)

**Fixed bugs:**

- fix/no\_need\_to\_subclass [\#23](https://github.com/OpenVoiceOS/ovos-PHAL/pull/23) ([JarbasAl](https://github.com/JarbasAl))

## [V0.0.5a10](https://github.com/OpenVoiceOS/ovos-PHAL/tree/V0.0.5a10) (2023-07-14)

[Full Changelog](https://github.com/OpenVoiceOS/ovos-PHAL/compare/V0.0.5a9...V0.0.5a10)

**Merged pull requests:**

- rm deprecation logs name == skill\_id [\#21](https://github.com/OpenVoiceOS/ovos-PHAL/pull/21) ([JarbasAl](https://github.com/JarbasAl))

## [V0.0.5a9](https://github.com/OpenVoiceOS/ovos-PHAL/tree/V0.0.5a9) (2023-07-12)

[Full Changelog](https://github.com/OpenVoiceOS/ovos-PHAL/compare/V0.0.5a8...V0.0.5a9)

**Merged pull requests:**

- Update requirements.txt [\#20](https://github.com/OpenVoiceOS/ovos-PHAL/pull/20) ([JarbasAl](https://github.com/JarbasAl))

## [V0.0.5a8](https://github.com/OpenVoiceOS/ovos-PHAL/tree/V0.0.5a8) (2023-07-03)

[Full Changelog](https://github.com/OpenVoiceOS/ovos-PHAL/compare/V0.0.5a7...V0.0.5a8)

## [V0.0.5a7](https://github.com/OpenVoiceOS/ovos-PHAL/tree/V0.0.5a7) (2023-07-03)

[Full Changelog](https://github.com/OpenVoiceOS/ovos-PHAL/compare/V0.0.5a6...V0.0.5a7)

## [V0.0.5a6](https://github.com/OpenVoiceOS/ovos-PHAL/tree/V0.0.5a6) (2023-05-16)

[Full Changelog](https://github.com/OpenVoiceOS/ovos-PHAL/compare/V0.0.5a5...V0.0.5a6)

**Merged pull requests:**

- Update requirements.txt [\#19](https://github.com/OpenVoiceOS/ovos-PHAL/pull/19) ([JarbasAl](https://github.com/JarbasAl))

## [V0.0.5a5](https://github.com/OpenVoiceOS/ovos-PHAL/tree/V0.0.5a5) (2023-05-12)

[Full Changelog](https://github.com/OpenVoiceOS/ovos-PHAL/compare/V0.0.5a4...V0.0.5a5)

**Merged pull requests:**

- add project description [\#18](https://github.com/OpenVoiceOS/ovos-PHAL/pull/18) ([emphasize](https://github.com/emphasize))

## [V0.0.5a4](https://github.com/OpenVoiceOS/ovos-PHAL/tree/V0.0.5a4) (2023-04-11)

[Full Changelog](https://github.com/OpenVoiceOS/ovos-PHAL/compare/V0.0.5a3...V0.0.5a4)

**Merged pull requests:**

- refactor/update\_imports [\#17](https://github.com/OpenVoiceOS/ovos-PHAL/pull/17) ([JarbasAl](https://github.com/JarbasAl))

## [V0.0.5a3](https://github.com/OpenVoiceOS/ovos-PHAL/tree/V0.0.5a3) (2023-04-08)

[Full Changelog](https://github.com/OpenVoiceOS/ovos-PHAL/compare/V0.0.5a2...V0.0.5a3)

**Merged pull requests:**

- bump requirements.txt [\#16](https://github.com/OpenVoiceOS/ovos-PHAL/pull/16) ([JarbasAl](https://github.com/JarbasAl))

## [V0.0.5a2](https://github.com/OpenVoiceOS/ovos-PHAL/tree/V0.0.5a2) (2023-04-05)

[Full Changelog](https://github.com/OpenVoiceOS/ovos-PHAL/compare/V0.0.5a1...V0.0.5a2)

**Merged pull requests:**

- bump requirements.txt [\#15](https://github.com/OpenVoiceOS/ovos-PHAL/pull/15) ([JarbasAl](https://github.com/JarbasAl))

## [V0.0.5a1](https://github.com/OpenVoiceOS/ovos-PHAL/tree/V0.0.5a1) (2023-04-04)

[Full Changelog](https://github.com/OpenVoiceOS/ovos-PHAL/compare/V0.0.4...V0.0.5a1)

## [V0.0.4](https://github.com/OpenVoiceOS/ovos-PHAL/tree/V0.0.4) (2022-11-16)

[Full Changelog](https://github.com/OpenVoiceOS/ovos-PHAL/compare/V0.0.4a4...V0.0.4)

## [V0.0.4a4](https://github.com/OpenVoiceOS/ovos-PHAL/tree/V0.0.4a4) (2022-11-16)

[Full Changelog](https://github.com/OpenVoiceOS/ovos-PHAL/compare/V0.0.4a3...V0.0.4a4)
Expand Down
2 changes: 2 additions & 0 deletions ovos_PHAL/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from ovos_PHAL.service import PHAL, on_ready, on_error, on_stopping

from ovos_utils import wait_for_exit_signal
from ovos_utils.log import init_service_logger


def main(ready_hook=on_ready, error_hook=on_error, stopping_hook=on_stopping):
Expand All @@ -9,6 +10,7 @@ def main(ready_hook=on_ready, error_hook=on_error, stopping_hook=on_stopping):
# "ovos-PHAL-plugin-display-manager-ipc": {"enabled": true},
# "ovos-PHAL-plugin-mk1": {"enabled": True}
# }
init_service_logger("PHAL")
phal = PHAL(on_error=error_hook, on_ready=ready_hook, on_stopping=stopping_hook)
phal.start()
wait_for_exit_signal()
Expand Down
25 changes: 14 additions & 11 deletions ovos_PHAL/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from ovos_plugin_manager.phal import find_admin_plugins
from ovos_utils import wait_for_exit_signal
from ovos_utils.configuration import read_mycroft_config
from ovos_utils.log import LOG
from ovos_config import Configuration
from ovos_utils.log import LOG, init_service_logger

from ovos_PHAL import PHAL

Expand Down Expand Up @@ -37,18 +37,20 @@ class AdminPHAL(PHAL):

def __init__(self, config=None, bus=None, on_ready=on_admin_ready, on_error=on_admin_error,
on_stopping=on_admin_stopping, on_started=on_admin_started, on_alive=on_admin_alive,
watchdog=lambda: None, name="PHAL.admin", **kwargs):
if not config:
try:
config = read_mycroft_config()
config = config.get("PHAL", {}).get("admin", {})
except:
config = {}
super().__init__(config, bus, on_ready, on_error, on_stopping, on_started, on_alive, watchdog, name, **kwargs)
watchdog=lambda: None, skill_id="PHAL.admin", **kwargs):
if config and "admin" not in config:
config = {"admin": config}
super().__init__(config, bus, on_ready, on_error, on_stopping, on_started, on_alive, watchdog, skill_id, **kwargs)

def load_plugins(self):
for name, plug in find_admin_plugins().items():
config = self.config.get(name) or {}
# load the plugin only if not defined as user plugin
# (for plugins that can be used as admin or user plugins)
if name in self.user_config:
LOG.debug(f"PHAL plugin {name} runs as user plugin, skipping")
continue

config = self.admin_config.get(name) or {}
enabled = config.get("enabled")
if not enabled:
continue # require explicit enabling by user
Expand All @@ -71,6 +73,7 @@ def main(ready_hook=on_admin_ready, error_hook=on_admin_error, stopping_hook=on_
# "ovos-PHAL-plugin-system": {"enabled": True}
# }
# }
init_service_logger("PHAL_admin")
phal = AdminPHAL(on_error=error_hook, on_ready=ready_hook, on_stopping=stopping_hook)
phal.start()
wait_for_exit_signal()
Expand Down
39 changes: 24 additions & 15 deletions ovos_PHAL/service.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from ovos_plugin_manager.phal import find_phal_plugins
from ovos_utils.configuration import read_mycroft_config
from ovos_config import Configuration
from ovos_utils.log import LOG
from ovos_utils.messagebus import get_mycroft_bus
from ovos_bus_client.client import MessageBusClient
from ovos_utils.process_utils import ProcessStatus, StatusCallbackMap
from ovos_workshop import OVOSAbstractApplication


def on_ready():
Expand All @@ -26,7 +25,7 @@ def on_started():
LOG.info('PHAL is started')


class PHAL(OVOSAbstractApplication):
class PHAL:
"""
Args:
config (dict): PHAL config, usually from mycroft.conf
Expand All @@ -38,8 +37,13 @@ class PHAL(OVOSAbstractApplication):
def __init__(self, config=None, bus=None,
on_ready=on_ready, on_error=on_error,
on_stopping=on_stopping, on_started=on_started, on_alive=on_alive,
watchdog=lambda: None, name="PHAL", **kwargs):
super().__init__(skill_id=f"ovos.{name}")
watchdog=lambda: None, skill_id="PHAL", **kwargs):
if not bus:
bus = MessageBusClient()
bus.run_in_thread()
self.skill_id = skill_id
self.bus = bus

ready_hook = kwargs.get('ready_hook', on_ready)
error_hook = kwargs.get('error_hook', on_error)
stopping_hook = kwargs.get('stopping_hook', on_stopping)
Expand All @@ -50,21 +54,25 @@ def __init__(self, config=None, bus=None,
on_stopping=stopping_hook,
on_alive=alive_hook,
on_started=started_hook)
self.status = ProcessStatus(name, callback_map=callbacks)
self.status = ProcessStatus(skill_id, callback_map=callbacks)
self._watchdog = watchdog # TODO implement
if not config:
try:
config = read_mycroft_config()["PHAL"]
except:
config = {}
self.config = config
self.bus = bus or get_mycroft_bus()
self.user_config = config or Configuration().get("PHAL") or {}
if "admin" in self.user_config:
self.admin_config = self.user_config.pop("admin")
else:
self.admin_config = {}
self.drivers = {}
self.status.bind(self.bus)

def load_plugins(self):
for name, plug in find_phal_plugins().items():
config = self.config.get(name) or {}
# load the plugin only if not defined as admin plugin
# (for plugins that can be used as admin or user plugins)
if name in self.admin_config:
LOG.debug(f"PHAL plugin {name} runs as admin plugin, skipping")
continue

config = self.user_config.get(name) or {}
if hasattr(plug, "validator"):
enabled = plug.validator.validate(config)
else:
Expand All @@ -83,6 +91,7 @@ def start(self):
self.load_plugins()
self.status.set_ready()
except Exception as e:
LOG.exception(e)
self.status.set_error(e)

def shutdown(self):
Expand Down
2 changes: 1 addition & 1 deletion ovos_PHAL/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
VERSION_MAJOR = 0
VERSION_MINOR = 0
VERSION_BUILD = 5
VERSION_ALPHA = 0
VERSION_ALPHA = 13
# END_VERSION_BLOCK
8 changes: 5 additions & 3 deletions requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ovos-utils~=0.0, >=0.0.21
ovos_workshop~=0.0, >=0.0.8
ovos-plugin-manager~=0.0, >=0.0.20
ovos-utils<0.1.0, >=0.0.35a7
ovos_bus_client<0.1.0, >=0.0.5
ovos_workshop~=0.0, >=0.0.12a38
ovos-config~=0.0,>=0.0.11a3
ovos-plugin-manager~=0.0, >=0.0.24a5
9 changes: 9 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,22 @@ def required(requirements_file):
if pkg.strip() and not pkg.startswith("#")]


long_description = ""
if os.path.isfile(os.path.join(BASEDIR, "README.md")):
with open(os.path.join(BASEDIR, "README.md"), "r") as f:
long_description = f.read()


setup(
name='ovos_PHAL',
version=get_version(),
packages=['ovos_PHAL'],
install_requires=required("requirements/requirements.txt"),
package_data={'': package_files('ovos_PHAL')},
url='https://github.com/OpenVoiceOS/ovos-PHAL',
description="Plugin based Hardware Abstraction Layer for OVOS",
long_description=long_description,
long_description_content_type="text/markdown",
license='apache-2.0',
author='jarbasAi',
author_email='[email protected]',
Expand Down

0 comments on commit 8c2f42c

Please sign in to comment.