MK2 - Hello World skill for dummies

I was disappointed with the limited skills and inability to load new skills - so I thought I would have a go at following the ‘Porting the Hello World Skill’ .

I’m coming to this without knowing anything about the pre-MK2 Mycroft so I suspect that I’m misunderstanding what I need to do to get it working. What would be really helpful would be a copy of a working hello world init.py so I can see where I’m going wrong.

I’m assuming that’s where the issue is but digging around in the files downloaded from git I can see vocab files with only a few words in them - does that mean they are the only words I can use as dialog in init.py?

I no longer have the error messages I was seeing as I have removed the hello world skill and rebooted the MK2 to reassure myself that I hadn’t permanently messed it up.

Thanks

1 Like

I tried again:
sudo systemctl restart dinkum-skills.service
Job for dinkum-skills.service failed because the service did not take the steps required by its unit configuration.
See “systemctl status dinkum-skills.service” and “journalctl -xe” for details.

and …
$ systemctl status dinkum-skills.service
● dinkum-skills.service - Mycroft service skills.service
Loaded: loaded (/etc/systemd/system/dinkum-skills.service; static; vendor preset: enabled)
Active: activating (auto-restart) (Result: protocol) since Mon 2022-12-26 13:39:29 UTC; 3s ago
Process: 2178 ExecStart=/opt/mycroft-dinkum/.venv/bin/python -m service --service-id skills --skill /opt/mycroft-dinkum/skills/alarm.mark2 --skill /opt/mycroft-dinkum/skills/date.ma>
Main PID: 2178 (code=exited, status=0/SUCCESS)

and
journalctl -xe
Dec 26 13:40:14 localhost.localdomain python[1953]: File “/opt/mycroft-dinkum/services/messagebus/service/event_handler.py”, line 52, in on_message
Dec 26 13:40:14 localhost.localdomain python[1953]: client.write_message(message)
Dec 26 13:40:14 localhost.localdomain python[1953]: File “/opt/mycroft-dinkum/.venv/lib/python3.8/site-packages/tornado/websocket.py”, line 337, in write_message
Dec 26 13:40:14 localhost.localdomain python[1953]: raise WebSocketClosedError()
Dec 26 13:40:14 localhost.localdomain python[1953]: tornado.websocket.WebSocketClosedError
Dec 26 13:40:14 localhost.localdomain python[1953]: Traceback (most recent call last):
Dec 26 13:40:14 localhost.localdomain python[1953]: File “/opt/mycroft-dinkum/services/messagebus/service/event_handler.py”, line 52, in on_message
Dec 26 13:40:14 localhost.localdomain python[1953]: client.write_message(message)
Dec 26 13:40:14 localhost.localdomain python[1953]: File “/opt/mycroft-dinkum/.venv/lib/python3.8/site-packages/tornado/websocket.py”, line 337, in write_message
Dec 26 13:40:14 localhost.localdomain python[1953]: raise WebSocketClosedError()
Dec 26 13:40:14 localhost.localdomain python[1953]: tornado.websocket.WebSocketClosedError
Dec 26 13:40:14 localhost.localdomain python[1953]: Traceback (most recent call last):
Dec 26 13:40:14 localhost.localdomain python[1953]: File “/opt/mycroft-dinkum/services/messagebus/service/event_handler.py”, line 52, in on_message
Dec 26 13:40:14 localhost.localdomain python[1953]: client.write_message(message)
Dec 26 13:40:14 localhost.localdomain python[1953]: File “/opt/mycroft-dinkum/.venv/lib/python3.8/site-packages/tornado/websocket.py”, line 337, in write_message
Dec 26 13:40:14 localhost.localdomain python[1953]: raise WebSocketClosedError()
Dec 26 13:40:14 localhost.localdomain python[1953]: tornado.websocket.WebSocketClosedError
Dec 26 13:40:14 localhost.localdomain python[1953]: Traceback (most recent call last):
Dec 26 13:40:14 localhost.localdomain python[1953]: File “/opt/mycroft-dinkum/services/messagebus/service/event_handler.py”, line 52, in on_message
Dec 26 13:40:14 localhost.localdomain python[1953]: client.write_message(message)
Dec 26 13:40:14 localhost.localdomain python[1953]: File “/opt/mycroft-dinkum/.venv/lib/python3.8/site-packages/tornado/websocket.py”, line 337, in write_message
Dec 26 13:40:14 localhost.localdomain python[1953]: raise WebSocketClosedError()
Dec 26 13:40:14 localhost.localdomain python[1953]: tornado.websocket.WebSocketClosedError
Dec 26 13:40:14 localhost.localdomain python[1953]: Traceback (most recent call last):
Dec 26 13:40:14 localhost.localdomain python[1953]: File “/opt/mycroft-dinkum/services/messagebus/service/event_handler.py”, line 52, in on_message
Dec 26 13:40:14 localhost.localdomain python[1953]: client.write_message(message)
Dec 26 13:40:14 localhost.localdomain python[1953]: File “/opt/mycroft-dinkum/.venv/lib/python3.8/site-packages/tornado/websocket.py”, line 337, in write_message
Dec 26 13:40:14 localhost.localdomain python[1953]: raise WebSocketClosedError()
Dec 26 13:40:14 localhost.localdomain python[1953]: tornado.websocket.WebSocketClosedError
Dec 26 13:40:14 localhost.localdomain python[1953]: Traceback (most recent call last):
Dec 26 13:40:14 localhost.localdomain python[1953]: File “/opt/mycroft-dinkum/services/messagebus/service/event_handler.py”, line 52, in on_message
Dec 26 13:40:14 localhost.localdomain python[1953]: client.write_message(message)
Dec 26 13:40:14 localhost.localdomain python[1953]: File “/opt/mycroft-dinkum/.venv/lib/python3.8/site-packages/tornado/websocket.py”, line 337, in write_message
Dec 26 13:40:14 localhost.localdomain python[1953]: raise WebSocketClosedError()
Dec 26 13:40:14 localhost.localdomain python[1953]: tornado.websocket.WebSocketClosedError
Dec 26 13:40:14 localhost.localdomain python[1953]: Traceback (most recent call last):
Dec 26 13:40:15 localhost.localdomain python[1953]: ERROR:asyncio:Task exception was never retrieved
Dec 26 13:40:15 localhost.localdomain python[1953]: future: <Task finished name=‘Task-79084’ coro=<WebSocketProtocol13.write_message..wrapper() done, defined at /opt/mycroft-din>
Dec 26 13:40:15 localhost.localdomain python[1953]: Traceback (most recent call last):
Dec 26 13:40:15 localhost.localdomain python[1953]: File “/opt/mycroft-dinkum/.venv/lib/python3.8/site-packages/tornado/websocket.py”, line 1102, in wrapper
Dec 26 13:40:15 localhost.localdomain python[1953]: await fut
Dec 26 13:40:15 localhost.localdomain python[1953]: tornado.iostream.StreamClosedError: Stream is closed
Dec 26 13:40:15 localhost.localdomain python[1953]: During handling of the above exception, another exception occurred:
Dec 26 13:40:15 localhost.localdomain python[1953]: Traceback (most recent call last):
Dec 26 13:40:15 localhost.localdomain python[1953]: File “/opt/mycroft-dinkum/.venv/lib/python3.8/site-packages/tornado/websocket.py”, line 1104, in wrapper
Dec 26 13:40:15 localhost.localdomain python[1953]: raise WebSocketClosedError()
Dec 26 13:40:15 localhost.localdomain python[1953]: tornado.websocket.WebSocketClosedError
Dec 26 13:40:16 localhost.localdomain python[1958]: INFO:mycroft.util.log:Training… (single_thread=True)

