From 46518a45c17304179a73d20aa8792d2cccbe245b Mon Sep 17 00:00:00 2001 From: Ross Date: Wed, 3 Jun 2026 20:26:12 +0100 Subject: [PATCH] add log when improt fails --- atlas/views.py | 1 + todo | 133 +++++++++++++++++++++++++++---------------------- 2 files changed, 74 insertions(+), 60 deletions(-) diff --git a/atlas/views.py b/atlas/views.py index 2e5040ba..e0bc70f9 100755 --- a/atlas/views.py +++ b/atlas/views.py @@ -3575,6 +3575,7 @@ def uploads_import_htmx(request, case_id: int | None = None): imported = import_dicoms_helper(request, case_id=case_id, dicoms=dicoms) except Exception as exc: + logger.exception("Error during uploads import") return HttpResponse( f'
Import failed: {escape(str(exc))}
', status=500, diff --git a/todo b/todo index 65de291a..73af8588 100644 --- a/todo +++ b/todo @@ -1,67 +1,80 @@ +on the case details page when mananging series clicking on a select button launches the series popup when it shouldn't. -on the condition details pages we should have an easier way to set parents and children +when building the series / stack description for the dv3d viewer we should take into account the plane and contrast if they are defined on the series model. -the casecollection form should use a widget for the prerequisites that supports autocomplete searching to allow for easy case selection. the selection options should be restricted to those cases that the user is an author of. +when importing cases we currently get the following error: +web-1 | 2026-06-03 20:20:04.612 | ERROR | atlas.views:uploads_import_htmx:3578 - Error during uploads import +web-1 | Traceback (most recent call last): +web-1 | File "/usr/src/app/atlas/views.py", line 3576, in uploads_import_htmx +web-1 | imported = import_dicoms_helper(request, case_id=case_id, dicoms=dicoms) +web-1 | File "/usr/src/app/atlas/api.py", line 280, in import_dicoms_helper +web-1 | series_image.save() +web-1 | File "/usr/src/app/generic/models.py", line 390, in save +web-1 | super().save(*args, **kwargs) # Call the "real" save() method. +web-1 | File "/opt/venv/lib/python3.14/site-packages/django/db/models/base.py", line 874, in save +web-1 | self.save_base( +web-1 | File "/opt/venv/lib/python3.14/site-packages/django/db/models/base.py", line 981, in save_base +web-1 | post_save.send( +web-1 | File "/opt/venv/lib/python3.14/site-packages/django/dispatch/dispatcher.py", line 209, in send +web-1 | response = receiver(signal=self, sender=sender, **named) +web-1 | File "/usr/src/app/atlas/models.py", line 1382, in _populate_case_study_date_on_series_image_save +web-1 | tags = instance.basic_dicom_tags or {} +web-1 | AttributeError: 'SeriesImage' object has no attribute 'basic_dicom_tags' +web-1 | Internal Server Error: /atlas/uploads/import/case/241 -if a user has multiple uploads from the same patient waiting to be imported on the uploads page and more than one study in selected to import we should be able to import them and automatically create a set of cases with appropriate case series relations (by setting the model previous_case field appropriately). the workflow should be, multiple studies are selected -> enable the import into cases series button. clicking this should open a dialog that allows a user to set the fields from the CaseForm that will be duplicated across the series. a button at the bottoms should trigger the creation of the cases and import the series appropriately. +please add a unit test that demostrates the failure and then fix the bug and confirm that the unit test then passes. +please also check why when I add the + logger.exception("Error during uploads import") +error in production this does not seem to get shown anywhere. The only log just showed + ERROR 03/Jun/2026 11:52:50 django.request:249 +Internal Server Error: /atlas/uploads/import +the online local settings are +DEBUG = False +INTERNAL_IPS = ["82.69.88.125", "217.155.198.96"] +#SECURE_SSL_REDIRECT = False +#SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'http') +#REMOTE_URL = "http://46.101.13.46:8123" +# +#MEDIA_ROOT = '/home/django/rad/media/' +STATIC_ROOT = '/home/ross/web/static/' -when opening the series detail page we get the following error: web-1 | [28/May/2026 22:24:52] "GET /atlas/series/936 HTTP/1.0" 500 158244 -web-1 | /opt/venv/lib/python3.14/site-packages/pydicom/dataset.py:589: UserWarning: Invalid value 'DiffusionGradientDirection' used with the 'in' operator: must be an element tag as a 2-tuple or int, or an element keyword -web-1 | warn_and_log(msg) +#EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' +EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend" -we also get the following error when trying to view cases (in dev at least): -MemcacheError at /atlas/case/238/ +if not DEBUG: + LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'formatters': { + 'verbose': { + 'format' : "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s", + 'datefmt' : "%d/%b/%Y %H:%M:%S" + }, + 'simple': { + 'format': '%(levelname)s %(message)s' + }, + }, + 'handlers': { + 'file': { + 'level': 'DEBUG', + 'class': 'logging.FileHandler', + 'filename': 'log.txt', + 'formatter': 'verbose' + }, + }, + 'loggers': { + 'django': { + 'handlers':['file'], + 'propagate': True, + 'level':'DEBUG', + }, + 'atlas': { + 'handlers': ['file'], + 'level': 'DEBUG', + }, + #"django.core.mail": {"handlers": ["console"], "level": "DEBUG", "propagate": False}, + #"smtplib": {"handlers": ["console"], "level": "DEBUG", "propagate": False}, + } + } -All servers seem to be down right now - -Request Method: GET -Request URL: http://127.0.0.1/atlas/case/238/ -Django Version: 6.0.1 -Exception Type: MemcacheError -Exception Value: - -All servers seem to be down right now - -Exception Location: /opt/venv/lib/python3.14/site-packages/pymemcache/client/hash.py, line 182, in _get_client -Raised during: atlas.decorators.case_detail -Python Executable: /opt/venv/bin/python -Python Version: 3.14.5 -Python Path: - -['/usr/src/app', - '/usr/src/app', - '/usr/local/lib/python314.zip', - '/usr/local/lib/python3.14', - '/usr/local/lib/python3.14/lib-dynload', - '/opt/venv/lib/python3.14/site-packages'] - -Server time: Thu, 28 May 2026 22:28:21 +0100 -Error during template rendering - -In template /usr/src/app/atlas/templates/atlas/case_display_block.html, error at line 528 -All servers seem to be down right now -518 -519 -520 -521 -522
-523 Viewer -524 -525
-530
-531
-532 -533 Series -534 -535 {{ ordered_series|length }} total -536