pleiades.sammy.interface module

Interface definitions for SAMMY execution system.

This module defines the core interfaces and data structures used across all SAMMY backend implementations.

class pleiades.sammy.interface.SammyBackendType(value)[source]

Bases: Enum

Enumeration of available SAMMY backend types.

LOCAL = 1
DOCKER = 2
NOVA = 3
class pleiades.sammy.interface.SammyFiles(input_file: Path, parameter_file: Path, data_file: Path, _original_input_file: Path | None = None, _original_parameter_file: Path | None = None, _original_data_file: Path | None = None)[source]

Bases: object

Container for SAMMY input files.

input_file: Path
parameter_file: Path
data_file: Path
validate() None[source]

Validate that all required input files exist.

Raises:

FileNotFoundError – If any required file is missing

move_to_working_dir(working_dir: Path) None[source]

Move files to the working directory according to the desired strategy: - input_file: copy to working directory - parameter_file: copy to working directory - data_file: symlink to working directory

Updates the object’s file path attributes to point to the files in the working directory. Can be safely called multiple times - will clean up previous working files first.

Parameters:

working_dir – Path to the working directory

Raises:
cleanup_working_files() None[source]

Remove any files copied or symlinked to the working directory, and restore original file paths.

class pleiades.sammy.interface.SammyFilesMultiMode(input_file: Path, json_config_file: Path, data_file: Path, endf_directory: Path, fit_abundances: bool = False, _original_input_file: Path | None = None, _original_json_config_file: Path | None = None, _original_data_file: Path | None = None)[source]

Bases: object

Container for SAMMY multi-isotope JSON mode input files.

input_file: Path
json_config_file: Path
data_file: Path
endf_directory: Path
fit_abundances: bool = False
validate() None[source]

Validate that all required input files exist.

Basic file existence validation only.

Raises:

FileNotFoundError – If any required file is missing

move_to_working_dir(working_dir: Path) None[source]

Move files to working directory for SAMMY JSON mode.

Strategy for JSON mode: - input_file: copy to working directory - json_config_file: copy to working directory - data_file: symlink to working directory - endf_directory files: symlink individual ENDF files to working directory

Parameters:

working_dir – Path to the working directory

cleanup_working_files() None[source]

Remove files copied or symlinked to working directory.

class pleiades.sammy.interface.SammyExecutionResult(success: bool, execution_id: str, start_time: datetime, end_time: datetime, console_output: str, error_message: str | None = None)[source]

Bases: object

Detailed results of a SAMMY execution.

success: bool
execution_id: str
start_time: datetime
end_time: datetime
console_output: str
error_message: str | None = None
property runtime_seconds: float

Calculate execution time in seconds.

class pleiades.sammy.interface.BaseSammyConfig(working_dir: Path, output_dir: Path)[source]

Bases: ABC

Base configuration for all SAMMY backends.

working_dir: Path
output_dir: Path
prepare_directories() None[source]

Create and prepare required directories.

Raises:

ConfigurationError – If directory creation fails

validate() bool[source]

Validate the configuration.

Returns:

True if configuration is valid

Return type:

bool

Raises:

ConfigurationError – If configuration is invalid

class pleiades.sammy.interface.SammyRunner(config: BaseSammyConfig)[source]

Bases: ABC

Abstract base class for SAMMY execution backends.

abstractmethod prepare_environment(files: SammyFiles) None[source]

Prepare the execution environment.

Parameters:

files – Container with file information

Raises:

EnvironmentPreparationError – If preparation fails

abstractmethod execute_sammy(files: SammyFiles) SammyExecutionResult[source]

Execute SAMMY with prepared files.

Parameters:

files – Container with validated and prepared files

Returns:

Execution results including status and outputs

Raises:

SammyExecutionError – If execution fails

abstractmethod cleanup(files: SammyFiles) None[source]

Clean up resources after execution.

Parameters:

files – Container with file information

Raises:

CleanupError – If cleanup fails

abstractmethod validate_config() bool[source]

Validate backend configuration.

Returns:

True if configuration is valid

Return type:

bool

Raises:

ConfigurationError – If configuration is invalid

collect_outputs(result: SammyExecutionResult) None[source]

Collect and validate output files after execution.

Parameters:

result – Execution result containing status information

Raises:

OutputCollectionError – If output collection fails

exception pleiades.sammy.interface.SammyError[source]

Bases: Exception

Base exception for SAMMY-related errors.

exception pleiades.sammy.interface.EnvironmentPreparationError[source]

Bases: SammyError

Raised when environment preparation fails.

exception pleiades.sammy.interface.SammyExecutionError[source]

Bases: SammyError

Raised when SAMMY execution fails.

exception pleiades.sammy.interface.OutputCollectionError[source]

Bases: SammyError

Raised when output collection fails.

exception pleiades.sammy.interface.ConfigurationError[source]

Bases: SammyError

Raised when configuration is invalid.

exception pleiades.sammy.interface.CleanupError[source]

Bases: SammyError

Raised when cleanup fails.