Skip to content

Commit 8ca3c78

Browse files
ObadaScjh1Obada Haddad
authored
Various packages upgrades (Django 5.2) (#2200)
* Fix gather to work with Python 3.12 * packages upgrade with uv lock --upgrade * bump gunicorn to 23; new major version of flake8 so new fixes * bump jinja, requests, pillow * bump uvicorn (includes h11) * bump python to 3.10.19 for the compute worker; bump websockets to 16 for instance and compute worker (which also fixes an issue on the compute worker with python 3.10) * Upgrade package.json packages (still some left, like Riot which is a major rewrite) * remove six from pyproject and code * flake8 fixes * bump boto3, botocore, s3transfer * bump urllib3 * bump python to 3.13 on compute worker * bump pyyaml, ipdb, twisted, flex, markdown, flex, pygments, whitenoise, bleach, oyaml, aiofiles, bpython, argh, watchdog * bump celery to 5.6.2 for main instance * bump python to 3.13.11 on instance * flake8 fixes * bump python to 3.14 for playwright pytests * merge pytest.ini into pyproject.toml; bump pytest to 9.0.2 * bump various django related packages; bump pytest to 9.0.2 and merge pytest config from setup.cfg into pyproject.toml * bump django_filter and fix code to make it work * remove coreapi and legacy-cgi, bump setuptools * remove duplicate build in docker-compose.yml and assign better names to containers * bump caddy version and remove useless line in circle-ci config file * bump django to 4.2.29 and various other packages with uv lock --upgrade * bump django to 5.2.12, bump other packages with uv lock --upgrade * bump factory-boy, django-ajax-selects, drf-extensions and replace deprecated django-cors-middleware with django-cors-headers * replace bleach (deprecated) with nh3 * bump django-redis to 6.0.0 * bump rabbitmq to 4.2.4 * cleanup some Containerfiles * Fixed missing code from #2237 that was not merged into this branch * bump blessed and redis on instance; bump charset-normalizer and setuptools on compute worker * fix logout that broke on django 5.2 upgrade --------- Co-authored-by: Chris Harris <cjh@lbl.gov> Co-authored-by: Obada Haddad <obada.haddad@lisn.fr>
1 parent 839a138 commit 8ca3c78

33 files changed

Lines changed: 891 additions & 1197 deletions

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969

7070
- run:
7171
name: "Tests: Run unit/integration tests (excluding e2e)"
72-
command: docker compose exec django py.test src/ -m "not e2e"
72+
command: docker compose exec django py.test src/
7373

7474
# We give the name of the test files manually because we need test_auth.py to be run before the others for state.json file to be created
7575
# CI="true" to skip some tests that fail in the CI for now

compute_worker/compute_worker.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ def rewrite_bundle_url_if_needed(url):
240240
# -----------------------------------------------------------------------------
241241
@shared_task(name="compute_worker_run")
242242
def run_wrapper(run_args):
243+
# We need to convert the UUID given by celery into a byte like object otherwise things will break
244+
run_args.update(secret=str(run_args["secret"]))
243245
logger.info(f"Received run arguments: \n {colorize_run_args(json.dumps(run_args))}")
244246
run = Run(run_args)
245247

@@ -1183,14 +1185,14 @@ def start(self):
11831185

11841186
logger.info("Running scoring program, and then ingestion program")
11851187
loop = asyncio.new_event_loop()
1188+
# Set the event loop for the gather
1189+
asyncio.set_event_loop(loop)
11861190
gathered_tasks = asyncio.gather(
11871191
self._run_program_directory(program_dir, kind="program"),
11881192
self._run_program_directory(ingestion_program_dir, kind="ingestion"),
11891193
self.watch_detailed_results(),
1190-
loop=loop,
11911194
return_exceptions=True,
11921195
)
1193-
11941196
task_results = [] # will store results/exceptions from gather
11951197
signal.signal(signal.SIGALRM, alarm_handler)
11961198
signal.alarm(self.execution_time_limit)
@@ -1278,6 +1280,9 @@ def start(self):
12781280
# set logs of this kind to None, since we handled them already
12791281
logger.info("Program finished")
12801282
signal.alarm(0)
1283+
# Ensure loop is cleaned up
1284+
loop.close()
1285+
asyncio.set_event_loop(None)
12811286

12821287
if self.is_scoring:
12831288
# Check if scoring program failed

compute_worker/pyproject.toml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@
22
authors = [
33
{name = "codalab"},
44
]
5-
requires-python = "==3.9.20"
5+
requires-python = "==3.13.11"
66
dependencies = [
7-
"celery==5.2.2",
7+
"celery==5.6.2",
88
"requests>=2.32.4,<3",
9-
"watchdog==2.1.1",
10-
"argh==0.26.2",
11-
"websockets==9.1",
12-
"aiofiles==0.4.0",
13-
"pyyaml==6.0.1",
9+
"watchdog==6.0.0",
10+
"argh==0.31.3",
11+
"websockets==16.0.0",
12+
"aiofiles==25.1.0",
13+
"pyyaml==6.0.3",
1414
"loguru>=0.7.3,<0.8",
1515
"docker>=7.1.0,<8",
1616
"rich>=14.2.0,<15",
17+
"setuptools>=82.0.0",
1718
]
1819

1920
name = "compute-worker"
2021
version = "0.1.0"
21-
description = ""
22+
description = ""

compute_worker/uv.lock

Lines changed: 134 additions & 102 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docker-compose.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ services:
33
# Web Services
44
#----------------------------------------------------------------------------------------------------
55
caddy:
6-
image: caddy:2.10.0
6+
image: caddy:2.11.1
77
env_file: .env
88
environment:
99
- ACME_AGREE=true
@@ -22,9 +22,11 @@ services:
2222
- django
2323

2424
django:
25+
container_name: django
2526
build:
2627
context: .
2728
dockerfile: packaging/container/Containerfile
29+
image: django_site-worker
2830
# NOTE: We use watchmedo to reload gunicorn nicely, Uvicorn + Gunicorn reloads don't work well
2931
command: ["python manage.py migrate --no-input && python manage.py collectstatic --no-input && cd /app/src && watchmedo auto-restart -p '*.py' --recursive -- python3 ./gunicorn_run.py"]
3032
environment:
@@ -95,6 +97,7 @@ services:
9597
# Local development helper, rebuilds RiotJS/Stylus on change
9698
#----------------------------------------------------------------------------------------------------
9799
builder:
100+
container_name: builder
98101
build:
99102
context: .
100103
dockerfile: packaging/container/Containerfile.builder
@@ -115,6 +118,7 @@ services:
115118
#----------------------------------------------------------------------------------------------------
116119
db:
117120
image: postgres:18-alpine
121+
container_name: db
118122
env_file: .env
119123
environment:
120124
- PGDATA=/var/lib/postgresql/18/docker
@@ -136,6 +140,7 @@ services:
136140
# Rabbitmq & Flower monitoring tool
137141
#----------------------------------------------------------------------------------------------------
138142
rabbit:
143+
container_name: rabbit
139144
build:
140145
context: .
141146
dockerfile: packaging/container/Containerfile.rabbitmq
@@ -161,6 +166,7 @@ services:
161166
max-file: "5"
162167

163168
flower:
169+
container_name: flower
164170
image: mher/flower
165171
env_file: .env
166172
environment:
@@ -179,6 +185,7 @@ services:
179185
# Redis
180186
#----------------------------------------------------------------------------------------------------
181187
redis:
188+
container_name: redis
182189
image: redis
183190
ports:
184191
- 6379:6379
@@ -195,9 +202,8 @@ services:
195202
# This auto-reloads
196203
command: ["watchmedo auto-restart -p '*.py' --recursive -- celery -A celery_config worker -B -Q site-worker -l info -n site-worker@%n --concurrency=2"]
197204
working_dir: /app/src
198-
build:
199-
context: .
200-
dockerfile: packaging/container/Containerfile
205+
container_name: site_worker
206+
image: django_site-worker
201207
depends_on:
202208
- rabbit
203209
- db
@@ -219,6 +225,7 @@ services:
219225
compute_worker:
220226
command: ["celery -A compute_worker worker -l info -Q compute-worker -n compute-worker@%n"]
221227
working_dir: /app
228+
container_name: compute_worker
222229
build:
223230
context: .
224231
dockerfile: packaging/container/Containerfile.compute_worker

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
"name": "competitions-v2",
33
"version": "0.0.1",
44
"dependencies": {
5-
"jquery": "^3.2.1",
6-
"npm-watch": "^0.2.0",
7-
"riot": "^3.6.3",
8-
"stylus": "^0.54.5",
9-
"uglify-js": "^3.0.28"
5+
"jquery": "^4.0.0",
6+
"npm-watch": "^0.13.0",
7+
"riot": "^3.13.2",
8+
"stylus": "^0.64.0",
9+
"uglify-js": "^3.19.3"
1010
},
1111
"devDependencies": {},
1212
"watch": {

packaging/container/Containerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
FROM almalinux:10-minimal
2+
23
RUN microdnf install -y tar gzip
34

45
ENV PYTHONUNBUFFERED=1
56

67
# Install UV and add paths to PATH for uv and the future .venv created by uv
7-
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
8+
RUN curl -LsSf https://astral.sh/uv/install.sh | sh && microdnf remove -y tar gzip && microdnf clean all
89
ENV PATH=$PATH:/root/.local/bin
910
ENV PATH=$PATH:/.venv/bin
1011

11-
12-
COPY pyproject.toml ./
13-
COPY uv.lock ./
12+
# Copy pyproject and uv.lock
13+
COPY pyproject.toml uv.lock ./
1414

1515
# Install dependencies
1616
RUN uv sync --all-extras --frozen
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
FROM almalinux:10-minimal
2+
23
RUN microdnf install -y tar gzip
34

45
# This makes output not buffer and return immediately, nice for seeing results in stdout
56
ENV PYTHONUNBUFFERED=1
67

7-
COPY compute_worker/pyproject.toml ./
8-
COPY compute_worker/uv.lock ./
9-
COPY compute_worker/celery_config.py ./
10-
COPY compute_worker/compute_worker.py ./
11-
8+
COPY compute_worker/pyproject.toml compute_worker/uv.lock compute_worker/celery_config.py compute_worker/compute_worker.py ./
129

1310
# Install UV and add paths to PATH for uv and the future .venv created by uv
14-
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
11+
RUN curl -LsSf https://astral.sh/uv/install.sh | sh && microdnf remove -y tar gzip && microdnf clean all
1512
ENV PATH=$PATH:/root/.local/bin
1613
ENV PATH=$PATH:/.venv/bin
1714

1815

1916
# Install dependencies
2017
RUN uv sync --frozen
2118
COPY src/settings/logs_loguru.py /.venv/bin
19+
2220
ENTRYPOINT ["/bin/bash", "-c"]
2321
CMD ["celery -A compute_worker worker -l info -Q compute-worker -n compute-worker@$HOSTNAME --concurrency=1"]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM rabbitmq:4.2.0-management
1+
FROM rabbitmq:4.2.4-management
22

33
ARG WORKER_CONNECTION_TIMEOUT
44
RUN echo "consumer_timeout = $WORKER_CONNECTION_TIMEOUT" >> /etc/rabbitmq/conf.d/10-defaults.conf

pyproject.toml

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,71 +3,69 @@ name = "codabench"
33
version = "0.1.0"
44
description = ""
55
authors = [{ name = "Codalab" }]
6-
requires-python = ">=3.10,<3.11"
6+
requires-python = "==3.13.11"
77
readme = "README.md"
88
classifiers = [
99
"Programming Language :: Python :: 3",
1010
"Programming Language :: Python :: 3.10",
1111
]
1212
dependencies = [
13-
"django>=4.2.0,<5",
13+
"django==5.2.12",
1414
"django-oauth-toolkit==1.6.3",
15-
"django-cors-middleware==1.5.0",
16-
"social-auth-core>=4.1.0,<5",
17-
"social-auth-app-django>=5.0.0,<6",
18-
"six==1.16.0",
19-
"django-extensions>=3.2,<4",
20-
"channels==4.2.0",
15+
"social-auth-core==4.8.5",
16+
"social-auth-app-django==5.4.3",
17+
"django-extensions==4.1.0",
18+
"channels==4.3.2",
2119
"channels-redis==4.0.0",
22-
"pillow==10.3.0",
23-
"celery==4.4.7",
24-
"gunicorn==22.0.0",
25-
"urllib3>=1.25.4,<1.27",
26-
"uvicorn>=0.22.0,<0.23",
27-
"pyyaml==5.3.1",
28-
"watchdog==2.1.1",
29-
"argh==0.26.2",
30-
"python-dateutil==2.7.3",
31-
"bpython>=0.21.0,<0.22",
32-
"websockets>=10.4.0,<11",
33-
"aiofiles==0.4.0",
34-
"oyaml==0.7",
35-
"factory-boy==2.11.1",
36-
"bleach>=5.0.0",
37-
"django-debug-toolbar==3.2",
38-
"django-querycount==0.7.0",
20+
"pillow==12.1.1",
21+
"celery==5.6.2",
22+
"gunicorn==23.0",
23+
"urllib3==2.6.3",
24+
"uvicorn==0.38",
25+
"pyyaml==6.0.3",
26+
"watchdog==6.0.0",
27+
"argh==0.31.3",
28+
"python-dateutil==2.9.0",
29+
"bpython==0.26",
30+
"websockets==16.0.0",
31+
"aiofiles==25.1.0",
32+
"oyaml==1.0",
33+
"factory-boy==3.3.3",
3934
"blessings==1.7",
4035
"django-su>=1.0.0,<2",
41-
"django-ajax-selects==2.0.0",
36+
"django-ajax-selects==3.0.3",
4237
"dj-database-url==0.4.2",
4338
"psycopg2-binary>=2.9.9,<3",
44-
"django-redis==4.12.1",
39+
"django-redis==6.0.0",
4540
"django-storages[azure]>=1.14.6,<2",
4641
"azure-storage-blob>=12,<13",
4742
"azure-storage-common==2.1.0",
48-
"boto3==1.26.76",
49-
"whitenoise==5.2.0",
50-
"djangorestframework>=3.13.0",
43+
"boto3==1.42.50",
44+
"whitenoise==6.11.0",
45+
"djangorestframework==3.16.1",
5146
"djangorestframework-csv==3.0.1",
52-
"drf-extensions==0.4.0",
53-
"markdown==2.6.11",
54-
"pygments==2.2.0",
55-
"drf-writable-nested==0.6.2",
56-
"django-filter==2.4.0",
57-
"flex==6.12.0",
47+
"drf-extensions==0.8.0",
48+
"markdown==3.10.2",
49+
"pygments==2.19.2",
50+
"drf-writable-nested==0.7.2",
51+
"flex==6.14.1",
5852
"pyrabbit2==1.0.7",
59-
"django-enforce-host==1.0.1",
60-
"twisted==24.7.0",
61-
"ipdb==0.13",
62-
"jinja2==3.1.4",
63-
"requests==2.32.2",
64-
"drf-extra-fields>=3.5.0",
65-
"botocore==1.29.76",
66-
"s3transfer==0.6.0",
53+
"django-enforce-host==1.1.0",
54+
"twisted==25.5.0",
55+
"ipdb==0.13.13",
56+
"jinja2==3.1.6",
57+
"requests==2.32.5",
58+
"drf-extra-fields==3.7.0",
59+
"botocore==1.42.50",
60+
"s3transfer==0.16.0",
6761
"drf-spectacular>=0.28.0,<0.29",
68-
"coreapi>=2.3.3,<3",
6962
"loguru>=0.7.3,<0.8",
7063
"tzdata>=2025.3",
64+
"setuptools==82.0.0",
65+
"pytz>=2025.2",
66+
"django-filter==25.1",
67+
"django-cors-headers==4.9.0",
68+
"nh3==0.3.3",
7169
]
7270

7371
[tool.uv]
@@ -79,9 +77,11 @@ build-backend = "uv_build"
7977

8078
[dependency-groups]
8179
dev = [
82-
"flake8>=3.8.4",
83-
"pytest==7.4.4",
84-
"pytest-django==4.11.1",
80+
"django-querycount==0.7.0",
81+
"django-debug-toolbar==6.2.0",
82+
"flake8==7.3.0",
83+
"pytest==9.0.2",
84+
"pytest-django==4.12.0",
8585
]
8686
[tool.pytest.ini_options]
8787
DJANGO_SETTINGS_MODULE = "settings.develop" # Just "settings" since pytest will be running from src/

0 commit comments

Comments
 (0)