Skip to content
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.

fallback order override #987

Closed
wants to merge 2 commits into from
Closed

fallback order override #987

wants to merge 2 commits into from

Conversation

JarbasAI
Copy link
Contributor

sometimes we may not agree with dev choices on fallback priority, an option to override the fallback order in config would be good, so we can get updates without git pull complaining of stashing changes, also good for dev purposes

This pr is more for discussion than a serious proposal

  • add fallback override flag in config, default false
  • add fallback order list with skill folder names, default empty
  • on register fallback track folder to handler
  • on handler if override flag try ordered list
  • if entry missing in ordered list try it next by skill load order
  • if no override flag behave normally
  • on shutdown also remove handler from tracked folder handlers

@augustnmonteiro
Copy link
Contributor

@JarbasAI thank you for the contribution, travis is getting those pep8 erros

mycroft/skills/core.py:433:42: E225 missing whitespace around operator
mycroft/skills/core.py:438:80: E501 line too long (92 > 79 characters)
mycroft/skills/core.py:442:80: E501 line too long (85 > 79 characters)
mycroft/skills/core.py:449:80: E501 line too long (84 > 79 characters)
mycroft/skills/core.py:462:80: E501 line too long (80 > 79 characters)
mycroft/skills/core.py:484:8: E114 indentation is not a multiple of four (comment)
mycroft/skills/core.py:544:1: W391 blank line at end of file```

@penrods penrods added the CLA: Yes Contributor License Agreement exists (see https://github.com/MycroftAI/contributors) label Aug 14, 2017
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.

Looks good, except for a couple of cleanups. This is definitely a feature we want to have in the long run! Many thanks

@@ -401,6 +401,9 @@ def shutdown(self):

class FallbackSkill(MycroftSkill):
fallback_handlers = {}
folders = {}
override = skills_config.get("fallback_override", False)
order = skills_config.get("fallback_priority", [])
Copy link
Collaborator

@forslund forslund Aug 15, 2017

Choose a reason for hiding this comment

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

is the override config parameter necessary. The check could be if len(order) > 0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i like the override parameter, i may want to have the override list there but only toggle it sometimes, with the PR for changing config at runtime from skills this can even be changed vocally

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, Gotcha.

@@ -413,20 +416,58 @@ def make_intent_failure_handler(cls, ws):
"""Goes through all fallback handlers until one returns true"""

def handler(message):
for _, handler in sorted(cls.fallback_handlers.items(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

split this into ordered_handler using the handler order from config and priority_handler for the default and do the check at L467 (returning either ordered_handler or priority_handler)

flag2 = True

if not flag1:
logger.warn('Could not remove fallback!')
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe call the flag success and move the waring text to just after the for loop where it's used (L517)

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 40.596% when pulling 49b41a4 on JarbasAI:patch-21 into eb63402 on MycroftAI:dev.

@JarbasAI
Copy link
Contributor Author

JarbasAI commented Sep 8, 2017

changes made

@pep8speaks
Copy link

Hello @JarbasAI! Thanks for updating the PR.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CLA: Yes Contributor License Agreement exists (see https://github.com/MycroftAI/contributors)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants