Skip to content

Commit

Permalink
enh: when batch-loading datasets, allow individual files to fail
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Jan 15, 2025
1 parent 37a20e7 commit c96033e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
2.21.2
- enh: when batch-loading datasets, allow individual files to fail
2.21.1
- fix: maximize image size in QuickView
- fix: colormap for QPI data only updating for one image view in QuickView
Expand Down
25 changes: 24 additions & 1 deletion shapeout2/gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,8 @@ def add_dataslot(self, paths=None, is_dcor=False):
self.toolButton_new_plot.setEnabled(True)
self.block_matrix.toolButton_new_plot.setEnabled(True)

failed_paths = []

slot_ids = []
# Create Dataslot instance and update block matrix
self.setUpdatesEnabled(False)
Expand All @@ -432,9 +434,19 @@ def add_dataslot(self, paths=None, is_dcor=False):
# add a filter if we don't have one already
if self.pipeline.num_filters == 0:
self.add_filter()
slot_id = self.pipeline.add_slot(path=path)
try:
slot_id = self.pipeline.add_slot(path=path)
except BaseException:
if len(paths) == 1:
# Let the user know immediately
raise
else:
failed_paths.append(path)
continue

self.block_matrix.add_dataset(slot_id=slot_id)
slot_ids.append(slot_id)

self.setUpdatesEnabled(True)
self.repaint()

Expand All @@ -444,6 +456,17 @@ def add_dataslot(self, paths=None, is_dcor=False):
self.widget_ana_view.widget_slot.update_content()
# redraw
self.block_matrix.update()

if failed_paths:
failed_text = ("The following files could not be loaded. You can "
"open them individually to see the corresponding "
"error message during loading.\n")
for path in failed_paths:
failed_text += f"- {path}\n"
QtWidgets.QMessageBox.warning(self,
"Failed to load some datasets",
failed_text)

return slot_ids

@QtCore.pyqtSlot()
Expand Down

0 comments on commit c96033e

Please sign in to comment.