-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathtest_import.py
More file actions
40 lines (34 loc) · 1.11 KB
/
test_import.py
File metadata and controls
40 lines (34 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python3
import os
import sys
import importlib
# Current directory paths
current_dir = os.path.dirname(os.path.abspath(__file__))
print(f"Current directory: {current_dir}")
# Add current dir to path
sys.path.append(current_dir)
print(f"sys.path: {sys.path}")
# Try importing the modules
try:
import send_request
print("Successfully imported send_request")
except ImportError as e:
print(f"Failed to import send_request: {e}")
try:
import utils
print("Successfully imported utils")
except ImportError as e:
print(f"Failed to import utils: {e}")
# Try to import from comfy-nodes
try:
# Use importlib to handle the hyphen in the directory name
spec = importlib.util.spec_from_file_location(
"generate_text",
os.path.join(current_dir, "comfy-nodes", "generate_text.py")
)
generate_text = importlib.util.module_from_spec(spec)
spec.loader.exec_module(generate_text)
print("Successfully imported generate_text")
except Exception as e:
print(f"Failed to import generate_text: {e}")
print("Import test completed")