tardisbase.testing.regression_comparison.util module

tardisbase.testing.regression_comparison.util.color_print(text, color)[source]

Print text to the console with ANSI color formatting.

This function provides colored console output using ANSI escape codes, making it easier to distinguish different types of messages in terminal output. The text is automatically reset to default color after printing.

Parameters:
  • text (str) – The text string to be printed with color formatting.

  • color (str) – The color name for the text. Supported colors are: ‘red’, ‘green’, ‘yellow’, ‘blue’. If an unsupported color is provided, the text will be printed without color formatting.

Notes

The function uses ANSI escape codes for coloring: - Red: 033[91m - Green: 033[92m - Yellow: 033[93m - Blue: 033[94m - Reset: 033[0m

tardisbase.testing.regression_comparison.util.get_last_n_commits(n=2, repo_path=None)[source]

Get the last n commits from a git repository using GitPython.

Parameters:
  • n (int, optional) – Number of commits to retrieve, by default 2

  • repo_path (str or Path, optional) – Path to the repository. If None, uses CONFIG[“regression_data_repo”]

Returns:

List of commit hashes (strings)

Return type:

list

Raises:

ValueError – If repository not found or git operations fail

tardisbase.testing.regression_comparison.util.get_relative_path(path, base)[source]

Calculate the relative path from a base directory to a target path.

This function computes the relative path representation of a target path with respect to a base directory, returning the result as a string.

Parameters:
  • path (str or Path) – The target path for which to calculate the relative path. Can be either an absolute or relative path.

  • base (str or Path) – The base directory from which to calculate the relative path. Should typically be an absolute path for consistent results.

Returns:

The relative path from base to path as a string.

Return type:

str

Raises:

ValueError – If the path is not relative to the base directory (i.e., they don’t share a common root or the path is outside the base directory tree).

Notes

This function uses pathlib.Path.relative_to() internally, which requires that the target path be within the base directory hierarchy. If the paths are on different drives (Windows) or don’t share a common ancestor, a ValueError will be raised.