Make it easier to develop without a dev install (#22697)

* Make it easier to develop without a dev install

* Remove ugly hack that doesn't work anyway
This commit is contained in:
Sylvain Gugger
2023-04-11 08:41:53 -04:00
committed by GitHub
parent 4c01231e67
commit 28c19ab58d
6 changed files with 62 additions and 9 deletions

View File

@@ -277,11 +277,20 @@ def check_submodules():
transformers = direct_transformers_import(PATH_TO_TRANSFORMERS)
import_structure_keys = set(transformers._import_structure.keys())
# This contains all the base keys of the _import_structure object defined in the init, but if the user is missing
# some optional dependencies, they may not have all of them. Thus we read the init to read all additions and
# (potentiall re-) add them.
with open(os.path.join(PATH_TO_TRANSFORMERS, "__init__.py"), "r") as f:
init_content = f.read()
import_structure_keys.update(set(re.findall(r"import_structure\[\"([^\"]*)\"\]", init_content)))
module_not_registered = [
module
for module in get_transformers_submodules()
if module not in IGNORE_SUBMODULES and module not in transformers._import_structure.keys()
if module not in IGNORE_SUBMODULES and module not in import_structure_keys
]
if len(module_not_registered) > 0:
list_of_modules = "\n".join(f"- {module}" for module in module_not_registered)
raise ValueError(