New Home-made Skill on an Ubuntu (non-RasPi) Installation

I’m new to Mycroft.

As a quick exercise to get experience writing a new skill, I followed the template
in your web space at

I replicated the patterns laid out in that documentation, building my init.py file and
the respective files needed that reside in the dialog, vocab, and test/intent folders.

So far, so good.

Then I got to this step:

Note that it’s tagged “deprecated.” So…what next?

In my case, I punted and copied my new skill’s folder hierarchy over to /opt/mycroft/skills
into a new directory.

I stopped and restarted Mycroft and confirmed Mycroft can faithfully convert my speech to
text (I can see this in the log because I’m running things using ‘start-mycroft.sh debug’.

But Mycroft is not capturing the intent of a clear phrase that should map to one of my
skill’s intents.

What do I do next?

On a side note, I notice that the skills that shipped with Mycroft (when installed from
git yesterday), the ones that appear in my /opt/mycroft/skills folder, do not seem to
have the same directory structure specified in your “creating a new skill” tutorial.
Specifically, none of these skills seem to have the test/intent subdirectory that I created
with my skill (as per the aforementioned instructions on creating a new skill).

How can I test my new skill?

Thanks1

The skills framework is depreciated in favor of building skills directly in /opt/mycroft/skills which should get automatically loaded in the moment they are placed there. You can look for errors when loading your skill by starting Mycroft CLI (GitHub install: ./start-mycroft.sh cli, Mycroft Unit: mycroft-cli-client) and searching for the name of your skill with CTRL+F and then typing part of the name of your skill.

Let me know if this helps.
- Matthew

1 Like

Thanks Matthew for your speedy and helpful reply!

Yes, my new skill failed to load. The reason is that my init.py is importing a self-developed module.
I had placed this module–it’s just one python file–in the same directory as my skill.

At first I tried using getting the directory where my init.py resides in the /opt/mycroft/skills tree:

cwd = os.getcwd()
sys.path.append(cwd)

but that didn’t work.

Doing a sys.path.append(explicit-directory-name) did, however work. Not ideal, of course.

My skill is now up and running but seems to still have some problems. I think I may have gone
overboard with the number of phrases in my vocab files. All up, I have 14 test case JSON files
sitting in my test/intent directory.

Thanks again and all the best…

Jay

1 Like

Congratulations on that big step, Jay.
I have the same question: if you have some kind of custom module that is unlikely to make it into the hallowed halls of the Python Package Index (thus pip and requirements.txt won’t help), what is the preferred, “best-practice” way of packaging and importing the module? Or is the PyPI admission of custom modules kind of just a basic prerequisite?

Thanks @jrwarwick. What I did for the time being was just place the module in the same directory as my skill’s init.py file and then added this directory to the python path by adding this line in my skill’s init.py file:

sys.path.append(os.path.dirname(file)).

And that worked. I’ll leave it to others better versed in how to develop for Mycroft to comment.

Jay

I had the same issue, so I searched around in the mycroft-skills github repository to see if anyone had solved it. It happens that the Spotify skill has a nice solution: use relative imports. That is, rather than write
from local_module import stuff
instead write
from .local_module import stuff
The dot before the module name indicates to Python to check the current package (i.e. the skill itself) first before looking to PYTHONPATH (i.e. the usual places) [see PEP 328 for more details].

1 Like