MCPcopy Create free account
hub / github.com/huggingface/evaluate / init_dynamic_modules

Function init_dynamic_modules

src/evaluate/loading.py:56–71  ·  view source on GitHub ↗

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
)

Source from the content-addressed store, hash-verified

54
55
56def 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
74def import_main_class(module_path) -> Optional[Union[Type[DatasetBuilder], Type[EvaluationModule]]]:

Callers 3

get_moduleMethod · 0.85
get_moduleMethod · 0.85
get_moduleMethod · 0.85

Calls 1

init_hf_modulesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…