Creates a dynamic module in the cache directory for modules.
(name: Union[str, os.PathLike])
| 63 | |
| 64 | |
| 65 | def create_dynamic_module(name: Union[str, os.PathLike]): |
| 66 | """ |
| 67 | Creates a dynamic module in the cache directory for modules. |
| 68 | """ |
| 69 | init_hf_modules() |
| 70 | dynamic_module_path = Path(HF_MODULES_CACHE) / name |
| 71 | # If the parent module does not exist yet, recursively create it. |
| 72 | if not dynamic_module_path.parent.exists(): |
| 73 | create_dynamic_module(dynamic_module_path.parent) |
| 74 | os.makedirs(dynamic_module_path, exist_ok=True) |
| 75 | init_path = dynamic_module_path / "__init__.py" |
| 76 | if not init_path.exists(): |
| 77 | init_path.touch() |
| 78 | |
| 79 | |
| 80 | def get_relative_imports(module_file): |
no test coverage detected