You can use any development environment you want to develop Reggie.
PyCharm is a popular IDE for a variety of reasons including: ease of use for running unit tests, code completion, debugging, etc...
Before starting here, make sure you've followed the setup instructions from the README.
- Configure your remote interpreter for Vagrant by going to Preferences
- Under Project->Project Interpreter add a Remote Interpreter
- Select Vagrant and put your python path as
/home/vagrant/reggie-formula/reggie_install/env/bin/python
- Edit your configurations
- Add a python interpreter, and name it sideboard if you'd like
- Set the script to one located at
reggie_install/sideboard/run_server.py
- Select your python interpreter as Python 3.6.5
- Set your working directory as
reggie_install/sideboard
- You should be able to run Reggie from Pycharm now! Good luck!
Make sure the virtual machine is running (use 'vagrant up' to bring it up). Make sure you are running a recent version of PyCharm Professional 2016.2 or higher (not community edition).
-
Open Pycharm Note: You are going to see some warning messages about 'can't find git version control roots' for a couple of projects, that's OK just ignore those. Also dismiss anything about docker.
-
File->Open and select the folder 'reggie-formula' (or whatever you named it)
-
File->Settings and under Project:rams, click Project Interpreter
-
next to Project Interpreter, click the gear icon:
-
Click 'Add Remote'
-
Click the 'Vagrant' checkbox
-
Under 'vagrant instance folder', select your project folder:
-
The 'vagrant host URL field' should now switch automatically to
ssh://[email protected]:2222
-
For 'python interpreter path', either paste or browse to:
/home/vagrant/reggie-formula/reggie_install/env/bin/python
-
Hit OK and exit the system settings. You may see some activity and messages of PyCharm working, this is normal and may take a minute or two to process.
Anytime you restart vagrant, you will need to stop Reggie from running in the background.
- In PyCharm, click Tools -> External Tools -> systemctl
This will stop Reggie from running as a daemon and allow you to take control of it from PyCharm.
- In the upper right hand corner, click the dropdown that has the PyCharm configurations and select 'sideboard':
- Click the 'Debug' icon (it looks like a green bug)
You are now running ubersystem inside pycharm! You can set breakpoints and view the debug output.
This is basically the same procedure as debugging.
- Select a unit test configuration:
- Click the 'Debug' icon to run the unit tests. You can set breakpoints inside the unit tests as well!
All repositories (reggie-formula, infrastructure, sideboard, and all plugins) show up at the same time and you can do most git operations from within pycharm. Click the 'version control' button at the bottom of the screen to explore. PyCharm is incredibly adept at dealing with having a complex setup of working on multiple repositories at the same time.
To update all of your projects from github:
- Click the bottom right source control dialog:
-
Make sure everything is set to either 'master' or a branch that exists in github.
-
Click the 'Update Project' button in the upper right to pull changes from github:
If there are config changes introduced from github (this happens from time to time), or if you want to make sure you have the very latest, then follow this procedure to re-deploy. You'll need a decently fast Internet connection as this process will pull down stuff from github.
At some future point, we're going to make this process a bit more automated.
-
Open a command prompt or terminal and change directory to reggie-formula.
-
Run the
vagrant up
command if the vagrant machine isn't already running. -
Run
vagrant ssh
to ssh into the machine. -
Type
sudo salt reggie state.apply
. (This may take awhile.) This will bring your deploy up to date with the latest code, apply all configuration (YAML/INI) changes, install any new plugins that were added, and a bunch of other stuff. It should end with a pristine copy of everything deployed and ready to rock.a. If the command times out, make a note of the job id (JID). You can check for results with the following command:
sudo salt-run --out highstate jobs.lookup_jid JID
-
If you are planning on running the Reggie server from inside PyCharm (so you can debug it, for instance) then you'll need to turn off the server which the deploy auto-starts by typing
sudo systemctl stop reggie-web
from inside vagrant. If not, skip this step.
Deploy is now finished! You can close the command prompt.
-
If you were working on local changes, switch back to those branches, or unstash your changes.
-
Click the 'debug' or 'run' icon in PyCharm and you should be up and running again.
You can also do some other stuff we will document later like running with code coverage + unit tests to show you which lines of code are and aren't being hit.
If you see 'Private key file not found' when setting up, please upgrade your PyCharm, there was a bug in older versions.
If things are in general starting to get weird, check that you have definitely clicked on the 'reggie-formula' directory when you opened the project. If you open any other directory THINGS WILL START GETTING WEIRD.