API for connecting with the DMOJ Judge used for grading programming exercises in the Minerva LMS.
Report Bug
·
Request Feature
Table of Contents
This API is employed to establish a seamless connection between the Minerva backend and the judge, with a focus on efficiently handling requests.
Here's why:
- The project anticipates approximately 200,000 requests per year, with specific instances requiring a high volume of service consumption.
- The judge needs to effectively handle multiple requests simultaneously.
Are you able to review our requirements outlined in the pyproject file. This document provides a comprehensive overview of the specifications we are seeking.
Here's a guide on how to set up our project locally. This step-by-step walkthrough will assist you in configuring the project on your local environment for seamless development and testing.
In order to effectively work with this project, it's necessary to install certain software components. Follow these steps:
-
Ensure you have Python 3.X installed, with the appropriate version specified in pyproject
sudo apt install python3.8
Nice to have:
- Consider adding an SSH key for seamless connection with GitHub. This small step can greatly enhance your experience by simplifying authentication processes and streamlining your interactions with the platform. Look this tutorial if you want
- Clone the repo
git clone https://github.com/MinervaLMS/judge-api.git
- Install poetry
For a proper installation on your operating system, we recommend following this tutorial
curl -sSL https://install.python-poetry.org | python3 -
- Initialize the Poetry environment by navigating to the correct project path and executing the command below:
poetry shell
- This installs the default Python version on your computer for the environment. If you prefer to use a different version, you can install that version on your computer and then proceed with the following steps:
poetry env use 3.8
- This installs the default Python version on your computer for the environment. If you prefer to use a different version, you can install that version on your computer and then proceed with the following steps:
- Install the required dependencies by running the following command:
poetry install
- If you stumble upon an DMOJ error related to library
$seccomp$ , run the following command on you linux machine:sudo apt install libseccomp-dev
- Another usual problem is related to 'x86_64-linux-gnu-gcc'. To solve it, install:
sudo apt-get install build-essential
- If you stumble upon an DMOJ error related to library
- We recommend configuring the pre-commit functionality within the Poetry environment, especially if you won't be using it in other repositories. However, you also have the option to set it up globally on your PC by installing pre-commit system-wide.
pre-commit install
- The default DMOJ root is
$/mnt$ . We must give permissions to a group in order to place and modify archives located there. As we desire not other users modifing our environment, first, let's create a group named judge:sudo groupadd judge
And add user ubuntu to group judge:
sudo usermod --append --groups judge ubuntu
To set permissions, we must change ownership of /mnt to be group judge:
sudo chown :judge mnt
Finally, we set permissions. We will set it so that both root and group judge have rwx (read, write, execute) permissions and other users none.
sudo chmod 770 /mnt
A final reminder is that one must logout and login again for these changes to apply.
- To run the Judge API, run the following command, which can be understood as following:
The --http option starts an HTTP server at 0.0.0.0 port 5000. The --master option specifies the standard worker manager. The
$-p$ option starts 4 worker processes; a starting value could be$CPU * 2$ . The$-w$ option tells uWSGI how to import your application (ref). The $ & $ value will let you operate your machine while the Judge API is running.nohup uwsgi --http 0.0.0.0:5000 --master -p 4 -w wsgi:app &
- If you require to terminate this process, run the following command (supposing you are running the API in the 5000 port as default).
kill -9 $(lsof -t -i:"5000")
- If you require to terminate this process, run the following command (supposing you are running the API in the 5000 port as default).
NOTE: It is intended for Linux-based machines (WSL included); Windows and mac are not supported.
- in the poetry environment run the command
copy and paste the output into judge-api/app/utils/constants.py RUNTIME
dmoj-autoconf
finally verify that in the path of judge-api/app/utils/constants.py JUDGE_ROOT there is the folder problems with the problem TEST inside
If you want to contribute in this project
- Clone the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE.txt
for more information.
Your Name - @your_twitter - email@example.com
Project Link: https://github.com/MinervaLMS/judge-api/