Skip to content

Commit e0be1d0

Browse files
authored
Merge branch 'master' into notifications-python
2 parents 225bce4 + 772a93a commit e0be1d0

File tree

280 files changed

+1345
-1277
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

280 files changed

+1345
-1277
lines changed

.gitattributes

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This file exists for multi-system support
2+
3+
# default file behaviour
4+
* text=auto
5+
6+
# make all '.sh' files LF, regardless of users' OS
7+
*.sh text eol=lf

.github/workflows/ruff.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ jobs:
1515
- uses: astral-sh/ruff-action@v3
1616
with:
1717
src: "./oioioi"
18-
version: 0.11.12
18+
version: 0.13.2

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.11.12
3+
rev: v0.13.2
44
hooks:
55
- id: ruff-check
66
files: ^oioioi/

Dockerfile

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,16 @@ RUN pip3 install --user bsddb3==6.2.7
5858

5959
WORKDIR /sio2/oioioi
6060

61-
COPY --chown=oioioi:oioioi setup.py requirements.txt ./
62-
RUN pip3 install -r requirements.txt --user filetracker[server]
63-
COPY --chown=oioioi:oioioi requirements_static.txt ./
64-
RUN pip3 install -r requirements_static.txt --user
65-
RUN pip3 install --user -U "gevent==25.5.1" # override version of gevent
61+
COPY --chown=oioioi:oioioi . ./
62+
RUN pip3 install --user -r requirements.txt filetracker[server]
63+
RUN pip3 install --user -r requirements_static.txt
6664

6765
# Installing node dependencies
6866
ENV PATH $PATH:/sio2/oioioi/node_modules/.bin
6967

70-
COPY --chown=oioioi:oioioi package.json package-lock.json ./
7168
RUN npm ci
72-
73-
COPY --chown=oioioi:oioioi . /sio2/oioioi
74-
7569
RUN npm run build
70+
7671
RUN oioioi-create-config /sio2/deployment
7772

7873
WORKDIR /sio2/deployment
@@ -103,6 +98,8 @@ FROM base AS development
10398
COPY --from=development-sandboxes /sio2/sandboxes /sio2/sandboxes
10499
RUN chmod +x /sio2/oioioi/download_sandboxes.sh
105100

101+
# For production: Upload sandboxes to built-in filetracker during build
102+
# For dev: These will be re-uploaded to s3dedup at runtime via oioioi_init.sh
106103
RUN ./manage.py supervisor > /dev/null --daemonize --nolaunch=uwsgi && \
107104
/sio2/oioioi/wait-for-it.sh -t 60 "127.0.0.1:9999" && \
108105
./manage.py upload_sandboxes_to_filetracker -d /sio2/sandboxes && \

UPGRADING.rst

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ List of changes since the *CONFIG_VERSION* numbering was introduced:
347347
# directory in which necessary files will be stored.
348348
#FILETRACKER_CACHE_ROOT = '__DIR__/cache'
349349

350-
# When using a remote storage it's recommended to enable a cache cleaner deamon
350+
# When using a remote storage it's recommended to enable a cache cleaner daemon
351351
# which will periodically scan cache directory and remove files what aren't
352352
# used. For a detailed description of each option, please read a cache cleaner
353353
# configuration section in the sioworkersd documentation.
@@ -439,7 +439,7 @@ List of changes since the *CONFIG_VERSION* numbering was introduced:
439439

440440
-# Filetracker server settings.
441441
-#
442-
-# Determines which filetracker database use, availible options are:
442+
-# Determines which filetracker database use, available options are:
443443
-# - 'oioioi.filetracker.client.media_root_factory' (the default)
444444
-# Stores files on local filesystem under MEDIA_ROOT, optionally
445445
-# exposing them with a filetracker server (see section below).
@@ -588,7 +588,7 @@ List of changes since the *CONFIG_VERSION* numbering was introduced:
588588

589589
# 'oioioi.usergroups',
590590

591-
#. * Introduced `DEFAULT_COMPILERS` to settings, which should be set for every language supoorted::
591+
#. * Introduced `DEFAULT_COMPILERS` to settings, which should be set for every language supported::
592592

