Skip to content
Snippets Groups Projects
Commit 89d43509 authored by Jammer, Tim's avatar Jammer, Tim
Browse files

added some (partially AI generated) documentation for the Parameters

parent 734945c9
No related branches found
No related tags found
1 merge request!5more work on infrastructure III
......@@ -16,6 +16,9 @@ digits_to_use = 3
def import_module(root, file):
"""
Private function: imports a python module from a file
"""
full_fname = os.path.join(root, file)
name = file[:-3] # name without .py suffix
spec = importlib.util.spec_from_file_location(name, full_fname)
......@@ -25,14 +28,34 @@ def import_module(root, file):
class GeneratorManager:
def __init__(self, path):
def __init__(self, path, print_discovery=True, skip_invalid=False):
"""
Instantiates an GeneratorManager and discovers ErrorGenerator classes from Python files in the specified path.
Parameters:
- `path` (str): The path to search for Python files containing ErrorGenerator classes.
- `print_discovery` (bool, optional): Whether to print the discovered generators. Defaults to True.
- `skip_invalid` (bool, optional): Whether to skip invalid generators. Defaults to False.
Returns:
None
Raises:
AssertionError: If an ErrorGenerator class is found with unknown features and `skip_invalid` is False.
Note:
- Discovers the generators in Python files with the '.py' extension in the specified path and its subdirectories.
"""
self.generators = []
self.discover_generators(path)
self.discover_generators(path, print_discovery, skip_invalid)
self.case_names = {}
# discover all Error Generators
pass
def get_filename(self, case_name, suffix=".c"):
"""
Private Function: Helps to generate filenames for the generated testcases
"""
num = 0
if case_name in self.case_names:
num = self.case_names[case_name]
......@@ -43,6 +66,30 @@ class GeneratorManager:
def generate(self, outpath, filterlist_=None, print_progress_bar=True, overwrite=True, generate_full_set=False,
try_compile=False, max_mpi_version=4.0):
"""
Generates test cases based on the specified parameters.
Parameters:
- `outpath` (str): The path where the generated test cases will be saved.
- `filterlist_` (list, optional): A list of features to filter the generators. Defaults to None (no filters).
- `print_progress_bar` (bool, optional): Whether to print a progress bar. Defaults to True.
- `overwrite` (bool, optional): Whether to overwrite existing files. Defaults to True.
- `generate_full_set` (bool, optional): Whether to generate the full (extended) set of errors. Defaults to False.
- `try_compile` (bool, optional): Whether to try compiling the generated test cases. Defaults to False.
- `max_mpi_version` (float, optional): The maximum MPI version allowed for generated test cases. Defaults to 4.0.
Returns:
None
Raises:
AssertionError: If the environment variable 'MPICC' is not set when `try_compile` is True.
CalledProcessError: If compilation fails during the try_compile process.
Note:
- The progress bar is printed using the tqdm module.
- If `try_compile` is True, it uses the compiler specified via 'MPICC' environment variable to attempt compilation.#
- the Features and if a test belongs to the base of frull test set is defined by the respective generators
- Generators can Raise CorrectTestcase, therefore the number of discovered testcases may not match the number of generated cases
"""
filterlist = filterlist_
if filterlist is None:
filterlist = featurelist
......@@ -110,6 +157,9 @@ class GeneratorManager:
pass
def discover_generators(self, path, print_discovery=True, skip_invalid=False):
"""
Private Function. see Documentation for __init__()
"""
if print_discovery:
print("Discover Generators:")
for root, dirs, files in os.walk(path):
......@@ -117,7 +167,7 @@ class GeneratorManager:
if file.endswith('.py'):
module = import_module(root, file)
for name, obj in inspect.getmembers(module):
# if it is a class derived from ErrorGenerator (and not the interface class itself)
# if it is a class derived from ErrorGenerator (and is not the interface class itself)
if inspect.isclass(obj) and issubclass(obj, ErrorGenerator) and not obj is ErrorGenerator:
if print_discovery:
print("Found Generator %s" % name)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment