From 00a62292a01a0ed9f7ab274fb03caec8cca96365 Mon Sep 17 00:00:00 2001 From: Utz Ermel Date: Sun, 6 Jul 2025 10:56:50 -0700 Subject: [PATCH] remove excessive debug messages. --- pyproject.toml | 4 +- src/copick_shared_ui/core/image_interface.py | 3 -- src/copick_shared_ui/core/thumbnail_cache.py | 20 ---------- .../platform/napari_integration.py | 3 -- .../widgets/gallery/gallery_widget.py | 6 --- .../widgets/info/info_widget.py | 10 ----- src/copick_shared_ui/workers/base.py | 29 +-------------- src/copick_shared_ui/workers/base_manager.py | 14 ------- src/copick_shared_ui/workers/chimerax.py | 23 +----------- src/copick_shared_ui/workers/data_worker.py | 3 -- src/copick_shared_ui/workers/napari.py | 37 +------------------ 11 files changed, 6 insertions(+), 146 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 96bf85d..89c87eb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,8 +26,8 @@ dynamic = ["version"] dependencies = [ "qtpy", "pydantic>=2", - "copick>=1.5.0", - "zarr>=2.10.0", + "copick[all]>=1.5.0", + "zarr<3", "numpy>=1.21.0", ] authors = [ diff --git a/src/copick_shared_ui/core/image_interface.py b/src/copick_shared_ui/core/image_interface.py index 90f8be3..55b2a6b 100644 --- a/src/copick_shared_ui/core/image_interface.py +++ b/src/copick_shared_ui/core/image_interface.py @@ -22,7 +22,6 @@ def _setup_qt(self) -> None: self._QPixmap = QPixmap self._qt_available = True - print("๐ŸŽจ Using qtpy for image interface") except ImportError: try: # Fall back to Qt (ChimeraX) @@ -30,9 +29,7 @@ def _setup_qt(self) -> None: self._QPixmap = QPixmap self._qt_available = True - print("๐ŸŽจ Using Qt for image interface") except ImportError: - print("โŒ Neither qtpy nor Qt available for image interface") self._qt_available = False def save_image(self, image: Any, path: str, format: str = "PNG") -> bool: diff --git a/src/copick_shared_ui/core/thumbnail_cache.py b/src/copick_shared_ui/core/thumbnail_cache.py index b4d7a32..ec57e2f 100644 --- a/src/copick_shared_ui/core/thumbnail_cache.py +++ b/src/copick_shared_ui/core/thumbnail_cache.py @@ -98,7 +98,6 @@ def _setup_cache_directory(self) -> None: # Create the cache directory if it doesn't exist self.cache_dir.mkdir(parents=True, exist_ok=True) - print(f"๐Ÿ“ Thumbnail cache directory: {self.cache_dir}") # Create metadata file if it doesn't exist self._ensure_metadata_file() @@ -186,7 +185,6 @@ def has_thumbnail(self, cache_key: str) -> bool: """ thumbnail_path = self.get_thumbnail_path(cache_key) exists = thumbnail_path.exists() - # Uncomment for debugging: print(f"CACHE DEBUG: Checking cache for key '{cache_key}' at {thumbnail_path} -> {'EXISTS' if exists else 'NOT FOUND'}") return exists def save_thumbnail(self, cache_key: str, image: Any) -> bool: @@ -206,10 +204,6 @@ def save_thumbnail(self, cache_key: str, image: Any) -> bool: try: thumbnail_path = self.get_thumbnail_path(cache_key) success = self._image_interface.save_image(image, str(thumbnail_path), "PNG") - if success: - print(f"๐Ÿ’พ Saved thumbnail to: {thumbnail_path}") - else: - print(f"โŒ Failed to save thumbnail to: {thumbnail_path}") return success except Exception as e: print(f"Error saving thumbnail to cache: {e}") @@ -231,11 +225,8 @@ def load_thumbnail(self, cache_key: str) -> Optional[Any]: try: thumbnail_path = self.get_thumbnail_path(cache_key) if thumbnail_path.exists(): - print(f"๐Ÿ“ฆ Loading cached thumbnail from: {thumbnail_path}") image = self._image_interface.load_image(str(thumbnail_path)) return image if image and self._image_interface.is_valid_image(image) else None - else: - print(f"๐Ÿ” No cached thumbnail found at: {thumbnail_path}") return None except Exception as e: print(f"Error loading thumbnail from cache: {e}") @@ -266,18 +257,10 @@ def _cleanup_old_cache_entries(self, max_age_days: int = 14) -> None: if age_seconds > max_age_seconds: thumbnail_file.unlink() removed_count += 1 - print( - f"๐Ÿ—‘๏ธ Removed old cache entry: {thumbnail_file.name} (age: {age_seconds / (24 * 60 * 60):.1f} days)", - ) except Exception as e: print(f"Warning: Could not process cache file {thumbnail_file}: {e}") - if removed_count > 0: - print(f"๐Ÿงน Cache cleanup: Removed {removed_count} old entries (older than {max_age_days} days)") - else: - print(f"โœ… Cache cleanup: No entries older than {max_age_days} days found") - except Exception as e: print(f"Warning: Cache cleanup failed: {e}") @@ -290,11 +273,8 @@ def clear_cache(self) -> bool: try: if self.cache_dir and self.cache_dir.exists(): # Remove all PNG files (thumbnails) but keep metadata - removed_count = 0 for thumbnail_file in self.cache_dir.glob("*.png"): thumbnail_file.unlink() - removed_count += 1 - print(f"๐Ÿงน Manually cleared {removed_count} thumbnails from cache") return True return False except Exception as e: diff --git a/src/copick_shared_ui/platform/napari_integration.py b/src/copick_shared_ui/platform/napari_integration.py index 1d1b18e..a0ee74e 100644 --- a/src/copick_shared_ui/platform/napari_integration.py +++ b/src/copick_shared_ui/platform/napari_integration.py @@ -76,7 +76,6 @@ def _detect_napari_theme(self) -> str: """Detect theme from napari viewer.""" try: napari_theme = str(self.viewer.theme) - print(f"๐ŸŽจ Detected napari theme: '{napari_theme}'") # Map napari themes to our theme system if napari_theme.lower() == "light": @@ -85,7 +84,6 @@ def _detect_napari_theme(self) -> str: return "dark" else: # For custom themes or unknown themes, default to dark - print(f"๐ŸŽจ Unknown napari theme '{napari_theme}', defaulting to dark") return "dark" except Exception as e: @@ -121,7 +119,6 @@ def connect_theme_changed(self, callback: Callable[[], None]) -> None: try: # Connect to napari's theme change events self.viewer.events.theme.connect(lambda event: callback()) - print("๐Ÿ”— Connected to napari theme change events") except Exception as e: print(f"โš ๏ธ Could not connect to napari theme events: {e}") # Fallback: periodically check theme changes diff --git a/src/copick_shared_ui/widgets/gallery/gallery_widget.py b/src/copick_shared_ui/widgets/gallery/gallery_widget.py index 93fe109..2bac696 100644 --- a/src/copick_shared_ui/widgets/gallery/gallery_widget.py +++ b/src/copick_shared_ui/widgets/gallery/gallery_widget.py @@ -124,8 +124,6 @@ def delete(self) -> None: def set_copick_root(self, copick_root: Optional[Any]) -> None: """Set the copick root and load runs.""" - print(f"๐Ÿ”„ Gallery: Setting copick root: {copick_root}") - # Clear workers to cancel any pending thumbnail loads from previous session self.worker_interface.clear_workers() @@ -139,7 +137,6 @@ def set_copick_root(self, copick_root: Optional[Any]) -> None: if copick_root: self.runs = list(copick_root.runs) self.filtered_runs = self.runs.copy() - print(f"๐Ÿ“‚ Gallery: Found {len(self.runs)} runs: {[run.name for run in self.runs]}") self._update_grid() else: self.runs = [] @@ -244,7 +241,6 @@ def _load_run_thumbnail(self, run: "CopickRun", thumbnail_id: str, force_regener if self._is_destroyed: return - print(f"๐ŸŽจ Gallery: Starting thumbnail load for run '{thumbnail_id}' (force={force_regenerate})") self.worker_interface.start_thumbnail_worker(run, thumbnail_id, self._on_thumbnail_loaded, force_regenerate) def _on_thumbnail_loaded(self, thumbnail_id: str, pixmap: Optional[Any], error: Optional[str]) -> None: @@ -258,10 +254,8 @@ def _on_thumbnail_loaded(self, thumbnail_id: str, pixmap: Optional[Any], error: card = self.all_run_cards[thumbnail_id] if error: - print(f"โŒ Gallery: Thumbnail error for '{thumbnail_id}': {error}") card.set_error(error) else: - print(f"โœ… Gallery: Thumbnail loaded for '{thumbnail_id}': {pixmap is not None}") card.set_thumbnail(pixmap) # Cache the thumbnail for future use if pixmap: diff --git a/src/copick_shared_ui/widgets/info/info_widget.py b/src/copick_shared_ui/widgets/info/info_widget.py index 519a44f..7e45cfd 100644 --- a/src/copick_shared_ui/widgets/info/info_widget.py +++ b/src/copick_shared_ui/widgets/info/info_widget.py @@ -219,7 +219,6 @@ def set_run(self, run: Optional["CopickRun"]) -> None: if self._is_destroyed: return - print(f"CopickInfoWidget.set_run called with run: {run.name if run else 'None'}") self.current_run = run if run: self.current_run_name = run.name @@ -235,7 +234,6 @@ def set_run(self, run: Optional["CopickRun"]) -> None: self._loading_states.clear() self._update_display() - print(f"CopickInfoWidget.set_run completed for run: {run.name if run else 'None'}") def _start_async_loading(self) -> None: """Start asynchronous loading of all run data.""" @@ -255,8 +253,6 @@ def _start_data_loading_worker(self, data_type: str) -> None: if not self.current_run or self._is_destroyed: return - print(f"๐Ÿš€ InfoWidget: Starting threaded data loading for '{data_type}'") - # Use the worker interface to start threaded data loading self.worker_interface.start_data_worker( run=self.current_run, @@ -266,10 +262,6 @@ def _start_data_loading_worker(self, data_type: str) -> None: def _handle_data_loaded(self, data_type: str, data: Optional[List[Any]], error: Optional[str]) -> None: """Handle data loading completion.""" - print( - f"๐Ÿ“ฅ InfoWidget: _handle_data_loaded called for '{data_type}' - error: {error}, data count: {len(data) if data else 0}", - ) - if self._is_destroyed: print(f"โš ๏ธ InfoWidget: Widget destroyed, ignoring data for '{data_type}'") return @@ -278,12 +270,10 @@ def _handle_data_loaded(self, data_type: str, data: Optional[List[Any]], error: print(f"โŒ InfoWidget: Error loading '{data_type}': {error}") self._loading_states[data_type] = f"error: {error}" else: - print(f"โœ… InfoWidget: Successfully loaded {len(data) if data else 0} '{data_type}' items") self._loading_states[data_type] = "loaded" self._loaded_data[data_type] = data or [] # Update display - print(f"๐Ÿ”„ InfoWidget: Calling _update_display for '{data_type}'") self._update_display() @Slot() diff --git a/src/copick_shared_ui/workers/base.py b/src/copick_shared_ui/workers/base.py index 612f2ce..1d4a05f 100644 --- a/src/copick_shared_ui/workers/base.py +++ b/src/copick_shared_ui/workers/base.py @@ -77,10 +77,8 @@ def _select_best_tomogram(self, run: "CopickRun") -> Optional["CopickTomogram"]: if cache_key in self._best_tomogram_cache: cached_result = self._best_tomogram_cache[cache_key] if cached_result is not None: - print(f"๐ŸŽฏ Using cached best tomogram selection for run '{run.name}'") return cached_result - print(f"๐Ÿ” Selecting best tomogram for run '{run.name}'") try: all_tomograms = [] @@ -107,21 +105,18 @@ def _select_best_tomogram(self, run: "CopickRun") -> Optional["CopickTomogram"]: for preferred_type in preferred_types: for tomo in vs_tomograms: if preferred_type.lower() in tomo.tomo_type.lower(): - print(f"โœ… Selected best tomogram: {tomo.tomo_type} at {vs_size}ร…") self._best_tomogram_cache[cache_key] = tomo return tomo # If no preferred type found, return the first tomogram at this voxel spacing if vs_tomograms: selected = vs_tomograms[0] - print(f"โœ… Selected fallback tomogram: {selected.tomo_type} at {vs_size}ร…") self._best_tomogram_cache[cache_key] = selected return selected # Final fallback: return any tomogram if all_tomograms: selected = all_tomograms[0] - print(f"โœ… Selected final fallback tomogram: {selected.tomo_type}") self._best_tomogram_cache[cache_key] = selected return selected @@ -139,12 +134,8 @@ def generate_thumbnail_pixmap(self) -> tuple[Optional[Any], Optional[str]]: if not self.force_regenerate and self._cache and self._cache_key and self._cache.has_thumbnail(self._cache_key): cached_pixmap = self._cache.load_thumbnail(self._cache_key) if cached_pixmap is not None: - print(f"๐Ÿ“ฆ Using cached thumbnail for '{self.thumbnail_id}'") return cached_pixmap, None - # Generate new thumbnail - print(f"๐ŸŽจ Generating new thumbnail for '{self.thumbnail_id}'") - # Determine the tomogram to use if self._is_tomogram(): tomogram = self.item @@ -184,11 +175,7 @@ def generate_thumbnail_pixmap(self) -> tuple[Optional[Any], Optional[str]]: # Cache the result if self._cache and self._cache_key: try: - success = self._cache.save_thumbnail(self._cache_key, pixmap) - if success: - print(f"๐Ÿ’พ Cached thumbnail for '{self.thumbnail_id}'") - else: - print(f"โš ๏ธ Failed to cache thumbnail for '{self.thumbnail_id}'") + _ = self._cache.save_thumbnail(self._cache_key, pixmap) except Exception as e: print(f"โš ๏ธ Error caching thumbnail: {e}") @@ -205,8 +192,6 @@ def _generate_thumbnail_array(self, tomogram: "CopickTomogram") -> Optional[Any] import numpy as np import zarr - print(f"๐Ÿ”ง Loading zarr data for tomogram: {tomogram.tomo_type}") - # Load tomogram data - handle multi-scale zarr properly zarr_group = zarr.open(tomogram.zarr(), mode="r") @@ -218,18 +203,13 @@ def _generate_thumbnail_array(self, tomogram: "CopickTomogram") -> Optional[Any] # Use the highest scale level (most binned/smallest) for thumbnails highest_scale = scale_levels[-1] # Last element is highest number = most binned tomo_data = zarr_group[highest_scale] - print(f"๐Ÿ”ง Using highest binning scale level {highest_scale} from multi-scale zarr for thumbnail") else: # Fallback to first key first_key = list(zarr_group.keys())[0] tomo_data = zarr_group[first_key] - print(f"๐Ÿ”ง Using first key '{first_key}' from zarr group") else: # Direct zarr array tomo_data = zarr_group - print("๐Ÿ”ง Using direct zarr array") - - print(f"๐Ÿ“ Tomogram shape: {tomo_data.shape}") # Calculate downsampling factor based on data size target_size = 200 @@ -237,33 +217,26 @@ def _generate_thumbnail_array(self, tomogram: "CopickTomogram") -> Optional[Any] # Use middle slice for 2D thumbnail mid_z = z_size // 2 - print(f"๐Ÿ“ Using middle slice z={mid_z} of {z_size}") # Calculate downsampling for x and y dimensions downsample_x = max(1, x_size // target_size) downsample_y = max(1, y_size // target_size) - print(f"๐Ÿ“‰ Downsampling: x={downsample_x}, y={downsample_y}") # Extract and downsample middle slice - print("โœ‚๏ธ Extracting slice...") slice_data = tomo_data[mid_z, ::downsample_y, ::downsample_x] - print(f"๐Ÿ“Š Slice shape: {slice_data.shape}") # Convert to numpy array slice_array = np.array(slice_data) - print(f"๐Ÿ”ข Array shape: {slice_array.shape}, dtype: {slice_array.dtype}") # Normalize to 0-255 range slice_array = slice_array.astype(np.float32) data_min, data_max = slice_array.min(), slice_array.max() - print(f"๐Ÿ“ˆ Data range: {data_min} to {data_max}") if data_max > data_min: slice_array = ((slice_array - data_min) / (data_max - data_min) * 255).astype(np.uint8) else: slice_array = np.zeros_like(slice_array, dtype=np.uint8) - print(f"โœ… Thumbnail array generated: shape={slice_array.shape}, dtype={slice_array.dtype}") return slice_array except Exception as e: diff --git a/src/copick_shared_ui/workers/base_manager.py b/src/copick_shared_ui/workers/base_manager.py index 4dd004c..f7a1708 100644 --- a/src/copick_shared_ui/workers/base_manager.py +++ b/src/copick_shared_ui/workers/base_manager.py @@ -20,7 +20,6 @@ def __init__(self, max_concurrent_workers: int = 8): self._max_concurrent = max_concurrent_workers self._active_workers = [] self._pending_queue = [] - print(f"๐ŸŽ›๏ธ {self.__class__.__name__}: Initialized with max {max_concurrent_workers} concurrent workers") def start_thumbnail_worker( self, @@ -60,9 +59,6 @@ def _queue_or_start_worker(self, worker_info: Dict[str, Any]) -> None: self._start_worker_from_info(worker_info) else: self._pending_queue.append(worker_info) - print( - f"โณ {self.__class__.__name__}: Queued {worker_info['type']} worker (queue size: {len(self._pending_queue)})", - ) @abstractmethod def _create_thumbnail_worker( @@ -106,14 +102,10 @@ def _start_worker_from_info(self, worker_info: Dict[str, Any]) -> None: self._create_callback_wrapper(worker_info["callback"]), ) else: - print(f"โŒ {self.__class__.__name__}: Unknown worker type: {worker_info['type']}") return self._active_workers.append(worker) self._start_worker(worker) - print( - f"๐Ÿš€ {self.__class__.__name__}: Started {worker_info['type']} worker ({len(self._active_workers)}/{self._max_concurrent} active)", - ) def _create_callback_wrapper(self, original_callback: Callable) -> Callable: """Create a callback wrapper that handles worker completion and queue processing.""" @@ -135,9 +127,6 @@ def _on_worker_completed(self) -> None: # Start next queued worker if any if self._pending_queue and len(self._active_workers) < self._max_concurrent: next_worker_info = self._pending_queue.pop(0) - print( - f"๐Ÿ”„ {self.__class__.__name__}: Starting next queued {next_worker_info['type']} worker (queue size: {len(self._pending_queue)})", - ) self._start_worker_from_info(next_worker_info) @abstractmethod @@ -159,7 +148,6 @@ def clear_workers(self) -> None: # Clear pending queue self._pending_queue.clear() - print(f"๐Ÿงน {self.__class__.__name__}: Cleared all active and pending workers") def shutdown_workers(self, timeout_ms: int = 3000) -> None: """Shutdown all workers with timeout.""" @@ -178,7 +166,6 @@ def set_max_concurrent_workers(self, max_workers: int) -> None: """Update the maximum number of concurrent workers.""" old_max = self._max_concurrent self._max_concurrent = max_workers - print(f"๐ŸŽ›๏ธ {self.__class__.__name__}: Updated max concurrent workers from {old_max} to {max_workers}") # If we increased the limit, try to start queued workers if max_workers > old_max: @@ -188,5 +175,4 @@ def _process_pending_queue(self) -> None: """Process pending queue to start workers if slots are available.""" while self._pending_queue and len(self._active_workers) < self._max_concurrent: next_worker_info = self._pending_queue.pop(0) - print(f"๐Ÿ”„ {self.__class__.__name__}: Starting queued {next_worker_info['type']} worker") self._start_worker_from_info(next_worker_info) diff --git a/src/copick_shared_ui/workers/chimerax.py b/src/copick_shared_ui/workers/chimerax.py index 2469ed5..37bc51b 100644 --- a/src/copick_shared_ui/workers/chimerax.py +++ b/src/copick_shared_ui/workers/chimerax.py @@ -234,16 +234,13 @@ def __init__(self, max_concurrent_workers: int = 8): Default is 8 to balance performance and system stability with large projects. """ self._max_concurrent = max_concurrent_workers - print(f"๐ŸŽ›๏ธ ChimeraXWorkerManager: Initialized with max {max_concurrent_workers} concurrent workers") if QT_AVAILABLE: self._thread_pool = QThreadPool() # Use Qt's built-in queue management self._thread_pool.setMaxThreadCount(max_concurrent_workers) - print(f"โœ… ChimeraXWorkerManager: QThreadPool max threads set to {max_concurrent_workers}") else: self._thread_pool = None - print("โŒ ChimeraXWorkerManager: Qt not available") def start_thumbnail_worker( self, @@ -257,8 +254,6 @@ def start_thumbnail_worker( callback(thumbnail_id, None, "Qt not available") return - print(f"๐Ÿš€ ChimeraXWorkerManager: Starting thumbnail worker for '{thumbnail_id}' (force={force_regenerate})") - # Create unique signals for each worker to avoid callback conflicts worker_signals = ChimeraXWorkerSignals() worker_signals.thumbnail_loaded.connect(callback) @@ -268,10 +263,6 @@ def start_thumbnail_worker( # QThreadPool handles queuing automatically self._thread_pool.start(worker) - print( - f"๐Ÿ“‹ ChimeraXWorkerManager: Active threads: {self._thread_pool.activeThreadCount()}/{self._thread_pool.maxThreadCount()}", - ) - def start_data_worker( self, run: "CopickRun", @@ -283,8 +274,6 @@ def start_data_worker( callback(data_type, None, "Qt not available") return - print(f"๐Ÿš€ ChimeraXWorkerManager: Starting data worker for '{data_type}'") - # Create unique signals for each worker to avoid callback conflicts worker_signals = ChimeraXWorkerSignals() worker_signals.data_loaded.connect(callback) @@ -294,26 +283,16 @@ def start_data_worker( # QThreadPool handles queuing automatically self._thread_pool.start(worker) - print( - f"๐Ÿ“‹ ChimeraXWorkerManager: Active threads: {self._thread_pool.activeThreadCount()}/{self._thread_pool.maxThreadCount()}", - ) - def clear_workers(self) -> None: """Clear all pending workers.""" if self._thread_pool: self._thread_pool.clear() - print("๐Ÿงน ChimeraXWorkerManager: Cleared all pending workers") def shutdown_workers(self, timeout_ms: int = 3000) -> None: """Shutdown all workers with timeout.""" if self._thread_pool: - print(f"โน๏ธ ChimeraXWorkerManager: Shutting down workers (timeout: {timeout_ms}ms)") self._thread_pool.clear() - success = self._thread_pool.waitForDone(timeout_ms) - if success: - print("โœ… ChimeraXWorkerManager: All workers shutdown successfully") - else: - print("โš ๏ธ ChimeraXWorkerManager: Some workers may not have shutdown cleanly") + _ = self._thread_pool.waitForDone(timeout_ms) def get_status(self) -> dict: """Get current worker manager status for debugging.""" diff --git a/src/copick_shared_ui/workers/data_worker.py b/src/copick_shared_ui/workers/data_worker.py index 62ac9fe..c6f1f19 100644 --- a/src/copick_shared_ui/workers/data_worker.py +++ b/src/copick_shared_ui/workers/data_worker.py @@ -37,8 +37,6 @@ def load_data(self) -> tuple[Optional[List[Any]], Optional[str]]: return None, "Cancelled" try: - print(f"๐Ÿ” Loading {self.data_type} for run '{self.run.name}'") - if self.data_type == "voxel_spacings": data = list(self.run.voxel_spacings) elif self.data_type == "tomograms": @@ -60,7 +58,6 @@ def load_data(self) -> tuple[Optional[List[Any]], Optional[str]]: if self._cancelled: return None, "Cancelled" - print(f"โœ… Loaded {len(data)} {self.data_type} items for run '{self.run.name}'") return data, None except Exception as e: diff --git a/src/copick_shared_ui/workers/napari.py b/src/copick_shared_ui/workers/napari.py index e1a5b64..40a8d4a 100644 --- a/src/copick_shared_ui/workers/napari.py +++ b/src/copick_shared_ui/workers/napari.py @@ -3,17 +3,13 @@ from typing import TYPE_CHECKING, Any, Callable, Optional, Union try: - print("๐Ÿ” Napari Workers: Importing napari threading components") from napari.qt.threading import thread_worker from qtpy.QtCore import QObject, Signal from qtpy.QtGui import QImage, QPixmap NAPARI_AVAILABLE = True - print("โœ… Napari Workers: napari threading components imported successfully") -except ImportError as e: - print(f"โŒ Napari Workers: napari threading import failed: {e}") +except ImportError: NAPARI_AVAILABLE = False - print("โœ… Napari Workers: Will skip napari-specific functionality") if NAPARI_AVAILABLE: from .base import AbstractThumbnailWorker @@ -49,17 +45,14 @@ def __init__( def start(self) -> None: """Start the thumbnail loading work using napari's thread_worker.""" - print(f"๐Ÿš€ NapariWorker: Starting thumbnail work for '{self.thumbnail_id}'") if not NAPARI_AVAILABLE: - print(f"โŒ NapariWorker: napari not available for '{self.thumbnail_id}'") self.callback(self.thumbnail_id, None, "napari not available") return # Create the worker function as a generator for better control @thread_worker def load_thumbnail(): - print(f"๐Ÿ”ง NapariWorker: Inside generator thread_worker for '{self.thumbnail_id}'") # Check cancellation before starting if self._cancelled: @@ -85,7 +78,6 @@ def load_thumbnail(): if self._cache and self._cache_key and not self.force_regenerate: cached_pixmap = self._cache.load_thumbnail(self._cache_key) if cached_pixmap is not None: - print(f"๐Ÿ“ฆ Using cached thumbnail for '{self.thumbnail_id}'") return cached_pixmap, None # Step 2: Determine tomogram to use @@ -131,13 +123,10 @@ def load_thumbnail(): if self._cache and self._cache_key: try: - success = self._cache.save_thumbnail(self._cache_key, pixmap) - if success: - print(f"๐Ÿ’พ Cached thumbnail for '{self.thumbnail_id}'") + _ = self._cache.save_thumbnail(self._cache_key, pixmap) except Exception as e: print(f"โš ๏ธ Error caching thumbnail: {e}") - print(f"โœ… NapariWorker: Successfully created thumbnail for '{self.thumbnail_id}'") return pixmap, None except Exception as e: @@ -148,17 +137,14 @@ def load_thumbnail(): return None, str(e) # Connect worker signals - print(f"๐Ÿ”— NapariWorker: Creating and connecting worker for '{self.thumbnail_id}'") worker = load_thumbnail() worker.returned.connect(self._on_worker_finished) worker.errored.connect(self._on_worker_error) # Store reference to worker self._worker_func = worker - print(f"๐Ÿ“ฆ NapariWorker: Worker stored for '{self.thumbnail_id}'") # Actually start the worker! - print(f"โ–ถ๏ธ NapariWorker: Starting worker execution for '{self.thumbnail_id}'") worker.start() def cancel(self) -> None: @@ -167,7 +153,6 @@ def cancel(self) -> None: if self._worker_func: # Use napari's quit method to abort the worker if hasattr(self._worker_func, "quit"): - print(f"๐Ÿ›‘ NapariWorker: Calling quit() on worker for '{self.thumbnail_id}'") self._worker_func.quit() else: print(f"โš ๏ธ NapariWorker: Worker for '{self.thumbnail_id}' has no quit method") @@ -225,25 +210,18 @@ def _generate_thumbnail_array_with_cancellation(self, tomogram: "CopickTomogram" # Use the highest scale level (most binned/smallest) for thumbnails highest_scale = scale_levels[-1] # Last element is highest number = most binned tomo_data = zarr_group[highest_scale] - print( - f"๐Ÿ”ง Using highest binning scale level {highest_scale} from multi-scale zarr for thumbnail", - ) else: # Fallback to first key first_key = list(zarr_group.keys())[0] tomo_data = zarr_group[first_key] - print(f"๐Ÿ”ง Using first key '{first_key}' from zarr group") else: # Direct zarr array tomo_data = zarr_group - print("๐Ÿ”ง Using direct zarr array") # Check cancellation after getting data reference if self._cancelled: return None - print(f"๐Ÿ“ Tomogram shape: {tomo_data.shape}") - # Calculate downsampling factor based on data size target_size = 200 z_size, y_size, x_size = tomo_data.shape @@ -280,7 +258,6 @@ def _generate_thumbnail_array_with_cancellation(self, tomogram: "CopickTomogram" else: thumbnail = np.zeros_like(thumbnail, dtype=np.uint8) - print(f"๐Ÿ“ Generated thumbnail shape: {thumbnail.shape}") return thumbnail except Exception as e: @@ -353,7 +330,6 @@ def __init__( def start(self) -> None: """Start the data loading work using napari's thread_worker.""" - print(f"๐Ÿš€ NapariDataWorker: Starting data loading for '{self.data_type}'") if not NAPARI_AVAILABLE: print(f"โŒ NapariDataWorker: napari not available for '{self.data_type}'") @@ -368,7 +344,6 @@ def start(self) -> None: # Create the worker function as a generator for better control @thread_worker def load_data(): - print(f"๐Ÿ”ง NapariDataWorker: Inside generator thread_worker for '{worker_data_type}'") if worker_cancelled(): print(f"โš ๏ธ NapariDataWorker: Cancelled '{worker_data_type}' before starting") @@ -384,8 +359,6 @@ def load_data(): return None, "Cancelled" # Use base class data loading logic directly - print(f"๐Ÿ” Loading {worker_data_type} for run '{worker_run.name}'") - if worker_data_type == "voxel_spacings": data = list(worker_run.voxel_spacings) elif worker_data_type == "tomograms": @@ -407,28 +380,23 @@ def load_data(): if worker_cancelled(): return None, "Cancelled" - print(f"โœ… NapariDataWorker: Successfully loaded {len(data)} {worker_data_type} items") return data, None except Exception as e: - print(f"๐Ÿ’ฅ NapariDataWorker: Exception loading '{worker_data_type}': {e}") import traceback traceback.print_exc() return None, str(e) # Connect worker signals - print(f"๐Ÿ”— NapariDataWorker: Creating and connecting worker for '{self.data_type}'") worker = load_data() worker.returned.connect(self._on_worker_finished) worker.errored.connect(self._on_worker_error) # Store reference to worker self._worker_func = worker - print(f"๐Ÿ“ฆ NapariDataWorker: Worker stored for '{self.data_type}'") # Actually start the worker! - print(f"โ–ถ๏ธ NapariDataWorker: Starting worker execution for '{self.data_type}'") worker.start() def cancel(self) -> None: @@ -437,7 +405,6 @@ def cancel(self) -> None: if self._worker_func: # Use napari's quit method to abort the worker if hasattr(self._worker_func, "quit"): - print(f"๐Ÿ›‘ NapariDataWorker: Calling quit() on worker for '{self.data_type}'") self._worker_func.quit() else: print(f"โš ๏ธ NapariDataWorker: Worker for '{self.data_type}' has no quit method")