Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing Example and Adding Keyword Arguments as option for parameters #37

Merged
merged 12 commits into from
Aug 28, 2020
5 changes: 4 additions & 1 deletion docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ Try the example app `time_app.py`_ with the ``--help`` flag to see what settings

.. _`time_app.py`: https://github.com/rhasspy/rhasspy-hermes-app/blob/master/examples/time_app.py

You can pass all the settings as keyword arguments inside the constructor aswell:
:meth:`HermesApp("ExampleApp", host = "192.168.178.123", port = 12183)`

*******
Asyncio
*******
Expand Down Expand Up @@ -65,7 +68,7 @@ If the API of this library changes, your app possibly stops working when it upda

.. code-block::

rhasspy-hermes-app==0.2.0
rhasspy-hermes-app==1.0.0

This way your app keeps working when the Rhasspy Hermes App adds incompatible changes in a new version.

Expand Down
2 changes: 1 addition & 1 deletion examples/async_advice_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
None of the authors, contributors, administrators, or anyone else connected with Rhasspy_Hermes_App,
in any way whatsoever, can be responsible for your use of the api endpoint.
"""
URL = 'https://api.advicslip.com/advice'
URL = 'https://api.adviceslip.com/advice'

@app.on_intent("GetAdvice")
async def get_advice(intent: NluIntent):
Expand Down
6 changes: 6 additions & 0 deletions rhasspyhermes_app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def __init__(
name: str,
parser: Optional[argparse.ArgumentParser] = None,
mqtt_client: Optional[mqtt.Client] = None,
**kwargs
):
"""Initialize the Rhasspy Hermes app.

Expand All @@ -106,6 +107,11 @@ def __init__(
# Parse command-line arguments
self.args = parser.parse_args()

# Option to set all parameters as keyword arguments !!! CLI arguments are rated higher priority
args_dict = vars(self.args)
for key, value in kwargs.items():
args_dict[key] = args_dict[key] if key in args_dict else value
JonahKr marked this conversation as resolved.
Show resolved Hide resolved

# Set up logging
hermes_cli.setup_logging(self.args)
_LOGGER.debug(self.args)
Expand Down