in src/evaluate/loading.py [0:0]
def get_module(self) -> ImportableModule:
revision = self.revision or os.getenv("HF_SCRIPTS_VERSION", SCRIPTS_VERSION)
if re.match(r"\d*\.\d*\.\d*", revision): # revision is version number (three digits separated by full stops)
revision = "v" + revision # tagging convention on evaluate repository starts with v
# get script and other files
try:
local_path = self.download_loading_script(revision)
except FileNotFoundError as err:
# if there is no file found with current revision tag try to load main
if self.revision is None and os.getenv("HF_SCRIPTS_VERSION", SCRIPTS_VERSION) != "main":
revision = "main"
local_path = self.download_loading_script(revision)
else:
raise err
imports = get_imports(local_path)
local_imports = _download_additional_modules(
name=self.name,
base_path=hf_hub_url(path=self.name, name="", revision=revision),
imports=imports,
download_config=self.download_config,
)
# copy the script and the files in an importable directory
dynamic_modules_path = self.dynamic_modules_path if self.dynamic_modules_path else init_dynamic_modules()
module_path, hash = _create_importable_file(
local_path=local_path,
local_imports=local_imports,
additional_files=[],
dynamic_modules_path=dynamic_modules_path,
module_namespace=self.module_type,
name=self.name,
download_mode=self.download_mode,
)
# make the new module to be noticed by the import system
importlib.invalidate_caches()
return ImportableModule(module_path, hash)