From 8f6255c2cd269f56c6bdcb45d7792537a54a1ee6 Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Rouby Date: Fri, 26 Sep 2025 14:27:19 +0200 Subject: [PATCH] Results: Update to async db load for results. --- src/Model/Results/Results.py | 2 +- src/Model/Study.py | 5 +++++ src/View/MainWindow.py | 34 ++++++++++++++++++++++------------ 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/Model/Results/Results.py b/src/Model/Results/Results.py index fc5a7fe4..e027b67f 100644 --- a/src/Model/Results/Results.py +++ b/src/Model/Results/Results.py @@ -169,7 +169,7 @@ class Results(SQLSubModel): new = new_results - return new + yield new def _db_save(self, execute, data=None): if self._status.scenario.id != self._owner_scenario: diff --git a/src/Model/Study.py b/src/Model/Study.py index d1dd8013..47d4a83e 100644 --- a/src/Model/Study.py +++ b/src/Model/Study.py @@ -17,6 +17,7 @@ # -*- coding: utf-8 -*- import os +import types import shutil import logging from datetime import datetime @@ -530,6 +531,10 @@ class Study(SQLModel): @property def results(self): + results = self._river._results + if isinstance(results, types.GeneratorType): + self._river._results = next(results) + return self._river._results @results.setter diff --git a/src/View/MainWindow.py b/src/View/MainWindow.py index ea122508..68554ac6 100644 --- a/src/View/MainWindow.py +++ b/src/View/MainWindow.py @@ -573,7 +573,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): def setup_results(self): self._last_solver = None - self._last_results = None + self.last_results = None default = None @@ -590,10 +590,23 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): # Last solver note found, use default-mage if exists self._last_solver = default + @property + def last_results(self): + if self._study is None: + return None + + return self._study.results + + @last_results.setter + def last_results(self, results): + if self._study is None: + return + + self._study.results = results + def set_results(self, solver, results): self._last_solver = solver - self._last_results = results - self._study.results = results + self.last_results = results self.enable_actions("action_menu_results_last", True) @@ -1479,9 +1492,9 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): # If no specific results, get last results if results is None: def reading_fn(): - self._tmp_results = self._last_results + self._tmp_results = self.last_results - if self._last_results is None: + if self.last_results is None: def reading_fn(): self._tmp_results = solver.results( self._study, @@ -1543,9 +1556,9 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): # If no specific results, get last results if results is None: def reading_fn(): - self._tmp_results = self._last_results + self._tmp_results = self.last_results - if self._last_results is None: + if self.last_results is None: def reading_fn(): self._tmp_results = solver.results( self._study, @@ -1608,15 +1621,12 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): if self._last_solver is None: return - if self._study is not None and self._study.results is not None: - self._last_results = self._study.results - if self._last_solver._type == "mage8": self.open_solver_results(self._last_solver, - self._last_results) + self.last_results) elif self._last_solver._type == "adistswc": self.open_solver_results_adists(self._last_solver, - self._last_results) + self.last_results) def open_results_from_file(self): if self._study is None: