Results: Update to async db load for results.

This commit is contained in:
parouby committed 2025-09-26 14:27:19 +02:00
1 parent 6c4f6e269c
commit 8f6255c2cd
3 files changed
+28 -13

No files matched your search

+1 -1
View File
@@ -169,7 +169,7 @@ class Results(SQLSubModel):
new = new_results new = new_results
return new yield new
def _db_save(self, execute, data=None): def _db_save(self, execute, data=None):
if self._status.scenario.id != self._owner_scenario: if self._status.scenario.id != self._owner_scenario:
+5
View File
@@ -17,6 +17,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import os import os
import types
import shutil import shutil
import logging import logging
from datetime import datetime from datetime import datetime
@@ -530,6 +531,10 @@ class Study(SQLModel):
@property @property
def results(self): def results(self):
results = self._river._results
if isinstance(results, types.GeneratorType):
self._river._results = next(results)
return self._river._results return self._river._results
@results.setter @results.setter
+22 -12
View File
@@ -573,7 +573,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
def setup_results(self): def setup_results(self):
self._last_solver = None self._last_solver = None
self._last_results = None self.last_results = None
default = None default = None
@@ -590,10 +590,23 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
# Last solver note found, use default-mage if exists # Last solver note found, use default-mage if exists
self._last_solver = default 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): def set_results(self, solver, results):
self._last_solver = solver self._last_solver = solver
self._last_results = results self.last_results = results
self._study.results = results
self.enable_actions("action_menu_results_last", True) 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 no specific results, get last results
if results is None: if results is None:
def reading_fn(): 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(): def reading_fn():
self._tmp_results = solver.results( self._tmp_results = solver.results(
self._study, self._study,
@@ -1543,9 +1556,9 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
# If no specific results, get last results # If no specific results, get last results
if results is None: if results is None:
def reading_fn(): 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(): def reading_fn():
self._tmp_results = solver.results( self._tmp_results = solver.results(
self._study, self._study,
@@ -1608,15 +1621,12 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
if self._last_solver is None: if self._last_solver is None:
return 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": if self._last_solver._type == "mage8":
self.open_solver_results(self._last_solver, self.open_solver_results(self._last_solver,
self._last_results) self.last_results)
elif self._last_solver._type == "adistswc": elif self._last_solver._type == "adistswc":
self.open_solver_results_adists(self._last_solver, self.open_solver_results_adists(self._last_solver,
self._last_results) self.last_results)
def open_results_from_file(self): def open_results_from_file(self):
if self._study is None: if self._study is None: