Skip to content

Commit

Permalink
Merge pull request #52 from ooemperor/dev
Browse files Browse the repository at this point in the history
Using Python venv, updating documentation for python venv and updating service files for using journalctl
  • Loading branch information
ooemperor authored Apr 29, 2024
2 parents ca51569 + eac7b36 commit 2a44f18
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 25 deletions.
14 changes: 9 additions & 5 deletions deployment/ansible/playbooks/codeGrader_install_backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,16 @@
- libpq-dev
- pip
- git
- python3.11-venv
state: present
- name: Recursively remove directory for python venvs

- name: Recursively remove directory /opt/CodeGrader_venv
ansible.builtin.file:
path: /usr/lib/python3.11/EXTERNALLY-MANAGED
path: /opt/CodeGrader_venv
state: absent
force: true

- name: Create python venv for CodeGrader
shell: python3 -m venv /opt/CodeGrader_venv

- name: Recursively remove directory /opt/CodeGrader
ansible.builtin.file:
Expand All @@ -57,13 +60,14 @@
- name: Install CodeGrader Backend requirements
ansible.builtin.pip:
requirements: /opt/CodeGrader/codeGrader/backend/requirements.txt
virtualenv: /opt/CodeGrader_venv/

- name: Rename the setup Script
shell: mv setup_backend.py setup.py
args:
chdir: /opt/CodeGrader

- name: Install the CodeGrader Application Backend
shell: pip install .
shell: /opt/CodeGrader_venv/bin/python3.11 -m pip install .
args:
chdir: /opt/CodeGrader
14 changes: 9 additions & 5 deletions deployment/ansible/playbooks/codeGrader_install_frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,16 @@
- libpq-dev
- pip
- git
- python3.11-venv
state: present
- name: Recursively remove directory for python venvs

- name: Recursively remove directory /opt/CodeGrader_venv
ansible.builtin.file:
path: /usr/lib/python3.11/EXTERNALLY-MANAGED
path: /opt/CodeGrader_venv
state: absent
force: true

- name: Create python venv for CodeGrader
shell: python3 -m venv /opt/CodeGrader_venv

- name: Recursively remove directory /opt/CodeGrader
ansible.builtin.file:
Expand All @@ -62,13 +65,14 @@
- name: Install CodeGrader Frontend requirements
ansible.builtin.pip:
requirements: /opt/CodeGrader/codeGrader/frontend/requirements.txt
virtualenv: /opt/CodeGrader_venv/

- name: Rename the setup Script
shell: mv setup_frontend.py setup.py
args:
chdir: /opt/CodeGrader

- name: Install the CodeGrader Application Frontend
shell: pip install .
shell: /opt/CodeGrader_venv/bin/python3.11 -m pip install .
args:
chdir: /opt/CodeGrader
14 changes: 9 additions & 5 deletions deployment/ansible/playbooks/codeGrader_install_full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@
- pip
- git
state: present
- name: Recursively remove directory for python venvs

- name: Recursively remove directory /opt/CodeGrader_venv
ansible.builtin.file:
path: /usr/lib/python3.11/EXTERNALLY-MANAGED
path: /opt/CodeGrader_venv
state: absent
force: true

- name: Create python venv for CodeGrader
shell: python3 -m venv /opt/CodeGrader_venv

- name: Recursively remove directory /opt/CodeGrader
ansible.builtin.file:
Expand All @@ -57,17 +59,19 @@
- name: Install CodeGrader Backend requirements
ansible.builtin.pip:
requirements: /opt/CodeGrader/codeGrader/backend/requirements.txt
virtualenv: /opt/CodeGrader_venv/

- name: Install CodeGrader Frontend requirements
ansible.builtin.pip:
requirements: /opt/CodeGrader/codeGrader/frontend/requirements.txt
virtualenv: /opt/CodeGrader_venv/

- name: Rename the setup Script
shell: mv setup_full.py setup.py
args:
chdir: /opt/CodeGrader

