proj_flow.base.matrix

The proj_flow.base.matrix operates on lists of run configurations. It provides means to build cartesian products for multiple sets, to load the GitHub Actions Job strategy matrix from a set of YAML files, or to put additional filters on the resulting set of configurations.

proj_flow.base.matrix.find_compiler(compiler: str, config_names: Dict[str, List[str]]) Tuple[str, List[str]]

Locates the C and C++ names of compilers corresponding to the current compiler.

Parameters:
  • compiler – Name ofthe compiuler to map, taken from the "compiler" entry in run config.

  • config_names – Dictionary of mapping from compiler name to C/C++ names, taken from "compiler.names" entry in flow config file.

proj_flow.base.matrix.flatten(array: Iterable[List[T]]) List[T]

Turns list of lists into a list.

Parameters:

array – List of lists to flatten

Returns:

a list with all items expanded

proj_flow.base.matrix.matches(tested: dict, test: dict) bool

Checks, if the tested dictionary contains all the values from test dictionary.

Parameters:
  • tested – Dictionary to check

  • test – Dictionary to check against

Returns:

True, if all keys from test are in tested and have the same values, False otherwise.

proj_flow.base.matrix.partially_matches(tested: dict, test: dict) bool

Checks, if the tested dictionary contains some of the values from test dictionary, with non-zero intersection between both dictionaries.

Parameters:
  • tested – Dictionary to check

  • test – Dictionary to check against

Returns:

True, if all keys from test are in tested and have the same values, False otherwise.

proj_flow.base.matrix.matches_any(tested: dict, tests: List[dict])

Checks, if the tested dictionary contains all the values from at least one of test dictionaries.

Parameters:
  • tested – Dictionary to check

  • tests – List of dictionaries to check against

Returns:

True, if at least one test matches() tested dictionary, False otherwise.

proj_flow.base.matrix.cartesian(input: Dict[str, list]) List[dict]

Calculates the cartesian product of all axes in input.

The input dictionary is source of all axes this product is calculated from. The key to the dictionary names the set and value under each key represents the set to be multiplied.

The output list contains each possible dictionary, where key set is identical to the input key set and each value is one of the values in the input axis.

Parameters:

input – A dictionary with each axis and its values

Returns:

A list of all possible permutation of axes values; order in which each permutation appears in resulting list is not guaranteed.

Example:

Input
{
    "key-1": ["value-1", "value-2"],
    "key-2": [True, False],
    "key-3": [1, 2, 3],
}
Possible output
[
    { "key-1": "value-1", "key-2": [True], "key-3": 1 },
    { "key-1": "value-1", "key-2": [True], "key-3": 2 },
    { "key-1": "value-1", "key-2": [True], "key-3": 3 },
    { "key-1": "value-1", "key-2": [False], "key-3":  1 },
    { "key-1": "value-1", "key-2": [False], "key-3":  2 },
    { "key-1": "value-1", "key-2": [False], "key-3":  3 },
    { "key-1": "value-2", "key-2": [True], "key-3":  1 },
    { "key-1": "value-2", "key-2": [True], "key-3":  2 },
    { "key-1": "value-2", "key-2": [True], "key-3":  3 },
    { "key-1": "value-2", "key-2": [False], "key-3":  1 },
    { "key-1": "value-2", "key-2": [False], "key-3":  2 },
    { "key-1": "value-2", "key-2": [False], "key-3":  3 },
]
proj_flow.base.matrix.load_matrix(*matrix_paths: str) Tuple[List[dict], List[str]]

Loads config definitions from files under matrix_paths to produce cartesian product of the matrix, expanded and/or contracted according to rules used by GitHub Action workflow strategies. Please note when comparing to GitHub documentation:

  • only scalar values are supported in the matrix dictionary.

  • only matrix, include and exclude keys are allowed.

Parameters:

matrix_paths – The list of filenames pointing to YAML files with matrix, include and exclude entries.

Returns:

A tuple of cartesian product for the config matrix, with inclusions and exclusions as described in GitHub docs and a list of key names in the matrix dictionary.