From 8752230a73be3ab0e91575cb670c1e29697c1fc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gregor=20Jer=C5=A1e?= Date: Thu, 4 Dec 2025 13:22:08 +0100 Subject: [PATCH] Django 6 --- pyproject.toml | 2 +- resolwe/flow/migrations/0008_annotations.py | 2 +- resolwe/flow/models/annotations.py | 2 +- resolwe/flow/models/functions.py | 2 +- .../permissions/migrations/0001_initial.py | 2 +- resolwe/permissions/models.py | 2 +- resolwe/test_helpers/test_runner.py | 33 ++++++------------- tests/settings.py | 1 + 8 files changed, 17 insertions(+), 29 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d4b9b78d2..c3b538f44 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,7 @@ dependencies = [ "channels_redis~=4.3.0", # Storage requirement for computing hashes. "crcmod", - "Django~=5.2.7", + "Django~=6.0", "django-fernet-fields-v2~=0.9", "django-filter~=25.2", "djangorestframework~=3.16.1", diff --git a/resolwe/flow/migrations/0008_annotations.py b/resolwe/flow/migrations/0008_annotations.py index 5b8df85d1..1537e3091 100644 --- a/resolwe/flow/migrations/0008_annotations.py +++ b/resolwe/flow/migrations/0008_annotations.py @@ -138,7 +138,7 @@ class Migration(migrations.Migration): migrations.AddConstraint( model_name="annotationfield", constraint=models.CheckConstraint( - check=models.Q(("type__in", ["DATE", "DECIMAL", "INTEGER", "STRING"])), + condition=models.Q(("type__in", ["DATE", "DECIMAL", "INTEGER", "STRING"])), name="annotation_type", ), ), diff --git a/resolwe/flow/models/annotations.py b/resolwe/flow/models/annotations.py index 40287d2d5..e824f8660 100644 --- a/resolwe/flow/models/annotations.py +++ b/resolwe/flow/models/annotations.py @@ -419,7 +419,7 @@ class Meta: constraints = [ # Accept only supported annotation types. models.constraints.CheckConstraint( - check=models.Q(type__in=[e.value for e in AnnotationType]), + condition=models.Q(type__in=[e.value for e in AnnotationType]), name="annotation_type", ), models.constraints.UniqueConstraint( diff --git a/resolwe/flow/models/functions.py b/resolwe/flow/models/functions.py index dcaaff4b8..75fa93ad5 100644 --- a/resolwe/flow/models/functions.py +++ b/resolwe/flow/models/functions.py @@ -27,7 +27,7 @@ def __init__(self, expression, path): def as_sql(self, compiler, connection): """Compile SQL for this function.""" sql, params = super().as_sql(compiler, connection) - params.append(self.path) + params = params + (self.path,) return sql, params diff --git a/resolwe/permissions/migrations/0001_initial.py b/resolwe/permissions/migrations/0001_initial.py index d8534f60d..465d0e5a4 100644 --- a/resolwe/permissions/migrations/0001_initial.py +++ b/resolwe/permissions/migrations/0001_initial.py @@ -88,7 +88,7 @@ class Migration(migrations.Migration): migrations.AddConstraint( model_name="permissionmodel", constraint=models.CheckConstraint( - check=models.Q( + condition=models.Q( models.Q(("group__isnull", True), ("user__isnull", False)), models.Q(("group__isnull", False), ("user__isnull", True)), _connector="OR", diff --git a/resolwe/permissions/models.py b/resolwe/permissions/models.py index bcf97558f..bdb697447 100644 --- a/resolwe/permissions/models.py +++ b/resolwe/permissions/models.py @@ -345,7 +345,7 @@ class Meta: condition=models.Q(group__isnull=False), ), models.CheckConstraint( - check=models.Q(user__isnull=False, group__isnull=True) + condition=models.Q(user__isnull=False, group__isnull=True) | models.Q(user__isnull=True, group__isnull=False), name="exactly_one_of_user_group_must_be_set", ), diff --git a/resolwe/test_helpers/test_runner.py b/resolwe/test_helpers/test_runner.py index 2b95fa1ed..b6aa33b9c 100644 --- a/resolwe/test_helpers/test_runner.py +++ b/resolwe/test_helpers/test_runner.py @@ -52,10 +52,6 @@ from . import TESTING_CONTEXT -# Python 3.14 uses forkserver by default, which is not supported by Django. -# Remove the line bellow after Django fixes the issue. -multiprocessing.set_start_method("fork", force=True) - auth = None logger = logging.getLogger(__name__) @@ -241,27 +237,19 @@ def _prepare_settings(): return (overrides, zmq_info) -def _custom_worker_init(django_init_worker): +def _custom_worker_init(django_init_worker, *args, **kwargs): """Wrap the original worker init to also start the manager.""" - def _init_worker(*args, **kwargs): - """Initialize a :class:`multiprocessing.Pool` worker. - - Call the Django's ``ParallelTestSuite.init_worker`` and then - also start the manager infrastructure. - """ - result = django_init_worker(*args, **kwargs) + result = django_init_worker(*args, **kwargs) - # Further patch channel names and the like with our current pid, - # so that parallel managers and executors don't clash on the - # same channels and directories. - resolwe_settings.FLOW_MANAGER_SETTINGS[ - "REDIS_PREFIX" - ] += "-parallel-pid{}".format(os.getpid()) + # Further patch channel names and the like with our current pid, + # so that parallel managers and executors don't clash on the + # same channels and directories. + resolwe_settings.FLOW_MANAGER_SETTINGS[ + "REDIS_PREFIX" + ] += "-parallel-pid{}".format(os.getpid()) - return result - - return _init_worker + return result def _run_in_event_loop(coro, *args, **kwargs): @@ -361,8 +349,7 @@ def run(self, *args, **kwargs): class CustomParallelTestSuite(ParallelTestSuite): """Standard parallel suite with a custom worker initializer.""" - - init_worker = _custom_worker_init(ParallelTestSuite.init_worker) + init_worker = partial(_custom_worker_init, django_init_worker=ParallelTestSuite.init_worker) runner_class = CustomRemoteRunner diff --git a/tests/settings.py b/tests/settings.py index e36c42707..c944ad423 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -28,6 +28,7 @@ INSTALLED_APPS = ( "django.contrib.auth", "django.contrib.contenttypes", + "django.contrib.postgres", "django.contrib.sessions", "django.contrib.staticfiles", "channels",