def test_progression_start_iter_not_zero(full_snapshot): source_model = SnapshotModel() model = ProgressProxyModel(source_model, parent=None) reporting_mode = qt_api.QtTest.QAbstractItemModelTester.FailureReportingMode.Warning tester = qt_api.QtTest.QAbstractItemModelTester( # noqa, prevent GC model, reporting_mode) source_model._add_snapshot(SnapshotModel.prerender(full_snapshot), 1) assert model.data(model.index(0, 0, QModelIndex()), ProgressRole) == { "nr_reals": 100, "status": { REALIZATION_STATE_UNKNOWN: 100 }, } partial = PartialSnapshot(full_snapshot) partial.update_real("0", Realization(status=REALIZATION_STATE_FINISHED)) source_model._add_partial_snapshot(SnapshotModel.prerender(partial), 1) assert model.data(model.index(0, 0, QModelIndex()), ProgressRole) == { "nr_reals": 100, "status": { REALIZATION_STATE_UNKNOWN: 99, REALIZATION_STATE_FINISHED: 1 }, }
def partial_snapshot(snapshot) -> PartialSnapshot: partial = PartialSnapshot(snapshot) partial.update_real("0", Realization(status=JOB_STATE_FINISHED)) partial.update_job("0", "0", "0", Job(status=JOB_STATE_FINISHED)) return partial
def _create_partial_snapshot( self, run_context: ErtRunContext, detailed_progress: typing.Tuple[typing.Dict, int], iter_: int, ) -> typing.Optional[PartialSnapshot]: """Create a PartialSnapshot, or None if the sources of data were destroyed or had not been created yet. Both run_context and detailed_progress needs to be aligned with the stars if job status etc is to be produced. If queue_snapshot is set, this means the the differ will not be used to calculate changes.""" queue = self._iter_queue.get(iter_, None) if queue is None: logger.debug(f"no queue for {iter_}, no partial returned") return None queue_snapshot = queue.snapshot() snapshot = self._iter_snapshot.get(iter_, None) if snapshot is None: logger.debug(f"no snapshot for {iter_}, no partial returned") return None partial = PartialSnapshot(snapshot) if queue_snapshot is not None: for iens, change in queue_snapshot.items(): change_enum = JobStatusType.from_string(change) partial.update_real( str(iens), Realization( status=queue_status_to_real_state(change_enum)), ) iter_to_progress, progress_iter = detailed_progress if not iter_to_progress: logger.debug(f"partial: no detailed progress for iter:{iter_}") return partial if iter_ != progress_iter: logger.debug( f"partial: iter_to_progress iter ({progress_iter}) differed from run_context ({iter_})" ) for iens, _ in _enumerate_run_context(run_context): if not _is_iens_active(iens, run_context): continue progress = iter_to_progress[iter_].get(iens, None) if not progress: continue jobs = progress[0] for idx, fm in enumerate(jobs): partial.update_job( str(iens), # real_id "0", str(idx), Job( status=_map_job_state(fm.status), start_time=fm.start_time, end_time=fm.end_time, data={ CURRENT_MEMORY_USAGE: fm.current_memory_usage, MAX_MEMORY_USAGE: fm.max_memory_usage, }, stdout=fm.std_out_file, stderr=fm.std_err_file, error=fm.error, ), ) return partial