Create a module with name `name` in which you can add dynamic modules such as metrics or datasets. The module can be imported using its name. The module is created in the HF_MODULE_CACHE directory by default (~/.cache/huggingface/modules) but it can be overriden by specifying a path
(
name: str = config.MODULE_NAME_FOR_DYNAMIC_MODULES, hf_modules_cache: Optional[Union[Path, str]] = None
)
| 54 | |
| 55 | |
| 56 | def init_dynamic_modules( |
| 57 | name: str = config.MODULE_NAME_FOR_DYNAMIC_MODULES, hf_modules_cache: Optional[Union[Path, str]] = None |
| 58 | ): |
| 59 | """ |
| 60 | Create a module with name `name` in which you can add dynamic modules |
| 61 | such as metrics or datasets. The module can be imported using its name. |
| 62 | The module is created in the HF_MODULE_CACHE directory by default (~/.cache/huggingface/modules) but it can |
| 63 | be overriden by specifying a path to another directory in `hf_modules_cache`. |
| 64 | """ |
| 65 | hf_modules_cache = init_hf_modules(hf_modules_cache) |
| 66 | dynamic_modules_path = os.path.join(hf_modules_cache, name) |
| 67 | os.makedirs(dynamic_modules_path, exist_ok=True) |
| 68 | if not os.path.exists(os.path.join(dynamic_modules_path, "__init__.py")): |
| 69 | with open(os.path.join(dynamic_modules_path, "__init__.py"), "w"): |
| 70 | pass |
| 71 | return dynamic_modules_path |
| 72 | |
| 73 | |
| 74 | def import_main_class(module_path) -> Optional[Union[Type[DatasetBuilder], Type[EvaluationModule]]]: |
no test coverage detected
searching dependent graphs…