1 Like

I ran into the same thing. I didn’t mess with Mycroft prior to receiving the MK2. I attempted to port a skill and ran into the same issue. I opened a bug in the repo. No updates yet but figured I’d leave it here in case it does get updated.

Error when Porting Classic Skill to Mycroft 2 · Issue #49 · MycroftAI/mycroft-dinkum · GitHub

2 Likes

Finally got it working by reading up on Mycroft before MK2 https://mycroft-ai.gitbook.io/docs/skill-development/skill-structure … and the point I missed was that the last bit of the code in init.py is outside the class definition, that is it needs no indentation for the first line of …

def create_skill():
return HelloWorldSkill()

That was painful, my vi editing skills are very rusty … although I have learned a lot :slight_smile:

1 Like

Thanks for the update. That is super painful. I think my longer term plan is to setup Mycroft as a remote server and push code changes from PyCharm.

Went back through and checked mine. My create_skill function wasn’t inside of the class. I wonder where I’ve gone wrong.

Did you see any clues in the logs? Mycroft II Docs > Troubleshooting lists a few logs, the one I found most useful was this command:

journalctl -u dinkum-skills.service -f

1 Like

That one is useful. Thanks!

It looks like it’s just indentation errors and cleaning things up. Python in the cli without linters is not great to develop against.

Definitely going to spend some time setting this up as a remote python server to develop against.

If you have the debug console (mycroft-start debug) going, any time you save changes to your code, Mycroft will detect them and reload the code. If you have syntax errors, they will show up immediately. I keep my IDE and the debug env’t side by side. It’s a pretty cool model they’ve come up with :sunglasses:

-Mike Mac

I did not know that. Is there a good page for setting up the development environment? I saw an issue in the dinkum repo where people are asking for that?

1 Like

Also, I’ve started a repo for skills I’ve converted. If anyone wants to PR into to spread the labor out, I’ll test the PR against mine and merge it in.

Is there a way to test the skills code before adding it to the MK2 ?

I made a lot of mistakes on the hello world skill that were python syntax or formatting errors or my misunderstanding of the changes it needed.

I think that’s going to fall under getting a dev environment setup. There’s an issue open. I was going to try and take some time next weekend and see if I could get a container running and using my laptop’s speakers/microphone for testing. If I get anywhere, I’ll share it.

My shorter term plan is swapping the USBs and having a dev and prod version of the OS on each USB.

“hey Mycroft, how are you?”
“could be better”

… made me smile this morning … :wink: