Going back to Python 3.8 authored by Gabriel Dengler's avatar Gabriel Dengler
## Prerequisites ## Prerequisites
A running instance of ChiefExam requires **Python3**, **Postgresql**, and **Redis**. Other databases have not been tested, so their usage is at your own risk. Furthermore, a **Python & Java runtime** are required for automatic programming task evaluation. The code execution sandbox **[isolate](https://github.com/ioi/isolate)** is required for executing this untrusted code. Due to isolate, you can only use a modern Linux distribution (tested on Debian, Ubuntu, and Manjaro) as operating system. A running instance of ChiefExam requires **Python3**, **Postgresql**, and **Redis**. Other databases have not been tested, so their usage is at your own risk. Furthermore, a **Python & Java runtime** are required for automatic programming task evaluation. The code execution sandbox **[isolate](https://github.com/ioi/isolate)** is required for executing this untrusted code. Due to isolate, you can only use a modern Linux distribution (tested on Debian, Ubuntu, and Manjaro) as operating system.
It is recommended to use **Nginx** in production to serve static content. Other webservers such as **Apache** which work as a proxy are also feasable. It is recommended to use **Nginx** in production to serve static content. Other webservers such as **Apache** which work as a proxy are also feasable.
The commands below are simply an example of how you might install these dependencies. Please consult with your operating system's package manager to determine the correct packages to install. The commands below are simply an example of how you might install these dependencies. Please consult with your operating system's package manager to determine the correct packages to install.
``` ```bash
# Add additional repositories for Redis # Add additional repositories for Redis
add-apt-repository -y ppa:chris-lea/redis-server add-apt-repository -y ppa:chris-lea/redis-server
# Update repositories list # Update repositories list
apt update apt update
# Install Dependencies # Install Dependencies
apt -y install git build-essential libssl-dev libffi-dev libcap-dev python3-pip python3-dev python3-venv redis-server postgresql postgresql-contrib openjdk-11-jdk apt -y install git build-essential libssl-dev libffi-dev libcap-dev python3-pip python3-dev python3-venv redis-server postgresql postgresql-contrib openjdk-11-jdk
``` ```
## Setting up [isolate](https://github.com/ioi/isolate) Note that the ChiefExam was solely tested on Python 3.8 with the exact packages as denoted in `requirements.txt`. Unfortunately, the APIs of many packages change regularly, so simply changing the versions can cause a lot of mess. As newer Ubuntu versions are usually shipped with newer Python versions, I recommend to install Python 3.8 using `https://launchpad.net/%7Edeadsnakes/+archive/ubuntu/ppa` (see https://askubuntu.com/questions/682869/how-do-i-install-a-different-python-version-using-apt-get):
For isolate, you can follow the instruction guides on the website. In short, you have to execute the following commands in your bash: ```bash
```bash sudo add-apt-repository ppa:deadsnakes/ppa
cd /tmp sudo apt-get update
git clone https://github.com/ioi/isolate.git sudo apt-get install python3.8
cd isolate ```
make isolate
sudo make install ## Setting up [isolate](https://github.com/ioi/isolate)
``` For isolate, you can follow the instruction guides on the website. In short, you have to execute the following commands in your bash:
The building needs a modern version `gcc`. Instead of `make isolate` you can also consider to user `make`, which also creates a documentation using `a2x` (this software has then to be installed on your operating system, too). ```bash
cd /tmp
## Setting up flask git clone https://github.com/ioi/isolate.git
After downloading the application, you need to create a Python virtual environment and install the packages needed for ChiefExam: cd isolate
```bash make isolate
git clone https://gitlab.cs.fau.de/it62ajow/chiefexam.git sudo make install
cd chiefexam ```
python3 -m venv env The building needs a modern version `gcc`. Instead of `make isolate` you can also consider to user `make`, which also creates a documentation using `a2x` (this software has then to be installed on your operating system, too).
source env/bin/activate
pip install -r requirements.txt ## Setting up flask
``` After downloading the application, you need to create a Python virtual environment and install the packages needed for ChiefExam:
```bash
Now create a `.env` file in the root directory of ChiefExam and define the following variables: git clone https://gitlab.cs.fau.de/it62ajow/chiefexam.git
``` cd chiefexam
DATABASE_URL=... python3 -m venv env
REDIS_URL=... (optional) source env/bin/activate
JAVA_HOME=... (optional) pip install -r requirements.txt
PYTHON_HOME... (optional) ```
SECRET_KEY...
[...] Now create a `.env` file in the root directory of ChiefExam and define the following variables:
``` ```
DATABASE_URL=...
An example `.env` file: REDIS_URL=... (optional)
``` JAVA_HOME=... (optional)
DATABASE_URL=postgresql+psycopg2://<user>:<password>@<host>/<database> PYTHON_HOME... (optional)
JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/ SECRET_KEY...
PYTHON_HOME=/home/<user>/chiefexam/env/ [...]
SECRET_KEY=<some strong key> ```
DEBUG=True
``` An example `.env` file:
```
- `DATABASE_URL`: Defines the url for the database DATABASE_URL=postgresql+psycopg2://<user>:<password>@<host>/<database>
JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/
## Running ChiefExam PYTHON_HOME=/home/<user>/chiefexam/env/
To start ChiefExam you will need two open bash terminals. SECRET_KEY=<some strong key>
DEBUG=True
Starting the ChiefExam server is done by using the following commands: ```
``` - `DATABASE_URL`: Defines the url for the database
cd chiefexam
source env/bin/activate ## Running ChiefExam
python server.py To start ChiefExam you will need two open bash terminals.
```
Starting the ChiefExam server is done by using the following commands:
`deactivate` can be used to leave the Python virtual environment.
```
Starting the celery service worker is achieved by using: cd chiefexam
``` source env/bin/activate
cd chiefexam python server.py
source env/bin/activate ```
celery -A app:celery worker
``` `deactivate` can be used to leave the Python virtual environment.
`--loglevel=INFO` can be added to the start of celery for debugging. Starting the celery service worker is achieved by using:
```
## Defining systemd workers cd chiefexam
source env/bin/activate
## Setting up proxy celery -A app:celery worker
```
Things will be added here.
`--loglevel=INFO` can be added to the start of celery for debugging.
## Defining systemd workers
## Setting up proxy
Things will be added here.
Environment variables: `DATABASE_URL`, `REDIS_URL`, `JAVA_HOME`, `PYTHON_HOME`, `SECRET_KEY` Environment variables: `DATABASE_URL`, `REDIS_URL`, `JAVA_HOME`, `PYTHON_HOME`, `SECRET_KEY`
\ No newline at end of file