-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_and_run_ui.sh
More file actions
executable file
·124 lines (102 loc) · 3.84 KB
/
fix_and_run_ui.sh
File metadata and controls
executable file
·124 lines (102 loc) · 3.84 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/env bash
# Fix and run OneTrainer UI with DearPyGui 1.8.0
set -e
echo "==== OneTrainer UI with DearPyGui 1.8.0 ===="
echo "This script will install DearPyGui 1.8.0 and run the UI."
# Use python3 as backup if python command isn't available
if ! command -v python &> /dev/null && command -v python3 &> /dev/null; then
export OT_PYTHON_CMD="python3"
fi
source "${BASH_SOURCE[0]%/*}/lib.include.sh"
prepare_runtime_environment
# Forcibly install DearPyGui 1.8.0 which is known to work more reliably
echo "Installing DearPyGui 1.8.0..."
run_pip_in_active_env uninstall -y dearpygui
run_pip_in_active_env install dearpygui==1.8.0
echo "DearPyGui 1.8.0 installed successfully"
# Fix the Additional Embeddings tab to use a more compatible implementation
EMBEDDINGS_TAB_PATH="dpg_ui/tabs/additional_embeddings_tab.py"
if [ -f "$EMBEDDINGS_TAB_PATH" ]; then
# Backup the file if a backup doesn't already exist
if [ ! -f "${EMBEDDINGS_TAB_PATH}.bak" ]; then
cp "$EMBEDDINGS_TAB_PATH" "${EMBEDDINGS_TAB_PATH}.bak"
echo "Created backup of $EMBEDDINGS_TAB_PATH"
fi
# Replace the file_entry with a simpler implementation
run_python_in_active_env -c "
import re
# Read the file
with open('$EMBEDDINGS_TAB_PATH', 'r') as f:
content = f.read()
# Replace the file_entry with a simpler implementation
pattern = r'llama_path\s*=\s*Components\.file_entry\(.*?\n.*?\n.*?\n.*?\n.*?\)'
replacement = \"\"\" # Use a simpler approach to avoid file dialog issues
input_id = dpg.add_input_text(
default_value=\"\",
width=250,
callback=self.on_llama_path_change
)
browse_button = dpg.add_button(
label=\"...\",
width=30,
height=30
)
# Set up button callback
def show_file_dialog():
with dpg.file_dialog(
label=\"Select LLaMA Model\",
width=700,
height=400,
callback=lambda s, a: dpg.set_value(input_id, a.get(\"file_path_name\", \"\")),
show=True
):
pass
dpg.set_item_callback(browse_button, show_file_dialog)\"\"\"
# Use regex with dotall mode to match across multiple lines
new_content = re.sub(pattern, replacement, content, flags=re.DOTALL)
# Write the modified content back to the file
with open('$EMBEDDINGS_TAB_PATH', 'w') as f:
f.write(new_content)
"
echo "Fixed $EMBEDDINGS_TAB_PATH"
fi
# Create a simple no-frills launcher for the UI
LAUNCHER_SCRIPT="start-OneTrainerUI.py"
cat > "$LAUNCHER_SCRIPT" << 'EOF'
#!/usr/bin/env python3
"""
Simple launcher for OneTrainer UI
"""
import os
import sys
import importlib.util
# Add the current directory to the path
current_dir = os.path.dirname(os.path.abspath(__file__))
if current_dir not in sys.path:
sys.path.insert(0, current_dir)
# Banner
print("=== OneTrainer with DearPyGui ===")
# Check if DearPyGui is installed
try:
import dearpygui
print(f"DearPyGui version: {getattr(dearpygui, '__version__', 'unknown')}")
except ImportError:
print("DearPyGui is not installed. Please run fix_and_run_ui.sh")
sys.exit(1)
# Very simple error handling
try:
# Import and run the application
from dpg_ui.app import OneTrainerApp
app = OneTrainerApp()
app.run()
except Exception as e:
print(f"Error: {e}")
import traceback
traceback.print_exc()
sys.exit(1)
EOF
chmod +x "$LAUNCHER_SCRIPT"
echo "Created $LAUNCHER_SCRIPT"
# Run the UI
echo "Starting OneTrainer UI..."
run_python_in_active_env ./"$LAUNCHER_SCRIPT"