Draft: refactor DataPartition
Details
-
refactor DataPartitionWidgetOW
andDataPartitionWidget
. -
update example. -
make sure the ewoks task is called during processing -
add test -
make sure GUI is updated from loaded .ows and any modification at the gui level will be applied to the saved .ows -
fix issue when move a widget once processed (see below)
To be merge first
note: in theory it would require workflow/ewoks/ewoksorange!120 (merged) But in the fact the 'abort' button is always hidden. So user can never cancel processing. But better handle those before for coherence.
current processing of the widget:
Today this widget is combining two operations:
-
_computeHistogram
: callcompute_frames_intensity
and display the histogram (_showHistogram
). Hopefully this one is only used for display. So we don't need to compute it when not using the gui. -
_computePartition
: compute partition and setindices
andbg_indices
fromDataset.partition_by_intensity
and emitsigComputed
to send the signal to next task.
note: the ewoks task was false anyway. So no execution from ewoks-execute was possible.
question:
- check how to handle load / save of settings from the .ows file
error when moving a widget position once processed
If doing this then we end up with the following error:
Traceback (most recent call last):
File "/home/payno/dev/esrf/darkfield/venv/lib/python3.11/site-packages/orangecanvas/application/canvasmain.py", line 1617, in save_swp
self.save_swp_to(swpname)
File "/home/payno/dev/esrf/darkfield/venv/lib/python3.11/site-packages/orangecanvas/application/canvasmain.py", line 1626, in save_swp_to
propertiesDiff = document.uncleanProperties()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/payno/dev/esrf/darkfield/venv/lib/python3.11/site-packages/orangecanvas/document/schemeedit.py", line 698, in uncleanProperties
return list(dictdiffer.diff(
^^^^^^^^^^^^^^^^^^^^^
File "/home/payno/dev/esrf/darkfield/venv/lib/python3.11/site-packages/dictdiffer/__init__.py", line 215, in _diff_recursive
for diffed in recurred:
File "/home/payno/dev/esrf/darkfield/venv/lib/python3.11/site-packages/dictdiffer/__init__.py", line 215, in _diff_recursive
for diffed in recurred:
File "/home/payno/dev/esrf/darkfield/venv/lib/python3.11/site-packages/dictdiffer/__init__.py", line 253, in _diff_recursive
yield ADD, dotted_node, [
^
File "/home/payno/dev/esrf/darkfield/venv/lib/python3.11/site-packages/dictdiffer/__init__.py", line 256, in <listcomp>
(key, deepcopy(_second[key])) for key in addition]
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/copy.py", line 172, in deepcopy
y = _reconstruct(x, memo, *rv)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/copy.py", line 271, in _reconstruct
state = deepcopy(state, memo)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/copy.py", line 146, in deepcopy
y = copier(x, memo)
^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/copy.py", line 231, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/copy.py", line 161, in deepcopy
rv = reductor(4)
^^^^^^^^^^^
TypeError: cannot pickle 'DataSelectionWidgetOW' object
-------------------------------------------------------------------------------
This issue comes from having previously some functools.partial which seems to make settings saving failed. The following fix it:
- self._widget.sigNbBinsChanged.connect(
- functools.partial(
- self.set_default_input,
- "bins",
- self._widget.getBins,
- )
- )
- self._widget.sigBottomBinChanged.connect(
- functools.partial(
- self.set_default_input,
- "filter_bottom_bin_idx",
- self._widget.getBottomBin,
- )
- )
- self._widget.sigTopBinChanged.connect(
- functools.partial(
- self.set_default_input,
- "filter_top_bin_idx",
- self._widget.getTopBin,
- )
- )
+ self._widget.sigNbBinsChanged.connect(self._updateNbBins)
+ self._widget.sigBottomBinChanged.connect(self._updateBottomBin)
+ self._widget.sigTopBinChanged.connect(self._updateTopBin)
+
+ def _updateNbBins(self, nb_bins):
+ self.set_default_input("bins", nb_bins)
+
+ def _updateBottomBin(self, value):
+ self.set_default_input("filter_bottom_bin_idx", value)
+
+ def _updateTopBin(self, value):
+ self.set_default_input("filter_top_bin_idx", value)
Edited by payno