Skip to content

Commit

Permalink
revert change to validate
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanrfrazier committed Feb 14, 2025
1 parent 0b44c20 commit d6a54ca
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions src/backend/base/langflow/utils/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,22 +242,18 @@ def prepare_global_scope(module):
try:
with warnings.catch_warnings():
warnings.simplefilter("ignore", LangChainDeprecationWarning)
# check if module is installed
if importlib.util.find_spec(node.module) is None:
msg = f"Module {node.module} not found. Please install it if desired."
else:
imported_module = importlib.import_module(node.module)
for alias in node.names:
try:
# First try getting it as an attribute
exec_globals[alias.name] = getattr(imported_module, alias.name)
except AttributeError:
# If that fails, try importing the full module path
full_module_path = f"{node.module}.{alias.name}"
exec_globals[alias.name] = importlib.import_module(full_module_path)
imported_module = importlib.import_module(node.module)
for alias in node.names:
try:
# First try getting it as an attribute
exec_globals[alias.name] = getattr(imported_module, alias.name)
except AttributeError:
# If that fails, try importing the full module path
full_module_path = f"{node.module}.{alias.name}"
exec_globals[alias.name] = importlib.import_module(full_module_path)
except ModuleNotFoundError as e:
msg = f"Module {node.module} not found. Please install it if desired."
# raise ModuleNotFoundError(msg) from e
msg = f"Module {node.module} not found. Please install it and try again"
raise ModuleNotFoundError(msg) from e
elif isinstance(node, ast.ClassDef):
# Compile and execute the class definition to properly create the class
class_code = compile(ast.Module(body=[node], type_ignores=[]), "<string>", "exec")
Expand Down

0 comments on commit d6a54ca

Please sign in to comment.