Zach Schumacher
06/14/2021, 3:07 PMdef flow_imports_tester(root_path: Path, module_dot_path: str): # pragma: no cover
"""
Helper for testing all flows in a project root_path at module_dot_path are importable
Example:
>>> flow_imports_tester(Path("~/my_project").expanduser(), "my_project.my_directory.flows")
"""
split_dot_path = module_dot_path.split(".")
package_directory = Path(root_path, *split_dot_path)
flows = list(package_directory.iterdir())
if not flows:
raise RuntimeError("No flows found, did you specify the correct path?")
for flow in flows:
if "." in flow.name:
filename, file_extension = flow.name.split(".")
else:
filename, file_extension = flow.name, ""
if filename == "__init__" or file_extension != "py":
continue
import_module(".".join([module_dot_path, filename]))