eogrow.utils.testing

Module implementing utilities for unit testing pipeline results

class eogrow.utils.testing.StatCalcConfig(unique_values_limit: 'int' = 8, histogram_bin_num: 'int' = 8, num_random_values: 'int' = 8, parquet_epsg: 'Optional[int]' = None)[source]

Bases: object

Parameters:
  • unique_values_limit (int) –

  • histogram_bin_num (int) –

  • num_random_values (int) –

  • parquet_epsg (int | None) –

unique_values_limit: int = 8
histogram_bin_num: int = 8
num_random_values: int = 8
parquet_epsg: int | None = None
eogrow.utils.testing.compare_with_saved(stats, filename)[source]

Compares statistics of given folder content with statistics saved in a given file

Parameters:
  • stats (Dict[str, Any]) – Dictionary of calculated statistics of content

  • filename (str) – A JSON filename (with file path) where expected statistics is saved

Returns:

A dictionary report about differences between expected and actual content

Return type:

deepdiff.DeepDiff

eogrow.utils.testing.save_statistics(stats, filename)[source]

Saves statistics of given folder content into a JSON file

Parameters:
  • stats (Dict[str, Any]) – Dictionary of calculated statistics of content

  • filename (str) – A JSON filename (with file path) where statistics should be saved

Return type:

None

eogrow.utils.testing.calculate_statistics(folder, config)[source]

Calculates statistics of given folder and it’s content

Parameters:
  • folder (str) – Path to folder for which statistics are being calculated

  • config (StatCalcConfig) – A configuration of calculations

Return type:

Dict[str, Any]

eogrow.utils.testing.check_pipeline_logs(pipeline)[source]

A utility function which checks pipeline logs and makes sure there are no failed executions

Parameters:

pipeline (Pipeline) –

Return type:

None

eogrow.utils.testing.run_config(config_path, *, output_folder_key=None, reset_output_folder=True, check_logs=True)[source]

Runs a pipeline (or multiple) and checks the logs that all the executions were successful. Returns the full path of the output folder (if there is one) so it can be inspected further. In case of chain configs, the output folder of the last config is returned.

Parameters:
  • config_path (str) – A path to the config file

  • output_folder_key (str | None) – Type of the folder containing results of the pipeline, inferred from config if None

  • reset_output_folder (bool) – Delete the content of the results folder before running the pipeline

  • check_logs (bool) – If pipeline logs should be checked after the run completes. If EOWorkflows were used, the function fails if there were unsuccessful executions.

Return type:

str | None

eogrow.utils.testing.compare_content(folder_path, stats_path, *, config=None, save_new_stats=False)[source]

Compares the results from a pipeline run with the saved statistics. Constructed to be coupled with run_config hence the Optional input.

Parameters:
  • folder_path (str | None) – A path to the folder with contents to be compared

  • stats_path (str) – A path to the file containing result statistics

  • save_new_stats (bool) – Save new result stats and skip the comparison

  • config (StatCalcConfig | None) –

Return type:

None

eogrow.utils.testing.generate_tiff_file(filesystem, file_paths, *, tiff_bbox, width, height, num_bands, dtype, seed=42)[source]

Generates tiff files containing random data.

Parameters:
  • filesystem (FS) –

  • file_paths (Iterable[str]) –

  • tiff_bbox (BBox) –

  • width (int) –

  • height (int) –

  • num_bands (int) –

  • dtype (type) –

  • seed (int) –

Return type:

None