endoreg-db 0.8.4.0__py3-none-any.whl → 0.8.4.2__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/metadata/model_meta_logic.py +8 -1
- endoreg_db/services/video_import.py +10 -27
- {endoreg_db-0.8.4.0.dist-info → endoreg_db-0.8.4.2.dist-info}/METADATA +1 -1
- {endoreg_db-0.8.4.0.dist-info → endoreg_db-0.8.4.2.dist-info}/RECORD +6 -6
- {endoreg_db-0.8.4.0.dist-info → endoreg_db-0.8.4.2.dist-info}/WHEEL +0 -0
- {endoreg_db-0.8.4.0.dist-info → endoreg_db-0.8.4.2.dist-info}/licenses/LICENSE +0 -0
|
@@ -2,7 +2,7 @@ import shutil
|
|
|
2
2
|
from logging import getLogger
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
from typing import TYPE_CHECKING, Any, Optional, Type
|
|
5
|
-
|
|
5
|
+
from django.core.files import File
|
|
6
6
|
from django.db import transaction
|
|
7
7
|
from huggingface_hub import hf_hub_download
|
|
8
8
|
|
|
@@ -127,6 +127,8 @@ def create_from_file_logic(
|
|
|
127
127
|
logger.info(f"Copied weights from {source_weights_path} to {full_dest_path}")
|
|
128
128
|
except Exception as e:
|
|
129
129
|
raise IOError(f"Failed to copy weights file: {e}") from e
|
|
130
|
+
|
|
131
|
+
|
|
130
132
|
|
|
131
133
|
# --- Create/Update ModelMeta Instance ---
|
|
132
134
|
defaults = {
|
|
@@ -144,6 +146,11 @@ def create_from_file_logic(
|
|
|
144
146
|
version=target_version,
|
|
145
147
|
defaults=defaults,
|
|
146
148
|
)
|
|
149
|
+
|
|
150
|
+
with open(full_dest_path, "rb") as f:
|
|
151
|
+
model_meta.weights.save(relative_dest_path.name, File(f), save=False)
|
|
152
|
+
model_meta.save()
|
|
153
|
+
|
|
147
154
|
|
|
148
155
|
if created:
|
|
149
156
|
logger.info(f"Created new ModelMeta: {model_meta}")
|
|
@@ -18,6 +18,7 @@ from contextlib import contextmanager
|
|
|
18
18
|
from pathlib import Path
|
|
19
19
|
from typing import Union, Dict, Any, Optional, List, Tuple
|
|
20
20
|
from django.db import transaction
|
|
21
|
+
from lx_anonymizer import FrameCleaner
|
|
21
22
|
from moviepy import video
|
|
22
23
|
from endoreg_db.models import VideoFile, SensitiveMeta
|
|
23
24
|
from endoreg_db.utils.paths import STORAGE_DIR, VIDEO_DIR, ANONYM_VIDEO_DIR
|
|
@@ -55,18 +56,7 @@ class VideoImportService():
|
|
|
55
56
|
self.project_root = Path(__file__).parent.parent.parent.parent
|
|
56
57
|
|
|
57
58
|
# Track processed files to prevent duplicates
|
|
58
|
-
|
|
59
|
-
# Ensure anonym_video directory exists before listing files
|
|
60
|
-
anonym_video_dir = Path(ANONYM_VIDEO_DIR)
|
|
61
|
-
if anonym_video_dir.exists():
|
|
62
|
-
self.processed_files = set(str(anonym_video_dir / file) for file in os.listdir(ANONYM_VIDEO_DIR))
|
|
63
|
-
else:
|
|
64
|
-
logger.info(f"Creating anonym_videos directory: {anonym_video_dir}")
|
|
65
|
-
anonym_video_dir.mkdir(parents=True, exist_ok=True)
|
|
66
|
-
self.processed_files = set()
|
|
67
|
-
except Exception as e:
|
|
68
|
-
logger.warning(f"Failed to initialize processed files tracking: {e}")
|
|
69
|
-
self.processed_files = set()
|
|
59
|
+
self.processed_files = set(str(Path(ANONYM_VIDEO_DIR) / file) for file in os.listdir(ANONYM_VIDEO_DIR))
|
|
70
60
|
|
|
71
61
|
# Central video instance and processing context
|
|
72
62
|
self.current_video: Optional[VideoFile] = None
|
|
@@ -75,6 +65,8 @@ class VideoImportService():
|
|
|
75
65
|
self.delete_source = True
|
|
76
66
|
|
|
77
67
|
self.logger = logging.getLogger(__name__)
|
|
68
|
+
|
|
69
|
+
self.cleaner = None # This gets instantiated in the perform_frame_cleaning method
|
|
78
70
|
|
|
79
71
|
def _require_current_video(self) -> VideoFile:
|
|
80
72
|
"""Return the current VideoFile or raise if it has not been initialized."""
|
|
@@ -157,9 +149,6 @@ class VideoImportService():
|
|
|
157
149
|
High-level helper that orchestrates the complete video import and anonymization process.
|
|
158
150
|
Uses the central video instance pattern for improved state management.
|
|
159
151
|
"""
|
|
160
|
-
# DEFENSIVE: Initialize processing_context immediately to prevent KeyError crashes
|
|
161
|
-
self.processing_context = {'file_path': Path(file_path)}
|
|
162
|
-
|
|
163
152
|
try:
|
|
164
153
|
# Initialize processing context
|
|
165
154
|
self._initialize_processing_context(file_path, center_name, processor_name,
|
|
@@ -196,12 +185,7 @@ class VideoImportService():
|
|
|
196
185
|
return self.current_video
|
|
197
186
|
|
|
198
187
|
except Exception as e:
|
|
199
|
-
|
|
200
|
-
safe_file_path = getattr(self, 'processing_context', {}).get('file_path', file_path)
|
|
201
|
-
# Debug: Log context state for troubleshooting
|
|
202
|
-
context_keys = list(getattr(self, 'processing_context', {}).keys())
|
|
203
|
-
self.logger.debug(f"Context keys during error: {context_keys}")
|
|
204
|
-
self.logger.error(f"Video import and anonymization failed for {safe_file_path}: {e}")
|
|
188
|
+
self.logger.error(f"Video import and anonymization failed for {file_path}: {e}")
|
|
205
189
|
self._cleanup_on_error()
|
|
206
190
|
raise
|
|
207
191
|
finally:
|
|
@@ -840,7 +824,7 @@ class VideoImportService():
|
|
|
840
824
|
from lx_anonymizer import FrameCleaner # type: ignore[import]
|
|
841
825
|
|
|
842
826
|
if FrameCleaner:
|
|
843
|
-
return True, FrameCleaner
|
|
827
|
+
return True, FrameCleaner()
|
|
844
828
|
|
|
845
829
|
except Exception as e:
|
|
846
830
|
self.logger.warning(f"Frame cleaning not available: {e} Please install or update lx_anonymizer.")
|
|
@@ -869,10 +853,13 @@ class VideoImportService():
|
|
|
869
853
|
|
|
870
854
|
|
|
871
855
|
# Create temporary output path for cleaned video
|
|
872
|
-
video_filename = self.processing_context.get('video_filename', Path(raw_video_path).name)
|
|
856
|
+
video_filename = self.processing_context.get('video_filename', Path(raw_video_path).name if raw_video_path else "video.mp4")
|
|
873
857
|
cleaned_filename = f"cleaned_{video_filename}"
|
|
858
|
+
if not raw_video_path:
|
|
859
|
+
raise RuntimeError("raw_video_path is None after fallback, cannot construct cleaned_video_path")
|
|
874
860
|
cleaned_video_path = Path(raw_video_path).parent / cleaned_filename
|
|
875
861
|
|
|
862
|
+
|
|
876
863
|
|
|
877
864
|
|
|
878
865
|
# Clean video with ROI masking (heavy I/O operation)
|
|
@@ -988,10 +975,6 @@ class VideoImportService():
|
|
|
988
975
|
This method is always called in the finally block of import_and_anonymize()
|
|
989
976
|
to ensure the file lock is released even if processing fails.
|
|
990
977
|
"""
|
|
991
|
-
# DEFENSIVE: Ensure processing_context exists before accessing it
|
|
992
|
-
if not hasattr(self, 'processing_context'):
|
|
993
|
-
self.processing_context = {}
|
|
994
|
-
|
|
995
978
|
try:
|
|
996
979
|
# Release file lock if it was acquired
|
|
997
980
|
lock_context = self.processing_context.get('_lock_context')
|
|
@@ -464,7 +464,7 @@ endoreg_db/models/medical/risk/risk_type.py,sha256=kEugcaWSTEWH_Vxq4dcF80Iv1L4_K
|
|
|
464
464
|
endoreg_db/models/metadata/__init__.py,sha256=8I6oLj3YTmeaPGJpL0AWG5gLwp38QzrEggxSkTisv7c,474
|
|
465
465
|
endoreg_db/models/metadata/frame_ocr_result.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
466
466
|
endoreg_db/models/metadata/model_meta.py,sha256=F_r-PTLeNi4J-4EaGCQkGIguhdl7Bwba7_i56ZAjc-4,7589
|
|
467
|
-
endoreg_db/models/metadata/model_meta_logic.py,sha256=
|
|
467
|
+
endoreg_db/models/metadata/model_meta_logic.py,sha256=pcpKf9J5DUiEG-D-VhOPcnFjBznkx5jK7EGv0zDMQm8,12440
|
|
468
468
|
endoreg_db/models/metadata/pdf_meta.py,sha256=BTmpSgqxmPKi0apcNjyrZAS4AFKCPXVdBd6VBeyyv6E,3174
|
|
469
469
|
endoreg_db/models/metadata/sensitive_meta.py,sha256=ekLHrW-b5uYcjfkRd0EW5ncx5ef8Bu-K6msDkpWCAbk,13034
|
|
470
470
|
endoreg_db/models/metadata/sensitive_meta_logic.py,sha256=by3eCW8CgglK1SHiDOepHhTOGaugswxJhkH0BZp7-gs,33909
|
|
@@ -602,7 +602,7 @@ endoreg_db/services/pseudonym_service.py,sha256=CJhbtRa6K6SPbphgCZgEMi8AFQtB18CU
|
|
|
602
602
|
endoreg_db/services/requirements_object.py,sha256=290zf8AEbVtCoHhW4Jr7_ud-RvrqYmb1Nz9UBHtTnc0,6164
|
|
603
603
|
endoreg_db/services/segment_sync.py,sha256=YgHvIHkbW4mqCu0ACf3zjRSZnNfxWwt4gh5syUVXuE0,6400
|
|
604
604
|
endoreg_db/services/storage_aware_video_processor.py,sha256=kKFK64vXLeBSVkp1YJonU3gFDTeXZ8C4qb9QZZB99SE,13420
|
|
605
|
-
endoreg_db/services/video_import.py,sha256=
|
|
605
|
+
endoreg_db/services/video_import.py,sha256=0eeY5etJ4rg6uxC-uUis_yoa6cvGgwY2VaiD3mVFosg,46369
|
|
606
606
|
endoreg_db/tasks/upload_tasks.py,sha256=OJq7DhNwcbWdXzHY8jz5c51BCVkPN5gSWOz-6Fx6W5M,7799
|
|
607
607
|
endoreg_db/tasks/video_ingest.py,sha256=kxFuYkHijINV0VabQKCFVpJRv6eCAw07tviONurDgg8,5265
|
|
608
608
|
endoreg_db/tasks/video_processing_tasks.py,sha256=rZ7Kr49bAR4Q-vALO2SURebrhcJ5hSFGwjF4aULrOao,14089
|
|
@@ -786,7 +786,7 @@ endoreg_db/views/video/video_meta.py,sha256=C1wBMTtQb_yzEUrhFGAy2UHEWMk_CbU75WXX
|
|
|
786
786
|
endoreg_db/views/video/video_processing_history.py,sha256=mhFuS8RG5GV8E-lTtuD0qrq-bIpnUFp8vy9aERfC-J8,770
|
|
787
787
|
endoreg_db/views/video/video_remove_frames.py,sha256=2FmvNrSPM0fUXiBxINN6vBUUDCqDlBkNcGR3WsLDgKo,1696
|
|
788
788
|
endoreg_db/views/video/video_stream.py,sha256=kLyuf0ORTmsLeYUQkTQ6iRYqlIQozWhMMR3Lhfe_trk,12148
|
|
789
|
-
endoreg_db-0.8.4.
|
|
790
|
-
endoreg_db-0.8.4.
|
|
791
|
-
endoreg_db-0.8.4.
|
|
792
|
-
endoreg_db-0.8.4.
|
|
789
|
+
endoreg_db-0.8.4.2.dist-info/METADATA,sha256=xSaPMvzzc7HovOmkl2Gn0lYVoRNTPk4yqIBFcz0kc70,14758
|
|
790
|
+
endoreg_db-0.8.4.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
791
|
+
endoreg_db-0.8.4.2.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
792
|
+
endoreg_db-0.8.4.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|