GW Landscape Compas module for running Compas jobs from the web.
There are two "projects" contained in this repository - one for the Django project (backend), and one for the React project (frontend).
The frontend is in gwlandscape_compas/src/react/ and the backend is in gwlandscape_compas/src/
- Python 3.12+ with the virtualenv module installed
- Node Version Manager (NVM) installed
- In some instances
npm run relaymay raise an error that requires thewatchmanpackage to be installed. - COMPAS (refer to the docs to install it)
- Redis server (refer to the docs)
Set up the virtual environments for GW Landscape (don't forget you'll need to create a ):
cd gwlandscape_compas/src/
virtualenv -p python3.12 venv # or whatever version of python you have installed > 3.12
source venv/bin/activate
pip install -r requirements.txt
cd $COMPAS_ROOT_DIR
pip install . # install compas_python_utils, needed for plots
cd gwlandscape_compas/src
python development-manage.py migrateIf you want to use actual data, you will need to install and configure mysql as well. This is due to the production server using mysql and therefore difficulties in importing a mysql data dump into sqlite
- Install mysql-client and mysql-server for your distro
sudo apt-get install mysql-client mysql-server- Install the mysqlclient python package (note - you may need to install additional system packages for this to work)
- Create schema in mysql :
gwlandscape_compas - Create mysql user and grant it all privileges on that schema
- Generate a data dump from production (this is left as an exercise to the reader i.e., get someone with production access to do it for you)
- Import the data dump with
mysql -u <username> -p gwlandscape_compas < <production_dump.sql>- Add a local settings file at
src/gw_compas/local.pyand add aDATABASES=section defining the mysql connection (seeenvironemnt.pyin that directory for an example) - Migrate the database
# Inside the venv
python development-manage.py migrateIn order to fetch results or file lists you will need to have access to the production job controller. To do this, add a JOB_CONTROLLER_JWT_SECRET= field to the local.py settings file. This JWT_SECRET can be generated by Lewis
Set up the node environments:
cd gwlandscape_compas/src/react/
nvm install $(cat .nvmrc)
nvm use $(cat .nvmrc)
npm install
cp .env.template .envYou will need to run in four separate terminals - one for the django host, one for the react dev-server, one for redis and one for celery.
cd gwlandscape_compas/src
. venv/bin/activate
python development-manage.py runserver 8000cd gwlandscape_compas/src/react
npm use
npm run devIn many cases, redis will be running as a service, so this will not be required
redis-servercd gwlandscape_compas/src/
celery -A gw_compas.celery worker -l INFOAny time changes are made to the graphene schema in python, you need to rebuild the GraphQL schema for javascript
This also needs to be executed once before running the project for the first time
cd gwlandscape_compas/src/
. venv/bin/activate
python development-manage.py graphql_schemaAny time changes are made to the javascript GraphQL queries, you need to rebuild the GraphQL query files. This is not automatic, and may require stopping the node server, generating the GraphQL files, then starting the node server again.
This also needs to be executed once before running the project for the first time
cd gwlandscape_compas/src/react
nvm use
npm run relayOnce the project is running, you should be able to visit http://localhost:3000/ to open the project in a browser.
The docker configuration in the docker directory can be used to build and run the project in production.
The production build uses .env and .env.production files to determine runtime configuration and secrets, rather than src/gw_compas/local.py. The src/react/.env template will also have to be updated when building for production.
cd gwlandscape_compas/docker
sudo docker-compose up --build -d