Skip to content

Commit a97a545

Browse files
committed
refactor: move get helper functions to utils.py
- move get_models_data and get_tasks_data to utils.py from AutoGGUF.py
1 parent 4f2c805 commit a97a545

File tree

2 files changed

+37
-32
lines changed

2 files changed

+37
-32
lines changed

Diff for: src/AutoGGUF.py

+2-32
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ def __init__(self, args):
8080
self.browse_output = utils.browse_output.__get__(self)
8181
self.browse_logs = utils.browse_logs.__get__(self)
8282
self.browse_imatrix = utils.browse_imatrix.__get__(self)
83+
self.get_models_data = utils.get_models_data.__get__(self)
84+
self.get_tasks_data = utils.get_tasks_data.__get__(self)
8385
self.update_threads_spinbox = partial(ui_update.update_threads_spinbox, self)
8486
self.update_threads_slider = partial(ui_update.update_threads_slider, self)
8587
self.update_gpu_offload_spinbox = partial(
@@ -1549,38 +1551,6 @@ def browse_imatrix_output(self):
15491551
if output_file:
15501552
self.imatrix_output.setText(os.path.abspath(output_file))
15511553

1552-
def get_models_data(self):
1553-
models = []
1554-
root = self.model_tree.invisibleRootItem()
1555-
child_count = root.childCount()
1556-
for i in range(child_count):
1557-
item = root.child(i)
1558-
model_name = item.text(0)
1559-
model_type = "sharded" if "sharded" in model_name.lower() else "single"
1560-
model_path = item.data(0, Qt.ItemDataRole.UserRole)
1561-
models.append({"name": model_name, "type": model_type, "path": model_path})
1562-
return models
1563-
1564-
def get_tasks_data(self):
1565-
tasks = []
1566-
for i in range(self.task_list.count()):
1567-
item = self.task_list.item(i)
1568-
task_widget = self.task_list.itemWidget(item)
1569-
if task_widget:
1570-
tasks.append(
1571-
{
1572-
"name": task_widget.task_name,
1573-
"status": task_widget.status,
1574-
"progress": (
1575-
task_widget.progress_bar.value()
1576-
if hasattr(task_widget, "progress_bar")
1577-
else 0
1578-
),
1579-
"log_file": task_widget.log_file,
1580-
}
1581-
)
1582-
return tasks
1583-
15841554
def generate_imatrix(self):
15851555
self.logger.info(STARTING_IMATRIX_GENERATION)
15861556
try:

Diff for: src/utils.py

+35
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from PySide6.QtCore import Qt
12
from PySide6.QtWidgets import QFileDialog
23

34
from error_handling import show_error
@@ -8,6 +9,40 @@
89
from imports_and_globals import ensure_directory
910

1011

12+
def get_models_data(self):
13+
models = []
14+
root = self.model_tree.invisibleRootItem()
15+
child_count = root.childCount()
16+
for i in range(child_count):
17+
item = root.child(i)
18+
model_name = item.text(0)
19+
model_type = "sharded" if "sharded" in model_name.lower() else "single"
20+
model_path = item.data(0, Qt.ItemDataRole.UserRole)
21+
models.append({"name": model_name, "type": model_type, "path": model_path})
22+
return models
23+
24+
25+
def get_tasks_data(self):
26+
tasks = []
27+
for i in range(self.task_list.count()):
28+
item = self.task_list.item(i)
29+
task_widget = self.task_list.itemWidget(item)
30+
if task_widget:
31+
tasks.append(
32+
{
33+
"name": task_widget.task_name,
34+
"status": task_widget.status,
35+
"progress": (
36+
task_widget.progress_bar.value()
37+
if hasattr(task_widget, "progress_bar")
38+
else 0
39+
),
40+
"log_file": task_widget.log_file,
41+
}
42+
)
43+
return tasks
44+
45+
1146
def browse_models(self):
1247
self.logger.info(BROWSING_FOR_MODELS_DIRECTORY)
1348
models_path = QFileDialog.getExistingDirectory(self, SELECT_MODELS_DIRECTORY)

0 commit comments

Comments
 (0)