onsrap.runner module

class onsrap.runner.PipelineRunner(logger: Logger | None = None)

Bases: object

Represents the information required to run the Pipeline.

Parameters:

logger (Logger class type) – Information used to log progress throughout the Pipeline.

run(pipeline: Pipeline) PipelineRun

Method that runs a Pipeline instance.

This method validates the source information, establishes the directories and the context to run the pipeline within, sets out the manifest for the run, attempts to run the stages in the order outlined by the StageGraph instance and logs all progress alongside relevant statuses. Before each stage executes, the runner binds the current stage name onto the ExecutionContext so context.stage_config resolves to the correct stage-specific configuration.

It returns a PipelineRun instance containing metadata and logging information for the specific run of the whole Pipeline.

Parameters:

pipeline (Pipeline) – A Pipeline instance that this method will run.

Raises:

StageExecutionError – If the stage is unable to be run. Logs will be created to show a failed stage.

onsrap.runner.build_parser() ArgumentParser

Determines what arguments are needed when running a Pipeline from the command line.

Enables stages to be input, followed by a name if provided.

onsrap.runner.main(argv: list[str] | None = None) int

Entrypoint to the pipeline.

This function can be called from the command line. It builds a parser which enables the arguments to be held before using those arguments to build a Pipeline instance. The pipeline.run() method is then run which runs the entire pipeline. If this runs successfully, a 0 is returned which is the success code.

Parameters:

argv (list[str] or None) – Command line arguments to parse.

Returns:

Success code for completion of the run.

Return type:

int

onsrap.runner.print_config_diffs(file_1, file_2) dict

A combining function that calculates the differences between two YAML files and then prints the outputs to the terminal as well as returning the computer-readable dictionary of the differences.

This works by calling the _diff_yaml_files function to calculate the differences and then calling the _print_diff function to print the differences.

Parameters:
  • file_1 (Path) – The path to the first YAML file to compare.

  • file_2 (Path) – The path to the second YAML file to compare.

Returns:

A dictionary describing the differences between the two YAML files, structured as {changed: {}, added: {}, removed: {}}.

Return type:

dict