How to deploy during development?

I need a better way to deploy my plugin when developing it. Right now I edit on a Win 10 PC with Visual Studio code and commit to GitHub when I want to test. Then in OctoPrint I Uninstall my Plugin, Restart, Add Plugin from URL and Restart again. Then can I test my changes.

Because almost all my code is JavaScript I would like to be able to just push the changes to the Pi and have them take effect without a restart. Ideally I could just refresh the browser. Is there any way to do that?

By far the easiest way would be to install directly to the virtual environment in editable mode.
For this, I'll assume you have OctoPrint installed on Windows 10, if not i'll add bits about remote deployment at the end.

  1. Activate the OctoPrint virtual environment: ./venv/Scripts/activate
  2. Make sure you are in your plugin's git repository (through cd or something) and run:
    octoprint dev plugin:install
  3. develop!

You can also substitute octoprint dev plugin:install (if you don't have an octoprint dev env set up) with pip install -e .

Deploying on a remote install (i.e. OctoPi)

If you are used to using VS Code, then you can use their remote - SSH to code directly on the Pi - clone the plugin, then install in the same way as above.

In theory, you can edit the JS files and then refresh, but OctoPrint does caching that means that the changes may not make it in. I believe there is a way of disabling this, but if you are running from VS Code itself, then you can just hit restart on the debugging process.


To be honest, I'm incredibly impressed you've managed to get such a great plugin, by manually installing for each change! :clap: :clap: Any other questions and I'll answer as best as I can!

1 Like

Or why not just install a local octoprint dev environment and run everything locally? You can install your plugins that way in editable mode from the virtualenv and make changes direct to the js files. When you want to test you just force a refresh in your browser.

Edit: That's basically what you said

1 Like

I think I had a shell script setup to copy files semi automatically when I did the bulk of the coding last year. I lost it when I updated my PI.

I wound up using the SSH tools in Visual Code to connect to the PI and now can edit the JS files in place. Refreshing the page does update with changes (yay) so that is all I needed. Thanks for the answers guys!

:+1: Great to know you got it sorted.
If you wanted to, you could also use something like one of the JetBrains products - they have remote deployment a little differently to VS Code, in that you edit the code on a PC, then when you press run it copies across & connects a debugger etc. Personally I found it worked better that way than VSCode, since my SSH connection through that was quite unstable. They provide a free open source license too, to support projects like this.