Lazy Folder Scanner#

Lazy folder scanning functionality.

This module provides efficient folder scanning capabilities for MDA files with support for batch processing and progress tracking.

LazyFolderScanner(*args, **kwargs)

Lazy folder scanner for handling large MDA folders efficiently.

FolderScanResult(file_list, file_info_list, ...)

Result of a folder scan operation.

FolderScanWorker(*args, **kwargs)

Worker class for performing folder scans in background threads.

class mdaviz.lazy_folder_scanner.FolderScanResult(file_list: list[str], file_info_list: list[dict[str, Any]], total_files: int, scanned_files: int, is_complete: bool, error_message: str | None = None, is_progressive: bool = False)[source]#

Result of a folder scan operation.

class mdaviz.lazy_folder_scanner.FolderScanWorker(*args: Any, **kwargs: Any)[source]#

Worker class for performing folder scans in background threads.

_continue_progressive_scan(mda_files: list[Path], start_index: int) None[source]#

Continue progressive scanning from a given index.

Parameters:

mda_files (list[Path]): List of MDA files to scan start_index (int): Index to start scanning from

_progressive_scan(mda_files: list[Path]) None[source]#

Perform progressive scanning for very large directories.

Parameters:

mda_files (list[Path]): List of MDA files to scan

cancel() None[source]#

Cancel the scan operation.

complete#

alias of object

error#

alias of str

progress#

alias of int

progressive_update#

alias of object

scan() None[source]#

Perform the folder scan operation.

class mdaviz.lazy_folder_scanner.LazyFolderScanner(*args: Any, **kwargs: Any)[source]#

Lazy folder scanner for handling large MDA folders efficiently.

This class provides methods to scan folders in batches, allowing the UI to remain responsive while processing large numbers of files.

Attributes:

batch_size (int): Number of files to process in each batch max_files (int): Maximum number of files to scan before warning use_lightweight_scan (bool): Whether to use lightweight scanning progressive_loading (bool): Whether to use progressive loading for large directories

_continue_progressive_scan(folder_path: Path, mda_files: list[Path], start_index: int, progress_callback: Callable[[int, int], None] | None = None) None[source]#

Continue progressive scanning from a given index.

Parameters:

folder_path (Path): Path to the folder to scan mda_files (list[Path]): List of MDA files to scan start_index (int): Index to start scanning from progress_callback (callable, optional): Callback for progress updates

_on_scan_complete(result: FolderScanResult) None[source]#

Handle scan completion.

_on_scan_error(error_message: str) None[source]#

Handle scan error.

_progressive_scan(folder_path: Path, mda_files: list[Path], progress_callback: Callable[[int, int], None] | None = None) FolderScanResult[source]#

Perform progressive scanning for very large directories.

This method scans files in chunks and provides partial results to keep the UI responsive.

Parameters:

folder_path (Path): Path to the folder to scan mda_files (list[Path]): List of MDA files to scan progress_callback (callable, optional): Callback for progress updates

Returns:

FolderScanResult: Initial result with first batch of files

cancel_scan() None[source]#

Cancel the current scan operation.

is_scanning() bool[source]#

Check if a scan is currently in progress.

progressive_scan_update#

alias of object

scan_complete#

alias of object

scan_error#

alias of str

scan_folder(folder_path: Path, progress_callback: Callable[[int, int], None] | None = None) FolderScanResult[source]#

Scan a folder for MDA files using lazy loading.

Parameters:

folder_path (Path): Path to the folder to scan progress_callback (callable, optional): Callback for progress updates

Returns:

FolderScanResult: Result of the scan operation

scan_folder_async(folder_path: Path) None[source]#

Scan a folder asynchronously in a separate thread.

Parameters:

folder_path (Path): Path to the folder to scan

scan_progress#

alias of int