Extract the tests from the reverse_dependency_map and potentially filters the model tests. Args: reverse_map (`Dict[str, List[str]]`, *optional*): The reverse dependency map as created by `create_reverse_dependency_map`. Will default to the result of that fu
(reverse_map: Dict[str, List[str]] = None)
| 779 | |
| 780 | |
| 781 | def create_module_to_test_map(reverse_map: Dict[str, List[str]] = None) -> dict[str, List[str]]: |
| 782 | """ |
| 783 | Extract the tests from the reverse_dependency_map and potentially filters the model tests. |
| 784 | |
| 785 | Args: |
| 786 | reverse_map (`Dict[str, List[str]]`, *optional*): |
| 787 | The reverse dependency map as created by `create_reverse_dependency_map`. Will default to the result of |
| 788 | that function if not provided. |
| 789 | filter_pipelines (`bool`, *optional*, defaults to `False`): |
| 790 | Whether or not to filter pipeline tests to only include core pipelines if a file impacts a lot of models. |
| 791 | |
| 792 | Returns: |
| 793 | `Dict[str, List[str]]`: A dictionary that maps each file to the tests to execute if that file was modified. |
| 794 | """ |
| 795 | if reverse_map is None: |
| 796 | reverse_map = create_reverse_dependency_map() |
| 797 | |
| 798 | # Utility that tells us if a given file is a test (taking test examples into account) |
| 799 | def is_test(fname): |
| 800 | if fname.startswith("tests"): |
| 801 | return True |
| 802 | if fname.startswith("examples") and fname.split(os.path.sep)[-1].startswith("test"): |
| 803 | return True |
| 804 | return False |
| 805 | |
| 806 | # Build the test map |
| 807 | test_map = {module: [f for f in deps if is_test(f)] for module, deps in reverse_map.items()} |
| 808 | |
| 809 | return test_map |
| 810 | |
| 811 | |
| 812 | def check_imports_all_exist(): |
no test coverage detected
searching dependent graphs…