Source code for spindoctor.dataset.dataset_sim

import argparse
from collections.abc import Iterator
from typing import Any

from filecache import FCPath

from spindoctor.config import Config
from spindoctor.support.misc import flatten_list

from .dataset import DataSet, ImageFile, ImageFiles


[docs] class DataSetSim(DataSet): """Dataset that yields a series of YAML-described simulated images. Each dataset value is a direct file path to the YAML scene file; selection simply returns that one file. """ @staticmethod def _img_name_valid(img_name: str) -> bool: # Accept any path ending in .yaml or .yml return str(img_name).lower().endswith(('.yaml', '.yml')) # Public methods def __init__(self, *, config: Config | None = None) -> None: """Initializes a simulated dataset. Parameters: config: Configuration object to use. If None, uses DEFAULT_CONFIG. """ super().__init__(config=config)
[docs] @staticmethod def add_selection_arguments( cmdparser: argparse.ArgumentParser, group: argparse._ArgumentGroup | None = None, ) -> None: if group is None: group = cmdparser.add_argument_group('Image selection (sim-specific)') group.add_argument( 'img_path', action='append', nargs='*', type=str, help='Paths to YAML scene files containing simulated images to process', )
[docs] def yield_image_files_from_arguments( self, arguments: argparse.Namespace ) -> Iterator[ImageFiles]: img_path_list = flatten_list(arguments.img_path) for img_path in img_path_list: scene_fcpath = FCPath(img_path) imagefile = ImageFile( image_file_url=scene_fcpath, label_file_url=scene_fcpath, results_path_stub=str(scene_fcpath.with_suffix('').name), ) yield ImageFiles(image_files=[imagefile])
[docs] def yield_image_files_index(self, **kwargs: Any) -> Iterator[ImageFiles]: raise NotImplementedError('yield_image_files_index is not implemented for sim dataset')
[docs] @staticmethod def supported_grouping() -> list[str]: return []
[docs] def pds4_bundle_template_dir(self) -> str: """Returns absolute path to template directory for PDS4 bundle generation.""" raise NotImplementedError('Bundle generation not supported for sim dataset')
[docs] def pds4_bundle_name(self) -> str: """Returns bundle name for PDS4 bundle generation.""" raise NotImplementedError('Bundle generation not supported for sim dataset')
[docs] @staticmethod def pds4_bundle_path_for_image(image_name: str) -> str: """Maps image name to bundle directory path.""" raise NotImplementedError('Bundle generation not supported for sim dataset')
[docs] def pds4_path_stub(self, image_file: ImageFile) -> str: """Returns PDS4 path stub for bundle directory structure.""" raise NotImplementedError('Bundle generation not supported for sim dataset')
[docs] def pds4_template_variables( self, *, image_file: ImageFile, nav_metadata: dict[str, Any], backplane_metadata: dict[str, Any], ) -> dict[str, Any]: """Returns template variables for PDS4 label generation.""" raise NotImplementedError('Bundle generation not supported for sim dataset')