Just some notes on how I have been debugging dispatcher changes. Hopefully can iron out the less nice bits.

Set Up

Code + Env

  1. Create a virtual environment
  2. Check out the dispatcher
  3. run python setup.py install (in the dispatcher directory)
  4. You need a working LAVA install for the dispatcher to interact with. I have mine on another machine and just mount /srv over sshfs to get at the config: sshfs -o idmap=user -o uid=1001 -o gid=1001 $USER@lava-server:/srv /srv
  5. You need some dispatcher config. Put device config files in ~/.config/lava-dispatcher:

    /home/dooferlad/.config/lava-dispatcher/lava-dispatcher.conf
    /home/dooferlad/.config/lava-dispatcher/devices
    /home/dooferlad/.config/lava-dispatcher/devices/panda01.conf
    /home/dooferlad/.config/lava-dispatcher/devices/panda.conf 
  6. Set up your project interpreter (File -> Settings, Project Interpreter, Python Interpreters, + (green, right hand side), point it to python in your virtual environment.

Project

Open your dispatcher directory in PyCharm (this sets up a new project). Hack...

Running Code

  • Create a new run configuration (Run --> Edit Configurations)

  • Hit the green + (top left)
  • Pick Python
  • Fill in:
    • Script: <path to your virtual environment>/bin/lava

    • Script Parameters: dispatch <rest of parameters to lava-dispatch>

  • Set up an external tool to run before the job:
    • Bottom of the dialogue box there is "Before launch: External tool", hit the green + below that.
      • Run External Tool
      • +
      • Path to a script containing (something like)

        source /etc/bash_completion.d/virtualenvwrapper
        export WORKON_HOME=~/Envs
        workon bootloader-device
        python setup.py install

You can now run this new config. It will install your code changes into the virtual environment and run them.

Debugging

The nasty part is that to get a breakpoint hit you need to set the breakpoint in the installed code, which isn't the code in your project, it is the code in the virtualenv that you set up. It is very easy to accidentally edit that code only to have the install script write over it with the old version. Be careful. Other than that, debugging works.

TODO

If you could run without the virtualenv then you could do away with the install step and not have to edit one file, debug in another copy of it. Haven't dug into this, but it should be possible. It looks like the code is basically copied from your checkout into the virtualenv, so you could replace that copy with a soft-link to the code you are editing. If Python/PyCharm works out that it is the same file is another matter.

Better would be to get your dispatcher checkout on the PYTHONPATH such that it is imported, not the copy in the virtualenv (which you could delete). You could then just run lava dispatch...

Platform/LAVA/PyCharmHacking (last modified 2013-07-31 18:09:21)