593593
--- a/oioioi/default_settings.py
594594
+++ b/oioioi/default_settings.py
@@ -896,7 +896,7 @@ List of changes since the *CONFIG_VERSION* numbering was introduced:
896896
+# The server to be run. Options are:
897897
+# 'django' - django's http server
898898
+# 'uwsgi' - uwsgi daemon
899-
+# 'uwsgi-http' - uwsgi deamon with built-in http server
899+
+# 'uwsgi-http' - uwsgi daemon with built-in http server
900900
+# None - nothing will be run
901901
+SERVER = 'django'
902902

@@ -1121,3 +1121,49 @@ List of changes since the *CONFIG_VERSION* numbering was introduced:
11211121
+# )
11221122

11231123
* Remove all sentry and raven reminiscent from settings.py in LOGGING SECTION.
1124+
1125+
Migrating from Filetracker to s3dedup (currently only for docker-compose-dev.yml deployments)
1126+
----------------------------------------------------------------
1127+
1128+
This guide covers migrating from the built-in Filetracker to s3dedup in Docker Compose
1129+
development deployments. This is currently only needed deployments using ``docker-compose-dev.yml``.
1130+
If you don't have any data you want to keep, you don't have to do anything.
1131+
1132+
#. Stop the s3dedup container::
1133+
1134+
docker-compose -f docker-compose-dev.yml stop s3dedup
1135+
1136+
#. In ``docker-compose-dev.yml``, modify the web container environment variables:
1137+
1138+
* Remove ``FILETRACKER_SERVER_ENABLED=False`` (or set to ``True``)
1139+
* Set ``FILETRACKER_LISTEN_ADDR=0.0.0.0``
1140+
* Set ``FILETRACKER_LISTEN_PORT=9999``
1141+
1142+
#. Restart the web container::
1143+
1144+
docker-compose -f docker-compose-dev.yml down web
1145+
docker-compose -f docker-compose-dev.yml up -d web
1146+
1147+
#. Run the migration::
1148+
1149+
docker-compose -f docker-compose-dev.yml run --rm s3dedup migrate --env \
1150+
--filetracker-url http://web:9999 \
1151+
--max-concurrency 10
1152+
1153+
The migration will display progress and statistics about files migrated and
1154+
deduplication savings.
1155+
1156+
#. Once migration completes, restore the environment variables in ``docker-compose-dev.yml``:
1157+
1158+
* Remove or comment out ``FILETRACKER_LISTEN_ADDR`` and ``FILETRACKER_LISTEN_PORT``
1159+
* Set ``FILETRACKER_SERVER_ENABLED=False``
1160+
1161+
#. Restart the web container and start s3dedup::
1162+
1163+
docker-compose -f docker-compose-dev.yml down web
1164+
docker-compose -f docker-compose-dev.yml up -d web s3dedup
1165+
1166+
#. Verify the migration by checking that files are accessible through s3dedup.
1167+
1168+
For more details about the migration process, see the s3dedup documentation at
1169+
``https://github.com/sio2project/s3dedup``.

conftest.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
from __future__ import print_function
2-
31
import pytest
4-
2+
from django.conf import settings
53
from oioioi.base.tests import pytest_plugin as base_plugin
64
from oioioi.contests.tests import pytest_plugin as contests_plugin
7-
from django.conf import settings
85

96

107
def pytest_addoption(parser):

docker-compose-dev.yml

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
x-common-envs: &common-envs
2-
FILETRACKER_URL: 'http://web:9999'
2+
FILETRACKER_URL: 'http://s3dedup:9999/ft'
33
DATABASE_HOST: 'db'
44
DATABASE_PORT: '5432'
55

