Skip to content

Tracker entity fails padatious compilation #104

@zeronounours

Description

@zeronounours

Describe the bug
Since PR #89 the list of trackers is saved within a temporary tracker.entity files and loaded within padatious. Padatious cannot save the generated network and fails with an exception.

When padatious is configured to be single_thread, it cause the whole skills process to fails and exit.

To Reproduce
Steps to reproduce the behavior:

  1. Configure padatious as single_thread
  2. Configure HomeAssistantSkill to an instance with trackers
  3. Start mycroft.skills
  4. See error in logs and the process being aborted

Expected behavior
Padatious should not fails to compile and save the generated neural network.

Log files

2022-04-24 15:58:18.300 | INFO     |  3366 | mycroft.skills.intent_services.padatious_service:train:151 | Training... (single_thread=True)
2022-04-24 15:58:18.343 | INFO     |  3366 | __main__:on_ready:185 | Skills service is ready.
FANN Error 2: Unable to open configuration file "/opt/mycroft/.local/share/mycroft/intent_cache/skill-homeassistant.mycroftai:{/tmp/mycroft/cache/HomeAssistantSkill/tracker}.intent.net" for writing.
malloc(): invalid size (unsorted)

Environment (please complete the following information):

  • Device type: Raspberry Pi
  • OS: Raspbian
  • Mycroft-core version: 21.2.2

Additional context

The issue comes from method _register_tracker_entities:

def _register_tracker_entities(self) -> None:
"""List tracker entities.
Add them to entity file and registry it so
Padatious react only to known entities.
Should fix conflict with Where is skill.
"""
types = ['device_tracker']
entities = self.ha_client.list_entities(types)
if entities:
cache_dir = get_cache_directory(type(self).__name__)
self.tracker_file = pth_join(cache_dir, "tracker.entity")
with open(self.tracker_file, 'w', encoding='utf8') as voc_file:
voc_file.write('\n'.join(entities))
self.register_entity_file(self.tracker_file)

This methods create a temporary file (/tmp/mycroft/cache/HomeAssistantSkill/tracker.entity) and write trackers to it. It is provided to the core method register_entity_file which is intented to managed files within the vocab or locale directories only.

When Mycroft core generate the name for padatious, it uses both the skill ID and the filename https://github.com/MycroftAI/mycroft-core/blob/dev/mycroft/skills/mycroft_skill/mycroft_skill.py#L1049

In this case, the entity name contains multiples slashes / which are not valid within filenames.

One solution to prevent this issue would be to directly write list of trackers within vocab/<lang>/tracker.entity and to load it with self.register_entity_file("tracker.entity")

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions