diff --git a/src/ert/ensemble_evaluator/_builder/_step.py b/src/ert/ensemble_evaluator/_builder/_step.py index f6723b2cd2c..26db2fb3dfb 100644 --- a/src/ert/ensemble_evaluator/_builder/_step.py +++ b/src/ert/ensemble_evaluator/_builder/_step.py @@ -5,7 +5,6 @@ from ert.config.ext_job import ExtJob -SOURCE_TEMPLATE_STEP = "/step/{step_id}" if TYPE_CHECKING: from ert.run_arg import RunArg diff --git a/src/ert/gui/model/job_list.py b/src/ert/gui/model/job_list.py index 8eb26340469..388df022c8d 100644 --- a/src/ert/gui/model/job_list.py +++ b/src/ert/gui/model/job_list.py @@ -17,7 +17,6 @@ IsEnsembleRole, IsJobRole, IsRealizationRole, - IsStepRole, IsJobRole, NodeRole, ) @@ -125,27 +124,34 @@ def index(self, row: int, column: int, parent=None) -> QModelIndex: if parent.isValid(): return QModelIndex() print("def index") - created_index = self.createIndex(row, column, parent) + proxy_index = self.createIndex(row, column, parent) print("index created") - job_index = self.mapToSource(created_index) - job_index.data(NodeRole) - print(f"creating inee3x, {row=}, {column=}, {NodeRole}, job_index.data = {job_index.data(NodeRole)}") + job_index = self.mapToSource(proxy_index) + for role_add in range(13): + print(f"creating index, {row=}, {column=}, {role_add}, job_index.data = {job_index.data(Qt.UserRole + role_add)}") ret_index = self.createIndex(row, column, job_index.data(NodeRole)) print(f"{job_index=}, {column=}, {ret_index=}") + # if column == 2: + # breakpoint() print(f"{job_index.data(NodeRole)=}") # this gives None when column=2 return ret_index # pylint: disable=invalid-name def mapToSource(self, proxyIndex: QModelIndex) -> QModelIndex: + print(f"mapToSource: {proxyIndex.row()=}, {proxyIndex.column()=}") if not proxyIndex.isValid(): return QModelIndex() source_model = self.sourceModel() iter_index = source_model.index(self._iter, 0, QModelIndex()) + print(f"mapToSource: {iter_index=} {self._iter=} {iter_index.row()=}, {iter_index.column()=}") if not iter_index.isValid() or not source_model.hasChildren(iter_index): + print("mapToSource: iter_index return?") return QModelIndex() real_index = source_model.index(self._real, 0, iter_index) if not real_index.isValid() or not source_model.hasChildren(real_index): + print("mapToSource: real_index return?") return QModelIndex() + print("now doing job_index = source.model.index()") job_index = source_model.index( proxyIndex.row(), proxyIndex.column(), real_index ) diff --git a/src/ert/gui/model/snapshot.py b/src/ert/gui/model/snapshot.py index 8128c0a2952..42310bcebb3 100644 --- a/src/ert/gui/model/snapshot.py +++ b/src/ert/gui/model/snapshot.py @@ -27,9 +27,8 @@ # Indicates what type the underlying data is IsEnsembleRole = Qt.UserRole + 8 IsRealizationRole = Qt.UserRole + 9 -IsStepRole = Qt.UserRole + 10 -IsJobRole = Qt.UserRole + 11 -StatusRole = Qt.UserRole + 12 +IsJobRole = Qt.UserRole + 10 +StatusRole = Qt.UserRole + 11 JOB_COLUMN_NAME = "Name" JOB_COLUMN_ERROR = "Error" @@ -278,9 +277,6 @@ def _add_snapshot(self, snapshot: Snapshot, iter_: int): NodeType.REAL, ) snapshot_tree.add_child(real_node) - # for step_id, step in snapshot.steps(real_id).items(): - # step_node = Node(step_id, {ids.STATUS: step.status}, NodeType.STEP) - # real_node.add_child(step_node) for job_id in metadata[SORTED_JOB_IDS][real_id]: job = snapshot.get_job(real_id, job_id) job_dict = dict(job) # verified to be ok! @@ -326,22 +322,15 @@ def parent(self, index: QModelIndex): if not index.isValid(): return QModelIndex() - child_item = index.internalPointer() - if not hasattr(child_item, "parent"): - raise ValueError( - f"index r{index.row()}/c{index.column()} pointed to parent-less item " - + f"{child_item}" - ) - parentItem = child_item.parent - - if parentItem == self.root: + parent_item = index.internalPointer().parent + if parent_item == self.root: return QModelIndex() - return self.createIndex(parentItem.row(), 0, parentItem) + return self.createIndex(parent_item.row(), 0, parent_item) # pylint: disable=too-many-return-statements def data(self, index: QModelIndex, role=Qt.DisplayRole): - print(f"snapshot.data(), {role=}") + print(f"snapshot.data(), {role=}, {index.column()=}") if not index.isValid(): return QVariant() @@ -482,19 +471,32 @@ def _job_data(self, index: QModelIndex, node: Node, role: int): def index(self, row: int, column: int, parent: QModelIndex = None) -> QModelIndex: if parent is None: # we are at the root. - print("we are at the root") + print("mapToSource: we are at the root") parent = QModelIndex() + if not parent.isValid(): + print("mapToSource: parent is root") + elif not parent.parent().isValid(): + print("mapToSource: parent is iteration") + elif not parent.parent().parent().isValid(): + print("mapToSource: parent is realization") + elif not parent.parent().parent().parent().isValid(): + print("mapToSource: parent is job") + elif not parent.parent().parent().parent().parent().isValid(): + print("mapToSource: subjob calling") + elif not parent.parent().parent().parent().parent().parent().isValid(): + print("mapToSource: subsubjob calling") if not self.hasIndex(row, column, parent): + print(f"mapToSource: line 487, {parent.data()=}, {parent.row()=} {parent.column()=}") + #print(f"mapToSour: {len(parent.internalPointer().children.values())=}") return QModelIndex() - #print(f"snapshot.index: {row=}, {column=}, {parent=}, {parent.isValid()=}, {parent.data()=}") + print(f"mapToSour: snapshot.index: {row=}, {column=}, {parent=}, {parent.isValid()=}, {parent.data()=}") parent_item = self.root if not parent.isValid() else parent.internalPointer() - + print(f"mapToSour: {len(parent_item.children.values())=}") child_item = None try: child_item = list(parent_item.children.values())[row] except KeyError: - print(f"got index/keyerror, {row=}, {column=}, {parent=}") return QModelIndex() else: return self.createIndex(row, column, child_item) diff --git a/tests/unit_tests/gui/model/test_job_list.py b/tests/unit_tests/gui/model/test_job_list.py index 7205470c3c0..bada67f22f8 100644 --- a/tests/unit_tests/gui/model/test_job_list.py +++ b/tests/unit_tests/gui/model/test_job_list.py @@ -62,7 +62,7 @@ def test_changes(full_snapshot): source_model._add_snapshot(SnapshotModel.prerender(full_snapshot), 0) assert ( - model.index(0, _id_to_col(ids.STATUS), QModelIndex()).data() == JOB_STATE_START + model.index(0, _id_to_col(ids.STATUS)).data() == JOB_STATE_START ) partial = PartialSnapshot(full_snapshot)