endoreg-db 0.8.4.8__py3-none-any.whl → 0.8.4.9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of endoreg-db might be problematic. Click here for more details.
- endoreg_db/models/media/video/video_file.py +24 -38
- endoreg_db/services/video_import.py +29 -16
- {endoreg_db-0.8.4.8.dist-info → endoreg_db-0.8.4.9.dist-info}/METADATA +1 -1
- {endoreg_db-0.8.4.8.dist-info → endoreg_db-0.8.4.9.dist-info}/RECORD +6 -6
- {endoreg_db-0.8.4.8.dist-info → endoreg_db-0.8.4.9.dist-info}/WHEEL +0 -0
- {endoreg_db-0.8.4.8.dist-info → endoreg_db-0.8.4.9.dist-info}/licenses/LICENSE +0 -0
|
@@ -4,6 +4,7 @@ import logging
|
|
|
4
4
|
from pathlib import Path
|
|
5
5
|
import uuid
|
|
6
6
|
from typing import TYPE_CHECKING, Optional, Union, cast
|
|
7
|
+
import os
|
|
7
8
|
|
|
8
9
|
from django.db import models
|
|
9
10
|
from django.core.files import File
|
|
@@ -208,46 +209,25 @@ class VideoFile(models.Model):
|
|
|
208
209
|
return ffmpeg_meta
|
|
209
210
|
|
|
210
211
|
|
|
212
|
+
# Exception message constants
|
|
213
|
+
NO_ACTIVE_FILE = "Has no raw file"
|
|
214
|
+
NO_FILE_ASSOCIATED = "Active file has no associated file."
|
|
215
|
+
|
|
211
216
|
@property
|
|
212
|
-
def
|
|
213
|
-
"""
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
str: The URL of the active video file.
|
|
218
|
-
|
|
219
|
-
Raises:
|
|
220
|
-
Value Error if no active VideoFile is available.
|
|
221
|
-
"""
|
|
222
|
-
active = self.active_file
|
|
223
|
-
if not isinstance(active, FieldFile):
|
|
224
|
-
raise ValueError("Active file is not a stored FieldFile instance.")
|
|
225
|
-
if not active.name:
|
|
226
|
-
raise ValueError("Active file has no associated name.")
|
|
227
|
-
return active.url
|
|
228
|
-
|
|
229
|
-
@property
|
|
230
|
-
def active_raw_file(self) -> FieldFile:
|
|
231
|
-
raw = self.raw_file
|
|
232
|
-
if isinstance(raw, FieldFile) and raw.name:
|
|
233
|
-
return raw
|
|
234
|
-
raise ValueError("No raw file available for this video")
|
|
235
|
-
|
|
236
|
-
@property
|
|
237
|
-
def active_raw_file_url(self)-> str:
|
|
238
|
-
"""
|
|
239
|
-
Return the path of the URL of the active raw file for name reading.
|
|
217
|
+
def active_raw_file(self) -> File:
|
|
218
|
+
"""Return the raw file if available, otherwise raise ValueError."""
|
|
219
|
+
if self.has_raw:
|
|
220
|
+
return self.raw_file
|
|
221
|
+
raise ValueError(self.NO_ACTIVE_FILE)
|
|
240
222
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
return raw.url
|
|
250
|
-
|
|
223
|
+
@property
|
|
224
|
+
def active_raw_file_url(self) -> str:
|
|
225
|
+
"""Return the URL of the active raw file, or raise ValueError if unavailable."""
|
|
226
|
+
_file = self.active_raw_file
|
|
227
|
+
assert _file is not None, self.NO_ACTIVE_FILE
|
|
228
|
+
if not _file or not _file.name:
|
|
229
|
+
raise ValueError(self.NO_FILE_ASSOCIATED)
|
|
230
|
+
return _file.url
|
|
251
231
|
|
|
252
232
|
# Pipeline Functions
|
|
253
233
|
pipe_1 = _pipe_1
|
|
@@ -414,6 +394,12 @@ class VideoFile(models.Model):
|
|
|
414
394
|
if isinstance(file_path, str):
|
|
415
395
|
file_path = Path(file_path)
|
|
416
396
|
# Pass center_name and other kwargs to the helper function
|
|
397
|
+
if not center_name:
|
|
398
|
+
try:
|
|
399
|
+
center_name = os.environ["CENTER_NAME"]
|
|
400
|
+
except KeyError:
|
|
401
|
+
logger.error("Center name must be provided to create VideoFile from file. You can set CENTER_NAME in environment variables.")
|
|
402
|
+
return None
|
|
417
403
|
return _create_from_file(cls, file_path, center_name=center_name, **kwargs)
|
|
418
404
|
|
|
419
405
|
@classmethod
|
|
@@ -11,23 +11,26 @@ Changelog:
|
|
|
11
11
|
|
|
12
12
|
from datetime import date
|
|
13
13
|
import logging
|
|
14
|
-
import sys
|
|
15
14
|
import os
|
|
15
|
+
import random
|
|
16
16
|
import shutil
|
|
17
|
+
import sys
|
|
17
18
|
import time
|
|
18
19
|
from contextlib import contextmanager
|
|
20
|
+
from datetime import date
|
|
19
21
|
from pathlib import Path
|
|
20
|
-
from typing import
|
|
22
|
+
from typing import Any, Dict, List, Optional, Tuple, Union
|
|
23
|
+
|
|
21
24
|
from django.db import transaction
|
|
25
|
+
from django.db.models.fields.files import FieldFile
|
|
22
26
|
from lx_anonymizer import FrameCleaner
|
|
23
27
|
from moviepy import video
|
|
24
|
-
|
|
25
|
-
from endoreg_db.
|
|
26
|
-
import
|
|
28
|
+
|
|
29
|
+
from endoreg_db.models import EndoscopyProcessor, SensitiveMeta, VideoFile
|
|
30
|
+
from endoreg_db.models.media.video.video_file_anonymize import \
|
|
31
|
+
_cleanup_raw_assets
|
|
27
32
|
from endoreg_db.utils.hashs import get_video_hash
|
|
28
|
-
from endoreg_db.
|
|
29
|
-
from django.db.models.fields.files import FieldFile
|
|
30
|
-
from endoreg_db.models import EndoscopyProcessor
|
|
33
|
+
from endoreg_db.utils.paths import ANONYM_VIDEO_DIR, STORAGE_DIR, VIDEO_DIR
|
|
31
34
|
|
|
32
35
|
# File lock configuration (matches PDF import)
|
|
33
36
|
STALE_LOCK_SECONDS = 6000 # 100 minutes - reclaim locks older than this
|
|
@@ -895,20 +898,30 @@ class VideoImportService:
|
|
|
895
898
|
|
|
896
899
|
sm = sensitive_meta
|
|
897
900
|
updated_fields = []
|
|
898
|
-
|
|
901
|
+
|
|
902
|
+
# Ensure center is set from video.center if not in extracted_metadata
|
|
903
|
+
metadata_to_update = extracted_metadata.copy()
|
|
904
|
+
if 'center_name' not in metadata_to_update and video.center:
|
|
905
|
+
metadata_to_update['center_name'] = video.center.name
|
|
906
|
+
self.logger.debug("Added center_name '%s' to metadata for SensitiveMeta update", video.center.name)
|
|
907
|
+
|
|
899
908
|
try:
|
|
900
|
-
sm.update_from_dict(
|
|
901
|
-
updated_fields = list(extracted_metadata.keys())
|
|
909
|
+
sm.update_from_dict(metadata_to_update)
|
|
910
|
+
updated_fields = list(extracted_metadata.keys()) # Only log originally extracted fields
|
|
902
911
|
except KeyError as e:
|
|
903
912
|
self.logger.warning(f"Failed to update SensitiveMeta field {e}")
|
|
904
913
|
|
|
905
914
|
if updated_fields:
|
|
906
|
-
|
|
907
|
-
|
|
915
|
+
try:
|
|
916
|
+
sm.save() # Remove update_fields to allow all necessary fields to be saved
|
|
917
|
+
self.logger.info("Updated SensitiveMeta fields for video %s: %s", video.uuid, updated_fields)
|
|
908
918
|
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
919
|
+
state = video.get_or_create_state()
|
|
920
|
+
state.mark_sensitive_meta_processed(save=True)
|
|
921
|
+
self.logger.info("Marked sensitive metadata as processed for video %s", video.uuid)
|
|
922
|
+
except Exception as e:
|
|
923
|
+
self.logger.error(f"Failed to save SensitiveMeta: {e}")
|
|
924
|
+
raise # Re-raise to trigger fallback in calling method
|
|
912
925
|
else:
|
|
913
926
|
self.logger.info("No SensitiveMeta fields updated for video %s - all existing values preserved", video.uuid)
|
|
914
927
|
|
|
@@ -390,7 +390,7 @@ endoreg_db/models/media/video/create_from_file.py,sha256=3n4bbzFteEOFDUuEikP0x-S
|
|
|
390
390
|
endoreg_db/models/media/video/pipe_1.py,sha256=ljO3vO2mqqTXLZsKjzMTC6-sW4JRWMVRfJcK0n5CjKg,9740
|
|
391
391
|
endoreg_db/models/media/video/pipe_2.py,sha256=DnMxW0uOqSsf7-0n9Rlvn7u89U4Jpkv7n6hFpQfUjkQ,4964
|
|
392
392
|
endoreg_db/models/media/video/refactor_plan.md,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
393
|
-
endoreg_db/models/media/video/video_file.py,sha256=
|
|
393
|
+
endoreg_db/models/media/video/video_file.py,sha256=XYF0uhA4VjfGu3w7CsFWt0pdkbMzbGkjzBE2s--ZrPY,26604
|
|
394
394
|
endoreg_db/models/media/video/video_file_ai.py,sha256=3ABea52FOF1qlrlxHdYhz_M3Kmqfzqtgq7M0prl-FAo,18819
|
|
395
395
|
endoreg_db/models/media/video/video_file_anonymize.py,sha256=pet1UfSsbSHJJZxq6gDPifAfBWpGyEpD1jEQuSQi0Gg,16027
|
|
396
396
|
endoreg_db/models/media/video/video_file_frames.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -603,7 +603,7 @@ endoreg_db/services/pseudonym_service.py,sha256=CJhbtRa6K6SPbphgCZgEMi8AFQtB18CU
|
|
|
603
603
|
endoreg_db/services/requirements_object.py,sha256=290zf8AEbVtCoHhW4Jr7_ud-RvrqYmb1Nz9UBHtTnc0,6164
|
|
604
604
|
endoreg_db/services/segment_sync.py,sha256=YgHvIHkbW4mqCu0ACf3zjRSZnNfxWwt4gh5syUVXuE0,6400
|
|
605
605
|
endoreg_db/services/storage_aware_video_processor.py,sha256=kKFK64vXLeBSVkp1YJonU3gFDTeXZ8C4qb9QZZB99SE,13420
|
|
606
|
-
endoreg_db/services/video_import.py,sha256=
|
|
606
|
+
endoreg_db/services/video_import.py,sha256=jPwf341PBQjiH_8dy6L7m2v-v6awKIjBRpCW6SzolaE,47210
|
|
607
607
|
endoreg_db/tasks/upload_tasks.py,sha256=OJq7DhNwcbWdXzHY8jz5c51BCVkPN5gSWOz-6Fx6W5M,7799
|
|
608
608
|
endoreg_db/tasks/video_ingest.py,sha256=kxFuYkHijINV0VabQKCFVpJRv6eCAw07tviONurDgg8,5265
|
|
609
609
|
endoreg_db/tasks/video_processing_tasks.py,sha256=rZ7Kr49bAR4Q-vALO2SURebrhcJ5hSFGwjF4aULrOao,14089
|
|
@@ -788,7 +788,7 @@ endoreg_db/views/video/video_meta.py,sha256=C1wBMTtQb_yzEUrhFGAy2UHEWMk_CbU75WXX
|
|
|
788
788
|
endoreg_db/views/video/video_processing_history.py,sha256=mhFuS8RG5GV8E-lTtuD0qrq-bIpnUFp8vy9aERfC-J8,770
|
|
789
789
|
endoreg_db/views/video/video_remove_frames.py,sha256=2FmvNrSPM0fUXiBxINN6vBUUDCqDlBkNcGR3WsLDgKo,1696
|
|
790
790
|
endoreg_db/views/video/video_stream.py,sha256=kLyuf0ORTmsLeYUQkTQ6iRYqlIQozWhMMR3Lhfe_trk,12148
|
|
791
|
-
endoreg_db-0.8.4.
|
|
792
|
-
endoreg_db-0.8.4.
|
|
793
|
-
endoreg_db-0.8.4.
|
|
794
|
-
endoreg_db-0.8.4.
|
|
791
|
+
endoreg_db-0.8.4.9.dist-info/METADATA,sha256=BpXbY49BtPAkdq0FRu815L7JElNzpYmA3PmlgnoCf-Q,14719
|
|
792
|
+
endoreg_db-0.8.4.9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
793
|
+
endoreg_db-0.8.4.9.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
794
|
+
endoreg_db-0.8.4.9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|