@@ -30,8 +30,7 @@ services:
3030
RABBITMQ_PORT: '5672'
3131
RABBITMQ_USER: 'oioioi'
3232
RABBITMQ_PASSWORD: 'oioioi'
33-
FILETRACKER_LISTEN_ADDR: '0.0.0.0'
34-
FILETRACKER_LISTEN_PORT: '9999'
33+
FILETRACKER_SERVER_ENABLED: 'False'
3534
<<: *common-envs
3635
ports:
3736
# web server
@@ -49,6 +48,7 @@ services:
4948
depends_on:
5049
- db
5150
- broker
51+
- s3dedup
5252
worker:
5353
image: sio2project/oioioi-dev
5454
command: ["/sio2/oioioi/worker_init.sh"]
@@ -68,8 +68,55 @@ services:
6868
RABBITMQ_DEFAULT_USER: oioioi
6969
RABBITMQ_DEFAULT_PASS: oioioi
7070
stop_grace_period: 1m
71+
minio:
72+
image: minio/minio:RELEASE.2024-10-02T17-50-41Z
73+
environment:
74+
MINIO_ROOT_USER: minioadmin
75+
MINIO_ROOT_PASSWORD: minioadmin
76+
volumes:
77+
- minio-data-dev:/data
78+
command: server /data --console-address ":9001"
79+
ports:
80+
- "9000:9000" # MinIO API
81+
- "9001:9001" # MinIO Console
82+
healthcheck:
83+
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
84+
interval: 5s
85+
timeout: 3s
86+
retries: 10
87+
start_period: 5s
88+
stop_grace_period: 1m
89+
s3dedup:
90+
image: ghcr.io/sio2project/s3dedup:latest-dev
91+
ports:
92+
- "9999:9999"
93+
environment:
94+
LOG_LEVEL: debug
95+
BUCKET_NAME: oioioi-filetracker
96+
LISTEN_ADDRESS: 0.0.0.0
97+
LISTEN_PORT: 9999
98+
KVSTORAGE_TYPE: sqlite
99+
SQLITE_PATH: /app/data/kv.db
100+
SQLITE_MAX_CONNECTIONS: 10
101+
S3_ENDPOINT: http://minio:9000
102+
S3_ACCESS_KEY: minioadmin
103+
S3_SECRET_KEY: minioadmin
104+
S3_FORCE_PATH_STYLE: "true"
105+
CLEANER_ENABLED: "true"
106+
CLEANER_INTERVAL: 3600
107+
CLEANER_BATCH_SIZE: 1000
108+
CLEANER_MAX_DELETES: 10000
109+
volumes:
110+
- s3dedup-data-dev:/app/data
111+
depends_on:
112+
minio:
113+
condition: service_healthy
114+
restart: on-failure:5
115+
stop_grace_period: 1m
71116
volumes:
72117
postgress-data-dev:
73118
filetracker-data-dev:
74119
node_modules-dev:
75120
dist_webpack-dev:
121+
minio-data-dev:
122+
s3dedup-data-dev:

easy_toolbox.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@
1919
import sys
2020
from shlex import quote
2121

22-
BASE_DOCKER_COMMAND = "OIOIOI_UID=$(id -u) docker compose" + " -f docker-compose-dev.yml"
22+
if sys.platform == "win32":
23+
# for Windows, a different syntax command_prefix is needed
24+
command_prefix = "set OIOIOI_UID=1000 &&"
25+
else:
26+
command_prefix = "OIOIOI_UID=$(id -u)"
27+
28+
BASE_DOCKER_COMMAND = f"{command_prefix} docker compose -f docker-compose-dev.yml"
2329

2430
RAW_COMMANDS = [
2531
("build", "Build OIOIOI container from source.", "build", True),
@@ -45,7 +51,7 @@
4551
"Run coverage tests.",
4652
"{exec} 'web' ../oioioi/test.sh oioioi/problems --cov-report term --cov-report xml:coverage.xml --cov=oioioi {extra_args}",
4753
),
48-
("cypress-apply-settings", "Apply settings for CyPress.", '{exec} web bash -c "echo CAPTCHA_TEST_MODE=True >> settings.py"'),
54+
("cypress-apply-settings", "Apply settings for CyPress.", '{exec} web bash -c "echo >> settings.py && echo CAPTCHA_TEST_MODE=True >> settings.py"'),
4955
("npm", "Run npm command.", "{exec} web npm --prefix ../oioioi {extra_args}"),
5056
("eslint", "Run javascript linter.", "{exec} web npm --prefix ../oioioi run lint"),
5157
(
@@ -132,15 +138,22 @@ def get_action_from_gui() -> Option:
132138
),
133139
]
134140
answers = inquirer.prompt(questions)
135-
return answers["action"]
141+
return COMMANDS[answers["action"]]
136142

