spectre.tools.ValidateInputFile

Functions

validate_input_file(input_file_path[, ...])

Check an input file for parse errors

Exceptions

InvalidInputFileError(input_file_path, ...)

Indicates that the input file cannot be parsed by the executable

exception spectre.tools.ValidateInputFile.InvalidInputFileError(input_file_path: str | Path, line_number: int | None, yaml_path: Sequence[str], message: str | None)

Indicates that the input file cannot be parsed by the executable

The exception prints the ‘message’ by default. To print additional context, catch the exception and print the ‘render_context()’ as well.

input_file_path

Path to the input file on disk.

line_number

Line number in the input file where the parse error occurred.

yaml_path

Sequence of YAML keys in the input file that lead to the parse error, such as ‘[“DomainCreator”, “Interval”, “LowerBound”]’.

message

Error message emitted by the option parsing.

args
render_context() Iterable[ConsoleRenderable | RichCast | str | Segment]
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

spectre.tools.ValidateInputFile.validate_input_file(input_file_path: str | Path, executable: str | Path | None = None, work_dir: str | Path | None = None, print_context: bool = True, raise_exception: bool = True)

Check an input file for parse errors

Invokes the executable with the ‘–check-options’ flag to check for parse errors.

Parameters:
  • input_file_path – Path to the input file on disk.

  • executable – Name or path of the executable. If unspecified, use the ‘Executable:’ in the input file metadata.

  • work_dir – Working directory for invoking the executable with the input file. Relative paths in the input file are resolved from here.

  • print_context – Print additional context where the parse error occurred before raising an exception (default: True).

  • raise_exception – Raise an ‘InvalidInputFileError’ if a parse error occurred (default: True).