From 1df443515cc2f346a1621852fe939b03baab2eb3 Mon Sep 17 00:00:00 2001 From: Alex Lubbock Date: Thu, 8 Aug 2024 16:21:57 +0100 Subject: [PATCH] chore(deps): bump python to 3.12, thunor core bump more dependencies including thunor core and associated compatibility fixes. --- Dockerfile | 4 +- config-examples/docker-compose.complete.yml | 1 - .../docker-compose.postgresonly.yml | 1 - requirements.txt | 12 ++-- thunor | 2 +- thunordjango/settings.py | 59 ++++++++---------- thunordjango/wsgi.py | 3 +- thunorweb/plate_parsers.py | 2 +- thunorweb/templates/base-inner.html | 2 +- thunorweb/templatetags/thunorweb_tags.py | 8 ++- thunorweb/tests/test_datasets.py | 42 ++++++------- thunorweb/tests/test_plate_mapper.py | 14 ++--- thunorweb/tests/test_plots.py | 20 +++---- thunorweb/tests/test_tags.py | 60 +++++++++---------- 14 files changed, 112 insertions(+), 118 deletions(-) diff --git a/Dockerfile b/Dockerfile index a88a4888..79dfca62 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ -FROM python:3.11-slim-bullseye AS thunorweb_base -MAINTAINER Alex Lubbock +FROM python:3.12-slim-bullseye AS thunorweb_base +LABEL org.opencontainers.image.authors="code@alexlubbock.com" ENV PYTHONUNBUFFERED 1 ENV THUNOR_HOME=/thunor diff --git a/config-examples/docker-compose.complete.yml b/config-examples/docker-compose.complete.yml index 96be83b8..770b7fcd 100644 --- a/config-examples/docker-compose.complete.yml +++ b/config-examples/docker-compose.complete.yml @@ -1,4 +1,3 @@ -version: '2.1' services: app: extends: diff --git a/config-examples/docker-compose.postgresonly.yml b/config-examples/docker-compose.postgresonly.yml index 75a87ffe..32ef09d2 100644 --- a/config-examples/docker-compose.postgresonly.yml +++ b/config-examples/docker-compose.postgresonly.yml @@ -1,4 +1,3 @@ -version: '2.1' services: postgres: extends: diff --git a/requirements.txt b/requirements.txt index 6b2866cb..f6ca26f5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,12 +1,12 @@ -r thunor/requirements.txt Django==4.2.15 -django-allauth==0.52.0 +django-allauth==64.0.0 django-crispy-forms==1.14.0 django-custom-user==1.1 django-guardian==2.4.0 -django-invitations==2.0.0 +django-invitations==2.1.0 +django-redis==5.4.0 django-webpack-loader==0.6.0 -uwsgi==2.0.22 -psycopg2==2.9.5 -django-redis==5.2.0 -raven==6.10.0 +psycopg2==2.9.9 +sentry-sdk[django]==2.12.0 +uwsgi==2.0.23 diff --git a/thunor b/thunor index c0d932f2..179e7cc6 160000 --- a/thunor +++ b/thunor @@ -1 +1 @@ -Subproject commit c0d932f2e454f0b2716047dd107c25748c58a2ed +Subproject commit 179e7cc6b0459e1ed4e199ebee31fb38445face4 diff --git a/thunordjango/settings.py b/thunordjango/settings.py index 07ab67eb..1e90853e 100644 --- a/thunordjango/settings.py +++ b/thunordjango/settings.py @@ -11,21 +11,16 @@ """ import os +import sentry_sdk import sys import thunorweb from django.contrib import messages import errno import logging -logger = logging.getLogger(__name__) - # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) -# This is where state-specific files are stored, like uploads/downloads and -# the SQLite database, if applicable -STATE_DIR = os.path.join(BASE_DIR, '_state') - # Load environment variables for .env file, if present env_file = os.path.join(BASE_DIR, 'thunor-dev.env') try: @@ -46,6 +41,28 @@ # SECURITY WARNING: don't run with debug turned on in production! DEBUG = os.environ['DJANGO_DEBUG'].lower() == 'true' +# Initialise sentry error handler +sentry_sdk.init( + dsn=os.environ.get('DJANGO_SENTRY_DSN', None), + environment=os.environ.get('DJANGO_SENTRY_ENVIRONMENT', + 'development' if DEBUG else 'production'), + release=thunorweb.__version__, + # Set traces_sample_rate to 1.0 to capture 100% + # of transactions for tracing. + traces_sample_rate=1.0, + # Set profiles_sample_rate to 1.0 to profile 100% + # of sampled transactions. + # We recommend adjusting this value in production. + profiles_sample_rate=1.0, +) + + +logger = logging.getLogger(__name__) + +# This is where state-specific files are stored, like uploads/downloads and +# the SQLite database, if applicable +STATE_DIR = os.path.join(BASE_DIR, '_state') + if DEBUG: # Add the thunor submodule to the path sys.path.insert(0, os.path.join(BASE_DIR, 'thunor')) @@ -68,7 +85,6 @@ 'django.contrib.messages', 'django.contrib.sites', 'django.contrib.staticfiles', - 'raven.contrib.django.raven_compat', 'thunorweb.apps.ThunorConfig', 'custom_user', 'allauth', @@ -99,6 +115,7 @@ # MIDDLEWARE += ['debug_panel.middleware.DebugPanelMiddleware'] MIDDLEWARE += [ + 'allauth.account.middleware.AccountMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.http.ConditionalGetMiddleware', @@ -193,16 +210,6 @@ } -RAVEN_CONFIG = { - 'dsn': os.environ.get('DJANGO_SENTRY_DSN', None), - # If you are using git, you can also automatically configure the - # release based on the git info. - 'environment': os.environ.get('DJANGO_SENTRY_ENVIRONMENT', - 'development' if DEBUG else 'production'), - 'release': thunorweb.__version__, -} - - AUTH_USER_MODEL = 'custom_user.EmailUser' AUTHENTICATION_BACKENDS = ( # Needed to login by username in Django admin, regardless of `allauth` @@ -358,12 +365,6 @@ }, }, 'handlers': { - 'sentry': { - 'level': 'DEBUG' if DEBUG else 'INFO', - 'filters': ['require_debug_false'], - 'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler', - 'tags': {}, - }, 'console': { 'level': 'DEBUG', 'class': 'logging.StreamHandler', @@ -373,23 +374,13 @@ 'loggers': { 'root': { 'level': 'DEBUG' if DEBUG else 'INFO', - 'handlers': ['sentry'], + 'handlers': [], }, 'django.db.backends': { 'level': 'ERROR', 'handlers': ['console'], 'propagate': False, }, - 'raven': { - 'level': 'DEBUG', - 'handlers': ['console'], - 'propagate': False, - }, - 'sentry.errors': { - 'level': 'DEBUG', - 'handlers': ['console'], - 'propagate': False, - }, }, } diff --git a/thunordjango/wsgi.py b/thunordjango/wsgi.py index d46c37bb..a00b0f41 100644 --- a/thunordjango/wsgi.py +++ b/thunordjango/wsgi.py @@ -8,7 +8,6 @@ """ import os -from raven.contrib.django.raven_compat.middleware.wsgi import Sentry from django.core.wsgi import get_wsgi_application try: from uwsgidecorators import postfork @@ -18,7 +17,7 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "thunordjango.settings") -application = Sentry(get_wsgi_application()) +application = get_wsgi_application() @postfork def initialise(): diff --git a/thunorweb/plate_parsers.py b/thunorweb/plate_parsers.py index 092a7cef..51e0921b 100644 --- a/thunorweb/plate_parsers.py +++ b/thunorweb/plate_parsers.py @@ -478,7 +478,7 @@ def parse_platefile_synergy_neo(self, sep='\t'): plate = self._plate_objects.get(plate_name, None) # Each plate can have multiple assays - assays = re.split('\n\s*\n', barcode_and_rest[1]) + assays = re.split(r'\n\s*\n', barcode_and_rest[1]) for a in assays: a_strp = a.strip() diff --git a/thunorweb/templates/base-inner.html b/thunorweb/templates/base-inner.html index 265eecd3..d798ffe7 100644 --- a/thunorweb/templates/base-inner.html +++ b/thunorweb/templates/base-inner.html @@ -115,7 +115,7 @@ {% load webpack_loader %}{% get_files 'raven' 'js' as raven_js %} -