137143

138144
def run_command(command) -> None:
139145
print("Running command", command)
140146
if not NO_INPUT:
141147
width = os.get_terminal_size().columns
142148
print("=" * width)
143-
sys.exit(os.WEXITSTATUS(os.system(command)))
149+
150+
151+
if sys.platform == "win32":
152+
# for Windows, a different syntax for exiting is needed
153+
exit_code = os.system(command)
154+
sys.exit(exit_code)
155+
else:
156+
sys.exit(os.WEXITSTATUS(os.system(command)))
144157

145158

146159
def warn_user(action: Option) -> bool:
@@ -189,6 +202,5 @@ def main() -> None:
189202
except Exception as e:
190203
print(f"An error occurred during execution: {e}", file=sys.stderr)
191204

192-
193205
if __name__ == "__main__":
194206
main()

extra/sample-configs/runnable-test-settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
#
3838

3939
#
40-
# To workarund a bug, where sioworkers is not passed
40+
# To workaround a bug, where sioworkers is not passed
4141
# FILETRACKER_CACHE_ROOT, use this to start the website:
4242
#
4343
# FILETRACKER_URL=/tmp/oioioi-filetracker-cache ./manage.py runserver

ez_setup.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
This file can also be run as a script to install or upgrade setuptools.
1515
"""
1616

17-
from __future__ import print_function
18-
1917
import os
2018
import sys
2119

@@ -25,7 +23,7 @@
2523
from md5 import md5
2624

2725
DEFAULT_VERSION = "0.6c11"
28-
DEFAULT_URL = "http://pypi.python.org/packages/%s/s/setuptools/" % sys.version[:3]
26+
DEFAULT_URL = f"http://pypi.python.org/packages/{sys.version[:3]}/s/setuptools/"
2927

3028
md5_data = {
3129
"setuptools-0.6b1-py2.3.egg": "8822caf901250d848b996b7f25c6e6ca",
@@ -78,7 +76,7 @@ def _validate_md5(egg_name, data):
7876
digest = md5(data).hexdigest()
7977
if digest != md5_data[egg_name]:
8078
print(
81-
("md5 validation of %s failed! (Possible download problem?)" % egg_name),
79+
(f"md5 validation of {egg_name} failed! (Possible download problem?)"),
8280
file=sys.stderr,
8381
)
8482
sys.exit(2)
@@ -122,12 +120,11 @@ def do_download():
122120
if was_imported:
123121
print(
124122
(
125-
"The required version of setuptools (>=%s) is not available, and\n"
123+
f"The required version of setuptools (>={version}) is not available, and\n"
126124
"can't be installed while this script is running. Please install\n"
127125
" a more recent version first, using 'easy_install -U setuptools'."
128-
"\n\n(Currently using %r)"
129-
)
130-
% (version, e.args[0]),
126+
f"\n\n(Currently using {e.args[0]!r})"
127+
),
131128
file=sys.stderr,
132129
)
133130
sys.exit(2)
@@ -148,7 +145,7 @@ def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_d
148145
"""
149146
import urllib.request
150147

151-
egg_name = "setuptools-%s-py%s.egg" % (version, sys.version[:3])
148+
egg_name = f"setuptools-{version}-py{sys.version[:3]}.egg"
152149
url = download_base + egg_name
153150
saveto = os.path.join(to_dir, egg_name)
154151
src = dst = None
@@ -251,7 +248,7 @@ def update_md5(filenames):
251248
md5_data[base] = md5(f.read()).hexdigest()
252249
f.close()
253250

254-
data = [" %r: %r,\n" % it for it in md5_data.items()]
251+
data = [" {!r}: {!r},\n".format(*it) for it in md5_data.items()]
255252
data.sort()
256253
repl = "".join(data)
257254

0 commit comments

Comments
 (0)