Setup VOLTTRON for development
Prerequisites
- This document assumes you already have
A Linux environment - This can be a Linux machine, a virtual machine or a docker container.
VOLTTRON Pre-requisites software - Refer: VOLTTRON Pre-requisites
Forked the volttron-* repository you are editing. See forking volttron-core for development
Running VOLTTRON with source code
Create a new directory, say volttron_instance1
Create a new virtual environment in that directory and activate it
Install volttron-core, volttron-lib-auth and volttron-lib-zmq.
You can point to your clone fork directory for the library you are editing and use pypi packages for rest. You can do this using pip or poetry
Using pip
pip install -e <path to cloned volttron-core dir>orpip install volttron-core
pip install -e <path to cloned volttron-lib-auth dir>orpip install volttron-lib-auth
pip install -e <path to cloned volttron-lib-zmq dir>orpip install volttron-lib-zmqor
Using poetry and volttron-zmq wrapper
Clone the volttron-zmq library that is a wrapper that is dependent on volttron-core, volttron-lib-auth, and volttron-lib-zmq
Update pyproject.toml file of volttron-zmq to point to cloned source directory of volttron-core, and/or volttron-lib-auth, and/or volttron-lib-zmq and mark these source package as editable so that you don’t have to rebuild the wheel
run
poetry installIf you updating one of volttron agents or volttron-lib-* packages, you can simply install volttron using
pip intall volttronOptional: export VOLTTRON_HOME=/path/to/volttron-home` Defaults to $HOME/.volttron. Note: VOLTTRON>= 10 cannot work with volttron home directory used for previous versions of VOLTTRON
Start volttron
volttron -l volttron.log &This creates a new poetry project in $VOLTTRON_HOME and use that.You can check the status by running the command
vctl statusTo install agents use
vctl install <agent package name in pypi>orvctl install <path to forked agent source dir>To install any optional libraries use the
vctl install-libcommand. Example:vctl install-lib volttron-lib-bacnet-driverorvctl install-lib <path to forked library directory>Using
vctl installandvctl install-libensures that versions of python packages used by VOLTTRON are all compatible with each other. Usingpip install <library>might work if there is no dependency version mismatch but pip doesn’t do dependency management as well as poetry.
Note:
To debug your source code during development, you could run/debug volttron and vctl commands from within an IDE. Refer: PyCharm development environment
After executing the above commands your environment is setup for starting volttron. The next step is to begin developing an agent(see agent development, or continue on with setting up pycharm for use with this environment(see Pycharm development environment)
Note: To exit the poetry shell use the exit command. this deactivates the environment and exits the spawned shell.