mikejgray / neon-homeassistant-skill

A Neon AI Skill for Home Assistant, which integrates with ovos-PHAL-plugin-homeassistant.
Apache License 2.0
7 stars 4 forks source link

[BUG] Skill __init__ failed with 'NoneType' object is not callable #16

Closed fermulator closed 1 year ago

fermulator commented 1 year ago

Description

Fresh vanilla setup of latest Neon OS on Mycroft's Mark II.

Followed: https://github.com/mikejgray/neon-homeassistant-skill#installation-on-neon

On load, skill fails with:

Apr 02 17:02:43 neon neon-skills.py[629]: 2023-04-02 17:02:43.670 - skills - mycroft.skills.skill_loader:load:399 - INFO - ATTEMPTING TO LOAD SKILL: neon-homeassistant-skill.mikejgray
Apr 02 17:02:43 neon neon-skills.py[629]: 2023-04-02 17:02:43.677 - skills - mycroft.skills.skill_loader:_load_skill_source:506 - ERROR - Failed to load neon-homeassistant-skill.mikejgray due to a missing file.
Apr 02 17:02:43 neon neon-skills.py[629]: 2023-04-02 17:02:43.682 - skills - mycroft.skills.skill_loader:_create_skill_instance:541 - ERROR - Skill __init__ failed with 'NoneType' object is not callable
Apr 02 17:02:43 neon neon-skills.py[629]: Traceback (most recent call last):
Apr 02 17:02:43 neon neon-skills.py[629]:   File "/home/neon/venv/lib/python3.7/site-packages/mycroft/skills/skill_loader.py", line 529, in _create_skill_instance
Apr 02 17:02:43 neon neon-skills.py[629]:     self.instance = skill_creator()
Apr 02 17:02:43 neon neon-skills.py[629]: TypeError: 'NoneType' object is not callable
Apr 02 17:02:43 neon neon-skills.py[629]: 2023-04-02 17:02:43.689 - skills - mycroft.skills.skill_loader:_communicate_load_status:560 - ERROR - Skill neon-homeassistant-skill.mikejgray failed to load

Steps to Reproduce

  1. mycroft mark ii, neon OS (downloaded latest as of April 2nd 2023)
  2. install per README instructions i. pip install git+https://github.com/OpenVoiceOS/ovos-PHAL-plugin-homeassistant ii. edit config as appropriate for hass host & key iii. osm install https://github.com/mikejgray/neon-homeassistant-skill
  3. check logs (journalctl)

Relevant Code

TBD

Other Notes

No response

mikejgray commented 1 year ago

Not sure why this isn't working, since that's how I set it up on my previous dev environment, but I'm setting up a new dev environment right now. I'll try to reproduce and correct as needed. Thanks for the callout.

fermulator commented 1 year ago

Let me know if you'd like any assistance.

mikejgray commented 1 year ago

Good news - I was able to replicate the bug. Bad news - I haven't fixed it yet. One step at a time...

2023-04-07 21:54:42.101 - skills - mycroft.skills.skill_loader:load:399 - INFO - ATTEMPTING TO LOAD SKILL: neon-homeassistant-skill.mikejgray
2023-04-07 21:54:42.109 - skills - mycroft.skills.skill_loader:_load_skill_source:506 - ERROR - Failed to load neon-homeassistant-skill.mikejgray due to a missing file.
2023-04-07 21:54:42.114 - skills - mycroft.skills.skill_loader:_create_skill_instance:541 - ERROR - Skill __init__ failed with 'NoneType' object is not callable
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/mycroft/skills/skill_loader.py", line 529, in _create_skill_instance
    self.instance = skill_creator()
TypeError: 'NoneType' object is not callable
2023-04-07 21:54:42.122 - skills - mycroft.skills.skill_loader:_communicate_load_status:560 - ERROR - Skill neon-homeassistant-skill.mikejgray failed to load
mikejgray commented 1 year ago

Digging into that skill, what we have here is: https://github.com/OpenVoiceOS/ovos-core/blob/dev/mycroft/skills/skill_loader.py#L457

    def _load_skill_source(self):
        """Use Python's import library to load a skill's source code."""
        main_file_path = os.path.join(self.skill_directory, SKILL_MAIN_MODULE)
        skill_module = None
        if not os.path.exists(main_file_path):
            LOG.error(f'Failed to load {self.skill_id} due to a missing file.')
        else:
            try:
                skill_module = load_skill_module(main_file_path, self.skill_id)
            except Exception as e:
                LOG.exception(f'Failed to load skill: {self.skill_id} ({e})')
        return skill_module

SKILL_MAIN_MODULE is hardcoded as __init__.py, which I believe is a legacy of the old Mycroft skill format that assumes that you have skill files all in the root of the repository. Since this does not follow that format and instead follows a standard Python module format (all skill code is in ./neon_homeassistant_skill), we're never able to install the skill from git. We have to do it from pip.

I'll open an issue on the ovos-core and neon-core repositories to see about adding any supported Python module format instead of searching for __init__.py in the root of the repository. In the meantime, I will update the README with instructions on installing from pip.

Thanks for the callout, @fermulator ! When I have new instructions I'll ping you to test.

mikejgray commented 1 year ago

@NeonDaniel FYI

fermulator commented 1 year ago

@mikejgray

thanks!

so - based on the updates to readme doc

should i revert the manual install attempt and install a different way? (the notes say Neon comes preinstalled now…)?

mikejgray commented 1 year ago

@mikejgray

thanks!

so - based on the updates to readme doc

should i revert the manual install attempt and install a different way? (the notes say Neon comes preinstalled now…)?

@fermulator Neon does come preinstalled with this skill and its associated PHAL plugin. If you want to try to stay on the cutting edge (I do have two PRs open now for alpha versions), you can revert your manual attempt and install with pip on those branches. Neon is pretty good about staying on top of alphas, though, and the latest stable is pretty solid.