Skip to content

Commit 34ccfeb

Browse files
Fix AST parsing when looking for remote code imports (#37245)
* Not all Call.func nodes have id because they can be methods * Trigger tests * Trigger tests
1 parent f697b3f commit 34ccfeb

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/transformers/dynamic_module_utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ def recursive_look_for_imports(node):
157157
elif isinstance(node, ast.If):
158158
test = node.test
159159
for condition_node in ast.walk(test):
160-
if isinstance(condition_node, ast.Call) and condition_node.func.id.startswith("is_flash_attn"):
160+
if isinstance(condition_node, ast.Call) and getattr(condition_node.func, "id", "").startswith(
161+
"is_flash_attn"
162+
):
161163
# Don't recurse into "if flash_attn_available()" blocks and ignore imports in them
162164
return
163165
elif isinstance(node, ast.Import):

0 commit comments

Comments
 (0)