Fix flax failures (#33912)

* Few fixes here and there

* Remove typos

* Remove typos
This commit is contained in:
Lysandre Debut
2024-10-11 14:38:35 +02:00
committed by GitHub
parent e878eaa9fc
commit f052e94bcc
5 changed files with 40 additions and 20 deletions

View File

@@ -1089,18 +1089,34 @@ def check_public_method_exists(documented_methods_map):
for submodule_name in nested_submodules:
if submodule_name == "transformers":
continue
submodule = getattr(submodule, submodule_name)
try:
submodule = getattr(submodule, submodule_name)
except AttributeError:
failures.append(f"Could not parse {submodule_name}. Are the required dependencies installed?")
continue
class_name = nested_path[-1]
obj_class = getattr(submodule, class_name)
try:
obj_class = getattr(submodule, class_name)
except AttributeError:
failures.append(f"Could not parse {submodule_name}. Are the required dependencies installed?")
continue
# Checks that all explicitly documented methods are defined in the class
for method in methods:
if method == "all": # Special keyword to document all public methods
continue
if not hasattr(obj_class, method):
failures.append(
"The following public method is explicitly documented but not defined in the corresponding "
f"class. class: {obj}, method: {method}"
)
try:
if not hasattr(obj_class, method):
failures.append(
"The following public method is explicitly documented but not defined in the corresponding "
f"class. class: {obj}, method: {method}. If the method is defined, this error can be due to "
f"lacking dependencies."
)
except ImportError:
pass
if len(failures) > 0:
raise Exception("\n".join(failures))