- name: Install the CodeGrader Application Frontend and Backend
shell: pip install .
shell: /opt/CodeGrader_venv/bin/python3.11 -m pip install .
args:
chdir: /opt/CodeGrader
19 changes: 14 additions & 5 deletions doc/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,29 @@ exit
```
Then proceed with to clone and install the software itself.

For running everything in a Virtual Python environment run:
```
apt-get install python3-venv
python3 -m venv /opt/CodeGrader_venv/
```

```
cd /opt
rm -r /opt/CodeGrader
git clone https://github.com/ooemperor/CodeGrader.git
cd CodeGrader
pip install -r ./codeGrader/frontend/requirements.txt
pip install -r ./codeGrader/backend/requirements.txt
/opt/CodeGrader_venv/bin/python3.11 -m pip install -r ./codeGrader/frontend/requirements.txt
/opt/CodeGrader_venv/bin/python3.11 -m pip install -r ./codeGrader/backend/requirements.txt
cd /opt/CodeGrader
mv setup_full.py setup.py
pip install .
/opt/CodeGrader_venv/bin/python3.11 -m pip install .
```

If you are running some Version of python higher than 3.9, it could be that there is an Error about Externally Managed python.
You can resolve this by running:
Everything that you run from right now on, that are scripts such as ```cgAddAdmin``` needs to be run from the python venv
with ```/opt/CodeGrader_venv/bin/cgAddAdmin```. This ensures proper execution within the Virtual Environment.

If you are running some Version of python higher than 3.9 without Virtual Environment, it could be that there is an Error about Externally Managed python.
You can resolve this by running (not recommended):
```
rm -rf /usr/lib/python3.11/EXTERNALLY-MANAGED
```
Expand Down
2 changes: 1 addition & 1 deletion services/cgAdminFrontend.service
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ After=network.target
[Service]
User=root
WorkingDirectory=/
ExecStart=nohup /opt/CodeGrader_venv/bin/cgAdminFrontend > /var/log/cgAdminFrontend.log &
ExecStart=/opt/CodeGrader_venv/bin/cgAdminFrontend
# optional items below
Restart=always
RestartSec=3
Expand Down
2 changes: 1 addition & 1 deletion services/cgApiBackend.service
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ After=network.target
[Service]
User=root
WorkingDirectory=/
ExecStart=nohup /opt/CodeGrader_venv/bin/cgApiBackend > /var/log/cgApiBackend.log &
ExecStart=/opt/CodeGrader_venv/bin/cgApiBackend
# optional items below
Restart=always
RestartSec=3
Expand Down
2 changes: 1 addition & 1 deletion services/cgEvaluationService.service
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ After=network.target
[Service]
User=root
WorkingDirectory=/
ExecStart=nohup /opt/CodeGrader_venv/bin/cgEvaluationService > /var/log/cgEvaluationService.log &
ExecStart=/opt/CodeGrader_venv/bin/cgEvaluationService
# optional items below
Restart=always
RestartSec=3
Expand Down
2 changes: 1 addition & 1 deletion services/cgExecutionService.service
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ After=network.target
[Service]
User=root
WorkingDirectory=/
ExecStart=nohup /opt/CodeGrader_venv/bin/cgExecutionService > /var/log/cgExecutionService.log &
ExecStart=/opt/CodeGrader_venv/bin/cgExecutionService
# optional items below
Restart=always
RestartSec=3
Expand Down
2 changes: 1 addition & 1 deletion services/cgUserFrontend.service
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ After=network.target
[Service]
User=root
WorkingDirectory=/
ExecStart=nohup /opt/CodeGrader_venv/bin/cgUserFrontend > /var/log/cgUserFrontend.log &
ExecStart=/opt/CodeGrader_venv/bin/cgUserFrontend
# optional items below
Restart=always
RestartSec=3
Expand Down

0 comments on commit 2a44f18

Please sign in to comment.