The ISB-CGC Web Application provides a GUI for browsing, curating, and analyzing TCGA, TARGET, and CCLE data. It is built in Django 1.11 (Python 3) with MySQL 5.7, and is deployed on Google AppEngine Flex.
The system uses Vagrant to setup a consistent, platform independent development environment. To setup your development environment to run locally, you will need to install the following:
- Vagrant
- Oracle VirtualBox
If you are on Windows 8 or above, you will need to make sure you have version 5.0.9 or above to support the network interface. This may involve downloading a test build - PyCharm Pro (Recommended)
From there perform the following steps...
- Once you've installed PyCharm and cloned the repositories (this repository and ISB-CGC-Common, create a directory within the
PycharmProjects
directory (the parent directory of your repositories) calledsecure_files/
. - Copy the
sample.env
file to a file named.env
insecure_files/
- Fill out the
.env
file with the proper values
- For most development environments,
MYSQL_ROOT_PASSWORD
andDATABASE_PASSWORD
can be the same, andDATABASE_USER
can beroot
GCLOUD_PROJECT_ID
,GOOGLE_CLIENT_ID
andGOOGLE_CLIENT_SECRET
will be obtained from one of the other developers, as part of the initial set of information in your.env
file.
PyCharm Pro can be used to run your server through Vagrant and the Google App Engine.
- Go to your PyCharm Settings (On Mac, Go to Preferences;
CMD+,
) - Select Project: ISB-CGC-Webapp > Project Interpreter
- Click the icon next to the Project Interpreter drop down at the top of the main area
- Click Add Remote
- Select Vagrant (if it asks to start the machine, say yes)
- Set the Python interpreter path to
/home/vagrant/www/shell/python-su.sh
and click Ok - Go to Run > Edit Configurations
- If there is not a Django Configuration, add one
- Set the host to
0.0.0.0
and the port to8080
. - Set the Python Interpreter to the Vagrant Machine (if it is not set to that already); do NOT use any local interpreters installed on your host computer.
- Set the working directory to
/home/vagrant/www
- Click
...
next to theEnvironment variables:
, box and add the following values:SECURE_LOCAL_PATH = ../parentDir/secure_files/
PYTHONPATH = /home/vagrant/www:/home/vagrant/www/lib:/home/vagrant/www/ISB-CGC-Common
VM_PYTHONPATH = /home/vagrant/www:/home/vagrant/www/lib:/home/vagrant/www/ISB-CGC-Common
DJANGO_SETTINGS_MODULE = isb_cgc.settings
PYTHONUNBUFFERED = 1
- Click ok to save
Note for OSX: You will need to set all the scripts in the shell/
directory to executable from your OSX terminal, using chmod +x *.sh
- Obtain the necessary set of secure_files from one of the current developers, and the values needed for the developer .env file.
To run your server in PyCharm:
- Make sure your Vagrant machine is running by going to Tools > Vagrant > Up
- If this is the first time you've built the VM, it can be time consuming.
- Our VMs are currently running Ubuntu 16 LTS, which is what the app deploys under as well.
- Once the VM has built, set the
shell/python-su.sh
script to executable in the vagrant machine's command line with the commandchmod +x /home/vagrant/www/shell/python-su.sh
- You can now click on the Run or Debug icons in the toolbar (upper-right corner of the PyCharm GUI)
- Your server will start and the PyCharm console should show all the logs and output from the system.
- If you are running in debug, you can also use breakpoints to stop the execution and examine variables and code as it runs.
NOTE: The WebApp will be accessible at http://localhost:8080, but not at 0.0.0.0 or 127.0.0.1
To add Python Libraries or Dependencies, you should add them to the requirements.txt file and they will automatically be pulled down when a new developer starts the system.
- Double-check any new libraries to make sure they don't introduce conflicts.
- Note that sometimes a library will function fine on a local build but fail on the deployment, so always test on the mvm deployment as soon as your PR has been merged into master.
- Ensure that the licensing doesn't conflict with the project's current license type.
To update your existing python dependencies because of a change, or to pull down additional libraries you need, SSH into the virtual machine and run pip3 install
. Through PyCharm, you can take the following steps:
- Click Tools > Start SSH session...
- Select the Vagrant VM Connection you set up
- Type
cd www; sudo pip3 install -r requirements.txt -t lib/ --upgrade --only-binary all
Or from the command line, you can do this by doing the following (OSX):
- Open a terminal in the project directory
- Type
vagrant ssh
to login to the virtual machine - Change directory to the
www
directory (/home/vagrant/www/
is the full path) - Run
pip3 install -r requirements.txt -t lib/ --upgrade --only-binary all