Before starting, you need to have Python installed with a version >= 3.11.
Follow the official Poetry installation guide: https://python-poetry.org/docs/
Run the following command to install all dependencies:
poetry install
Poetry makes project environment isolation one of its core features.
To ensure everything is set up correctly, run the tests:
poetry run pytest
All tests should pass (or skip). Create an issue if you found any tests failed.
To format the codebase using yapf
, run the following command:
poetry run yapf -ir .
To ensure code quality and consistency, set up pre-commit hooks:
Install pre-commit:
poetry run pre-commit install
This will set up pre-commit hooks that will run some checks automatically before each commit.
To run NOJ (see the README of the root project), configure the following environment variables in docker-compose.yml
before docker compose up
:
Without MinIO, you cannot create Problems and Submissions.
We have set up the default values of these four variables in docker-compose.override.yml
, if you need to develop locally with MinIO, make sure to configure them properly based on the README in NOJ root project. You can skip this if you will not develop features related to Problems and Submissions.
MINIO_HOST
: The host for the MinIO server.MINIO_ACCESS_KEY
: The access key for MinIO.MINIO_SECRET_KEY
: The secret key for MinIO.MINIO_BUCKET
: The bucket name used in MinIO.
SMTP server is required for sending emails, such as password reset and signup new account. You can skip this if you will not develop features related to them.
SMTP_SERVER
: SMTP serverSMTP_NOREPLY
: email account used to send emails, e.g.[email protected]
SMTP_NOREPLY_PASSWORD
: password ofSMTP_NOREPLY
(optional)
These variables have default values, you can skip them if you want to use the default values.
MONGO_HOST
: host to MongoDB, used bymongoengine.connect
REDIS_HOST
/REDIS_PORT
: host and port to RedisJWT_EXP
: JWT expiration in daysJWT_ISS
: JWT issuer, e.g.noj.tw
JWT_SECRET
: JWT secret, ensure that you set a strong enough value in productionSERVER_NAME
: hostname used in external link (without schema), e.g.api.noj.tw
APPLICATION_ROOT
: the path that flask app is mounted, also used to generate external link, e.g./api
. default to/