MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / check_submodules

Function check_submodules

diffusers/utils/check_inits.py:274–294  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

272
273
274def check_submodules():
275 # This is to make sure the transformers module imported is the one in the repo.
276 spec = importlib.util.spec_from_file_location(
277 "transformers",
278 os.path.join(PATH_TO_TRANSFORMERS, "__init__.py"),
279 submodule_search_locations=[PATH_TO_TRANSFORMERS],
280 )
281 transformers = spec.loader.load_module()
282
283 module_not_registered = [
284 module
285 for module in get_transformers_submodules()
286 if module not in IGNORE_SUBMODULES and module not in transformers._import_structure.keys()
287 ]
288 if len(module_not_registered) > 0:
289 list_of_modules = "\n".join(f"- {module}" for module in module_not_registered)
290 raise ValueError(
291 "The following submodules are not properly registered in the main init of Transformers:\n"
292 f"{list_of_modules}\n"
293 "Make sure they appear somewhere in the keys of `_import_structure` with an empty list as value."
294 )
295
296
297if __name__ == "__main__":

Callers 1

check_inits.pyFile · 0.85

Calls 2

load_moduleMethod · 0.45

Tested by

no test coverage detected