Coverage for ezstitcher/core/main.py: 0%
23 statements
« prev ^ index » next coverage.py v7.3.2, created at 2025-04-30 13:20 +0000
« prev ^ index » next coverage.py v7.3.2, created at 2025-04-30 13:20 +0000
1"""
2Main module for ezstitcher.
4This module provides the main entry point for the ezstitcher package.
5"""
7import logging
8from pathlib import Path
10# Import configuration classes
11from ezstitcher.core.config import PipelineConfig
13# Import the pipeline orchestrator
14from ezstitcher.core.pipeline_orchestrator import PipelineOrchestrator
16def apply_nested_overrides(config_obj, overrides):
17 """
18 Recursively apply overrides to a nested config object.
20 Args:
21 config_obj: The root config object.
22 overrides: Dict of overrides, possibly with dot notation keys.
23 """
24 for key, value in overrides.items():
25 parts = key.split(".")
26 target = config_obj
27 for part in parts[:-1]:
28 if hasattr(target, part):
29 target = getattr(target, part)
30 else:
31 # Invalid path, skip
32 target = None
33 break
34 if target is not None and hasattr(target, parts[-1]):
35 setattr(target, parts[-1], value)
39def process_plate(
40 plate_folder: str | Path,
41 config = None,
42 **kwargs
43) -> bool:
44 """
45 High-level function to process a plate folder using the PipelineOrchestrator.
47 Args:
48 plate_folder: Path to the plate folder.
49 config: Optional PipelineConfig. If None, a default config is created.
50 **kwargs: Optional overrides for config parameters.
52 Returns:
53 True if processing succeeded, False otherwise.
54 """
55 plate_folder = Path(plate_folder)
57 # Create default config if none provided
58 if config is None:
59 config = PipelineConfig()
60 logging.info("No config provided, using default pipeline configuration")
62 # Apply any config overrides in kwargs
63 apply_nested_overrides(config, kwargs)
65 # Create and run the pipeline
66 pipeline = PipelineOrchestrator(config)
67 return pipeline.run(plate_folder)