Guide: Local development workflow

When doing development with the autopi, it is possible to do it all through the cloud.

  1. Make changes
  2. Push changes to device
  3. Restart services
  4. Execute module
  5. Go to 1.

But while this process can be used, it is much too slow to be used for actual development.
So the cloud should be used for management, and to push out code when the development has finished, and not in the actual development workflow.

Fortunately there is other much faster alternatives, here is a few ways to do it.

1. Development on RPI with screen+keyboard or SSH

You could instead SSH into the device and edit the files directly.
When syncing from the cloud, the modules will be put in the following directories, based on the type.

  • /opt/autopi/modules
  • /opt/autopi/returners
  • /opt/autopi/utils
  • /opt/autopi/engines
  • /opt/autopi/states

So you can simply edit/create the files directly, but make sure to avoid clashes with the cloud synced modules, to prevent losing work if you sync the module from the cloud, as that will, without asking, overwrite the file on the device, even if you have made local changes to it.

When you make changes to the files, to make sure that the minion process picks up on the change, you can either restart the salt-minion service, or run this command saltutil.refresh_modules which reloads the external modules, ie. your code.

2. Remote development on dev machine

Alternatively, another workflow can be to have a script on your development machine that copies the files to the device via SCP, that way you can make the changes in your favorite editor. (Remember to have the script also either restart the minion service or run the refresh_modules command as noted above).
Doing development on the local machine is preferable for many, and is also the way we do development as it has the benefit of the above solution, but also allows the user to be as productive as possible by in his/her preferred dev environment.

We hope this helps you get started developing with our device and platform.

Remember that we also offer additional more in-depth paid support to get you started with your project.

1 Like

What do these directories contain?

  • /opt/autopi/modules
  • /opt/autopi/returners
  • /opt/autopi/utils
  • /opt/autopi/engines
  • /opt/autopi/states

which one contains services? utility is understandable? what is in modules? Returners is under stable. Where are jobs? Execution?

I’m having trouble getting the AutoPi to pick up my change. I am SSH’d into my AutoPi and I can see my updated code in /opt/autopi/salt/modules and if I run this

$ autopi saltutil.refresh_modules

It still does not run my updated code. The only way I’ve gotten it to recognize the updated code is by rebooting the AutoPi, is there an easier way to refresh locally-changed modules?

Can anyone advise on the fastest way to reload custom modules? I can restart the salt-minion service with

sudo systemctl restart salt-minion

But this still takes several minutes for the service to restart and be ready again. It also re-syncs the code from the cloud after restarting. I’m hoping for a quick “re-import custom code that’s on the device” command that I can run.