RawScanLoadController

class RawScanLoadController(filestore: FileStoreInterface)

Orchestrates the loading of RawScan objects from a file store. This controller centralizes loader selection, classification, and batch-loading workflows. Implemented as a singleton to ensure consistent loader registry and classifier usage across the application.

Parameters:

filestore (FileStoreInterface) – File storage backend used to resolve file paths.

Overview

The controller coordinates three main concerns:

  • Classification: Determines the appropriate loader for a file via RawScanClassifier.

  • Loader resolution: Uses LoaderRegistry to map classifications to concrete loader implementations.

  • Batch orchestration: Provides optimized loading for multiple files or folders.

Private Methods

_lookup_loader(file_path: str) AbstractLoader

Resolve the appropriate loader for a given file path.

Parameters:

file_path (str) – Path to the input file.

Returns:

Loader instance corresponding to the file classification.

Return type:

AbstractLoader

Public Methods

load_file(file_path: str, loader: LoaderInterface | None = None) RawScan

Load a single file into a RawScan.

If no loader is provided, one is inferred via classification.

Parameters:
  • file_path (str) – Path to the file.

  • loader (LoaderInterface, optional) – Optional explicit loader instance.

Returns:

Loaded raw scan object.

Return type:

RawScan

load_files(file_paths: list[str], loader: LoaderInterface | None = None, quick: bool = Config['library.storage.raw.classification.quick']) list[RawScan]

Load multiple files into a list of RawScan objects.

When quick is enabled and no loader is provided, the loader is resolved once using the first file and reused for all subsequent files. This assumes homogeneous file types and improves performance.

Parameters:
  • file_paths (list[str]) – List of file paths.

  • loader (LoaderInterface, optional) – Optional explicit loader instance.

  • quick (bool) – Enable single classification for batch loading.

Returns:

List of loaded raw scans.

Return type:

list[RawScan]

load_folder(folder_path: str, loader: LoaderInterface | None = None, quick: bool = Config['library.storage.raw.classification.quick']) list[RawScan]

Load all files from a folder into RawScan objects.

Internally retrieves file paths from the filestore and delegates to load_files().

Parameters:
  • folder_path (str) – Path to the folder.

  • loader (LoaderInterface, optional) – Optional explicit loader instance.

  • quick (bool) – Enable single classification for batch loading.

Returns:

List of loaded raw scans.

Return type:

list[RawScan]

Design Notes

  • Singleton pattern ensures a single shared controller instance.

  • Pluggable loaders via LoaderRegistry support extensibility.

  • Performance optimization via quick mode reduces redundant classification.

  • Assumes consistent file types when quick=True; misuse may lead to incorrect loader selection.