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

Refactor skill service #2220

Merged
merged 41 commits into from Jul 26, 2019
Merged

Refactor skill service #2220

merged 41 commits into from Jul 26, 2019

Conversation

chrisveilleux
Copy link
Member

Description

Refactor the code that starts the skill service and primes the device when connected to the internet. Mostly just reorganized the code but also made a change to the logic that determines if a device is paired. The change reduces the amount of API calls to one.

How to test

This is a refactor so the unit tests need to pass and the skill service needs to work the same as it has.

Contributor license agreement signed?

CLA [yes]

- added some docstrings
- put config retrieval in a function
- added log messages
- fixed spelling error
- renamed variable that shadowed built-in
- reordered imports
- refactored docstrings for consistency
- renamed camel case variables to use snake case
- renamed the message bus client
- abstracted message bus config loading so service and client can use same code.
… it is a backport that inherits from the new MessageBusClient class. Added a deprecation comment as well.
… may cause breakage. added todo to include in next major release.
- broke big functions up into classes/methods
- reworked the multiple calls to is_paired() into a single call to minimize API calls and improve performance a bit
- added more documentation
- added more logging
- other miscellaneous cleaning stuff
@pep8speaks
Copy link

pep8speaks commented Jul 18, 2019

Hello @chrisveilleux! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2019-07-26 06:24:44 UTC

@devs-mycroft devs-mycroft added the CLA: Yes Contributor License Agreement exists (see https://github.com/MycroftAI/contributors) label Jul 18, 2019
@forslund
Copy link
Collaborator

There are some really good things here (and a few things I don't quite agree with). Will you let me take a stab at making an alternative approach during the weekend based on this?

@chrisveilleux
Copy link
Member Author

There are some really good things here (and a few things I don't quite agree with). Will you let me take a stab at making an alternative approach during the weekend based on this?

Have at it. Interested to see the differences between our approaches.

Copy link
Collaborator

@forslund forslund left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok this is much more to my liking. A couple of minor things (see separate comments).

I wonder if we need to have the _ at the start of functions since this is a __main__.py and it's quite clear it should not be imported?

mycroft/skills/__main__.py Show resolved Hide resolved
mycroft/skills/__main__.py Outdated Show resolved Hide resolved
mycroft/skills/__main__.py Outdated Show resolved Hide resolved
mycroft/skills/__main__.py Show resolved Hide resolved
mycroft/skills/__main__.py Outdated Show resolved Hide resolved
mycroft/skills/__main__.py Outdated Show resolved Hide resolved
@@ -230,15 +230,14 @@ def load_config_stack(configs=None, cache=False):
return base

@staticmethod
def init(ws):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the rename but we might want to keep the init method as well for backwards compatibility

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed all the core uses of this. Are there other repos that could call this?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically things like third party enclosures may use it or other things build for working with mycroft-core.

I do think we can have a rather short depreciation period though and remove it outright in 19.08 since it's a rarely touched thing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. will add an init method back that calls the new method and add a deprecation warning.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ugh! since it is a static method, I had to actually duplicate the method rather than have one call the other. I added a deprecation message. How do we track things like this that will be breaking changes in 19.08? Do we just search the code base for comments that mention 19.08?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's basically it yeah TODO: 19.08 or similar comments

@forslund
Copy link
Collaborator

Also can you do a rebase against dev? The commit history looks really weird...

@chrisveilleux
Copy link
Member Author

Also can you do a rebase against dev? The commit history looks really weird...

done

@forslund
Copy link
Collaborator

I think this looks pretty good, gonna do some final testruns. I want the current release to be out for 24 hours and then I'll merge this on Friday if no hot-fixes are needed.

@forslund forslund added the Type: Refactoring and other improvements Improvement of code and documentation that does not alter functionality. label Jul 26, 2019
@forslund forslund merged commit 0bde1bc into dev Jul 26, 2019
@forslund forslund deleted the refactor-skill-service branch July 26, 2019 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA: Yes Contributor License Agreement exists (see https://github.com/MycroftAI/contributors) Type: Refactoring and other improvements Improvement of code and documentation that does not alter functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants