a60a18a253
Introduce ruff lint/format config, expand .gitignore, and reformat Python sources. Co-authored-by: Cursor <cursoragent@cursor.com>
32 lines
964 B
Python
32 lines
964 B
Python
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass, field
|
|
from pathlib import Path
|
|
from typing import TYPE_CHECKING, Any
|
|
|
|
if TYPE_CHECKING:
|
|
from imagepipeline.core.log import PipelineLogger
|
|
|
|
|
|
@dataclass
|
|
class ModuleContext:
|
|
"""Runtime context passed to each module's run() method."""
|
|
|
|
input_paths: list[Path]
|
|
output_dir: Path
|
|
params: dict[str, Any]
|
|
pipeline_output_root: Path
|
|
step_id: str
|
|
matched_groups: list[list[Path]] = field(default_factory=list)
|
|
input_refs: list[str] = field(default_factory=list)
|
|
input_layer_dirs: list[tuple[str, Path]] = field(default_factory=list)
|
|
logger: PipelineLogger | None = None
|
|
|
|
@property
|
|
def is_multi_input(self) -> bool:
|
|
return len(self.matched_groups) > 1
|
|
|
|
def log_image(self, module_name: str, index: int, total: int, path: Path) -> None:
|
|
if self.logger is not None:
|
|
self.logger.image(module_name, index, total, path.name)
|