Mycroft Community Forum

Remote Debug skill

Remote Debug

Enable PTVSD - Python Tools for Visual Studio debug server

This skill adds PTVSD - Python Tools for Visual Studio debug server to make it posible to
debug running skills.
It is made as a companion to the THEIA IDE skill to enable debugging from there. But if you use another IDE like VS Code you can use this skill to inject the debug adaptor in the
mycroft.skills service and attach to it on port 5678.

When you activate debugging by saying “Run debug adaptor” the skill will change Settings for padatious single_thread = true so skills service runs in single thread.

THEIA IDE (latest version) should already be setup so you just have to start debug from debug menu after starting remote debug adaptor.

When finish debugging say “End debug adaptor” and skill restore single_thread settings and the skill will restart mycroft.skills service

https://github.com/Microsoft/ptvsd

This skills requeue using the dev branch !

launch.json

To use the debug adaptor from THEIA IDE or VS Code make sure you use Python
remote attach setting in launch.json

    {
        "name": "Python: Remote Attach",
        "type": "python",
        "request": "attach",
        "port": 5678,
        "host": "localhost",
    }

Examples

  • Start (remote|ptvsd|) debug adaptor
  • Enable (remote|ptvsd|) debug adaptor
  • Run (remote|ptvsd|) debug adaptor
  • Stop (remote|ptvsd|) debug adaptor
  • Exit (remote|ptvsd|) debug adaptor
  • End (remote|ptvsd|) debug adaptor

How to install Remote debug skill

use mycroft-msm to install the skill

mycroft-msm install https://github.com/andlo/remote-debug-skill.git

How to test Remote debug skill

  • Start remote debug adaptor by saying “hey mycroft - run remote debug adaptor”
  • in VS THEIA IDE or VS code (or maybe other IDE` start debug and atatch to remote
  • edit the init.py in the mycroft-hello-world.mycrofta skill
  • set breakpoint in line 46 `` self.speak_dialog(“how.are.you”)````
  • say “hey mycroft - thanks” and see that code is paused and debuger is active
  • step throu the code or stop debuging
  • say “hey mycroft - end remote debug adaptor”

If it works as expected th debugger stops and and you can go throu code step by step and see values in variables etc. you can step in and out of functions

When debug adaptor is running you can se that ptvsd is running

andlo@DESKTOP-D9EUQU6:/opt/mycroft/skills/mycroft-hello-world.mycroftai$ ps ax |grep " -m mycroft.skills"
17025 ?        Sl     5:36 python3 -m ptvsd --host 0.0.0.0 --port 5678 -m mycroft.skills
20565 pts/0    S      0:00 grep --color=auto  -m mycroft.skills

when debugger isnt running you see

andlo@DESKTOP-D9EUQU6:/opt/mycroft/skills/mycroft-hello-world.mycroftai$ ps ax |grep " -m mycroft.skills"
20696 ?        Rl     0:01 python3 -m mycroft.skills
20782 pts/0    S      0:00 grep --color=auto  -m mycroft.skills

Feedback on this Skill and debugging with PTVSD can be done through Issues on the skills GitHub page or here in the forum or via Mycroft Chat.

3 Likes

To use Remote debug from VS code I use plugin " Remote - SSH" ms-vscode-remote.remote-ssh and “Remote - SSH: Editing Configuration Files” ms-vscode-remote.remote-ssh-edit and ssh to picroft and go to folder /opt/mycroft/skills

To use Vscode and working on mycroft running in a WSL I use plugin “Remote - WSL” ms-vscode-remote.remote-wsl and go to folder /opt/mycroft/skills

both when conecting to picroft and WSL I also added the plugin “Python”
ms-python.python.

On WSL I had to add the venv location information in the python settings

To use it from THEIA IDE just install the latest THEIA IDE skill and it should be all setup to debug in skills folder and having right plugins installed.

To use from PyCharm I cant figure out how - PyCharm is for me a bit confusing. But as far as I can read PyCharm should be able to do the same as VS code and THEIA and connect to a remote system and debug adaptor running there.