MCPcopy Create free account
hub / github.com/OpenSparseLLMs/MoM / import_function

Function import_function

lm-eval-harness/lm_eval/utils.py:352–366  ·  view source on GitHub ↗
(loader, node)

Source from the content-addressed store, hash-verified

350
351
352def import_function(loader, node):
353 function_name = loader.construct_scalar(node)
354 yaml_path = os.path.dirname(loader.name)
355
356 *module_name, function_name = function_name.split(".")
357 if isinstance(module_name, list):
358 module_name = ".".join(module_name)
359 module_path = os.path.normpath(os.path.join(yaml_path, "{}.py".format(module_name)))
360
361 spec = importlib.util.spec_from_file_location(module_name, module_path)
362 module = importlib.util.module_from_spec(spec)
363 spec.loader.exec_module(module)
364
365 function = getattr(module, function_name)
366 return function
367
368
369def load_yaml_config(yaml_path=None, yaml_config=None, yaml_dir=None, mode="full"):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected