tomwer 1.4.0rc6__py3-none-any.whl → 1.4.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. orangecontrib/tomwer/tutorials/simple_volume_to_slurm_reconstruction.ows +2 -2
  2. orangecontrib/tomwer/widgets/reconstruction/AxisOW.py +19 -47
  3. orangecontrib/tomwer/widgets/reconstruction/NabuOW.py +8 -3
  4. orangecontrib/tomwer/widgets/reconstruction/NabuVolumeOW.py +4 -6
  5. orangecontrib/tomwer/widgets/reconstruction/SAAxisOW.py +8 -4
  6. orangecontrib/tomwer/widgets/reconstruction/SADeltaBetaOW.py +0 -4
  7. orangecontrib/tomwer/widgets/reconstruction/SinoNormOW.py +1 -13
  8. tomwer/app/axis.py +0 -1
  9. tomwer/app/intensitynormalization.py +0 -14
  10. tomwer/app/multicor.py +1 -33
  11. tomwer/app/multipag.py +1 -31
  12. tomwer/app/nabuapp.py +0 -1
  13. tomwer/app/patchrawdarkflat.py +0 -3
  14. tomwer/app/reducedarkflat.py +0 -1
  15. tomwer/core/process/control/datalistener/datalistener.py +0 -232
  16. tomwer/core/process/control/datawatcher/datawatcher.py +0 -5
  17. tomwer/core/process/control/scantransfer.py +3 -60
  18. tomwer/core/process/edit/darkflatpatch.py +0 -8
  19. tomwer/core/process/edit/imagekeyeditor.py +2 -19
  20. tomwer/core/process/reconstruction/axis/axis.py +0 -13
  21. tomwer/core/process/reconstruction/darkref/darkrefs.py +0 -59
  22. tomwer/core/process/reconstruction/nabu/nabuslices.py +0 -88
  23. tomwer/core/process/reconstruction/nabu/nabuvolume.py +0 -10
  24. tomwer/core/process/reconstruction/params_cache.py +36 -0
  25. tomwer/core/process/reconstruction/saaxis/saaxis.py +80 -88
  26. tomwer/core/process/reconstruction/sadeltabeta/sadeltabeta.py +78 -86
  27. tomwer/core/process/reconstruction/tests/test_params_cache.py +37 -0
  28. tomwer/core/process/script/python.py +0 -19
  29. tomwer/core/process/task.py +0 -290
  30. tomwer/core/process/tests/test_dark_and_flat.py +0 -6
  31. tomwer/core/process/tests/test_data_transfer.py +0 -1
  32. tomwer/core/process/tests/test_data_watcher.py +6 -23
  33. tomwer/core/scan/edfscan.py +0 -11
  34. tomwer/core/scan/nxtomoscan.py +0 -12
  35. tomwer/core/scan/scanbase.py +0 -81
  36. tomwer/gui/reconstruction/axis/CalculationWidget.py +3 -5
  37. tomwer/gui/reconstruction/tests/test_saaxis.py +2 -2
  38. tomwer/gui/reconstruction/tests/test_sadeltabeta.py +2 -2
  39. tomwer/gui/stitching/config/axisparams.py +2 -0
  40. tomwer/synctools/stacks/reconstruction/axis.py +0 -18
  41. tomwer/synctools/tests/test_foldertransfer.py +2 -19
  42. tomwer/tests/orangecontrib/tomwer/widgets/reconstruction/tests/test_i_norm.py +0 -10
  43. tomwer/tests/orangecontrib/tomwer/widgets/reconstruction/tests/test_sa_delta_beta.py +103 -153
  44. tomwer/tests/orangecontrib/tomwer/widgets/reconstruction/tests/test_saaxis.py +117 -152
  45. tomwer/tests/orangecontrib/tomwer/widgets/{tests/test_darkref.py → test_darkref.py} +0 -9
  46. tomwer/tests/orangecontrib/tomwer/widgets/{tests/test_foldertransfert.py → test_foldertransfert.py} +1 -1
  47. tomwer/tests/test_ewoks/test_workflows.py +0 -4
  48. tomwer/version.py +3 -3
  49. {tomwer-1.4.0rc6.dist-info → tomwer-1.4.1.dist-info}/METADATA +1 -2
  50. {tomwer-1.4.0rc6.dist-info → tomwer-1.4.1.dist-info}/RECORD +55 -56
  51. tomwer/core/scan/tests/test_process_registration.py +0 -64
  52. tomwer/core/utils/Singleton.py +0 -36
  53. tomwer/core/utils/locker.py +0 -58
  54. /tomwer/tests/orangecontrib/tomwer/widgets/{tests/test_conditions.py → test_conditions.py} +0 -0
  55. {tomwer-1.4.0rc6.dist-info → tomwer-1.4.1.dist-info}/LICENSE +0 -0
  56. {tomwer-1.4.0rc6.dist-info → tomwer-1.4.1.dist-info}/WHEEL +0 -0
  57. {tomwer-1.4.0rc6.dist-info → tomwer-1.4.1.dist-info}/entry_points.txt +0 -0
  58. {tomwer-1.4.0rc6.dist-info → tomwer-1.4.1.dist-info}/top_level.txt +0 -0
@@ -11,7 +11,6 @@ from silx.gui import qt
11
11
  from tomwer.core.process.reconstruction.axis import AxisTask
12
12
  from tomwer.core.process.reconstruction.axis.axis import NoAxisUrl
13
13
  from tomwer.core.process.reconstruction.axis.mode import AxisMode
14
- from tomwer.core.scan.nxtomoscan import NXtomoScan
15
14
  from tomwer.core.scan.scanbase import TomwerScanBase
16
15
  from tomwer.core.settings import get_lbsram_path, isOnLbsram
17
16
  from tomwer.core.utils.lbsram import is_low_on_memory
@@ -63,23 +62,6 @@ class AxisProcessStack(FIFO, qt.QObject):
63
62
  cor = 0
64
63
  data._axis_params.set_relative_value(cor)
65
64
  cor = data._axis_params.relative_cor_value
66
- if isinstance(data, NXtomoScan):
67
- entry = data.entry
68
- else:
69
- entry = "entry"
70
- try:
71
- with data.acquire_process_file_lock():
72
- AxisTask._register_process(
73
- process_file=data.process_file,
74
- entry=entry,
75
- process=AxisTask,
76
- results={"center_of_rotation": cor if cor is not None else "-"},
77
- configuration=self._axis_params.to_dict(),
78
- process_index=data.pop_process_index(),
79
- overwrite=True,
80
- )
81
- except Exception as e:
82
- _logger.warning(f"Fail to register Axis process. Reason is {e}")
83
65
  # If mode is read or manual the position_value is not computed and
84
66
  # we will keep the actual one (should have been defined previously)
85
67
  self._end_computation(data=data, future_tomo_obj=None, callback=callback)
@@ -195,10 +195,10 @@ class TestEDFDataTransfert(TestCaseQt):
195
195
  def checkDataCopied(self):
196
196
  outputFiles = os.listdir(self.outputdir)
197
197
  inputFile = glob(self.sourcedir)
198
- # + 3 because .info and .xml are count + one tomwer_processes file
198
+ # + 3 because .info and .xml are count
199
199
  return (
200
200
  (len(inputFile) == 0)
201
- and (len(outputFiles) == (self.n_file + 3))
201
+ and (len(outputFiles) == (self.n_file + 2))
202
202
  and (not os.path.isdir(self.sourcedir))
203
203
  )
204
204
 
@@ -247,23 +247,6 @@ class TestHDFDataTransfert(TestCaseQt):
247
247
  assert os.path.isfile(output_file_path)
248
248
  self.scan = NXtomoScan(scan=output_file_path, entry=entry)
249
249
 
250
- # register information regarding origin of the file
251
- from tomwer.core.process.control.datalistener import DataListener
252
-
253
- DataListener._register_process(
254
- process_file=self.scan.process_file,
255
- process=DataListener,
256
- entry=self.scan.entry,
257
- results={"output_file": self.scan.master_file, "entry": self.scan.entry},
258
- configuration={
259
- "sample_file": self._sample_file,
260
- "entry": self._sample_file_entry,
261
- "file_proposal": self._proposal_file,
262
- },
263
- process_index=self.scan.pop_process_index(),
264
- overwrite=True,
265
- )
266
-
267
250
  def tearDown(self):
268
251
  for dir_ in (self.input_dir, self.output_dir):
269
252
  shutil.rmtree(dir_)
@@ -12,16 +12,13 @@ from orangecanvas.scheme.readwrite import literal_dumps
12
12
  from processview.core.manager import DatasetState, ProcessManager
13
13
  from silx.gui import qt
14
14
  from silx.gui.utils.testutils import TestCaseQt
15
- from silx.io.utils import h5py_read_dataset
16
15
 
17
16
  from orangecontrib.tomwer.widgets.reconstruction.SinoNormOW import (
18
17
  SinoNormOW as _NormIOW,
19
18
  )
20
19
  from tomwer.core import settings
21
20
  from tomwer.core.utils.lbsram import mock_low_memory
22
- from tomwer.core.process.reconstruction.normalization import SinoNormalizationTask
23
21
  from tomwer.core.utils.scanutils import MockNXtomo
24
- from tomwer.io.utils.h5pyutils import EntryReader
25
22
 
26
23
  logger = logging.getLogger(__name__)
27
24
 
@@ -191,10 +188,3 @@ class TestProcessing(TestCaseQt):
191
188
  ),
192
189
  DatasetState.SUCCEED,
193
190
  )
194
- # test process file has been updated
195
- with EntryReader(scan.process_file_url) as entry:
196
- self.assertTrue("tomwer_process_0" in entry)
197
- self.assertEqual(
198
- h5py_read_dataset(entry["tomwer_process_0"]["program"]),
199
- SinoNormalizationTask.program_name(),
200
- )
@@ -1,37 +1,31 @@
1
- import gc
2
1
  import logging
3
2
  import os
4
3
  import pickle
5
- import shutil
6
- import tempfile
7
- import uuid
8
4
 
9
- import h5py
10
5
  import numpy
11
6
  from orangecanvas.scheme.readwrite import literal_dumps
12
7
  from processview.core.manager import DatasetState, ProcessManager
13
- from silx.gui import qt
14
- from silx.gui.utils.testutils import TestCaseQt
15
8
  from silx.io.url import DataUrl
9
+ from silx.gui import qt
16
10
 
17
11
  from orangecontrib.tomwer.widgets.reconstruction.SADeltaBetaOW import (
18
12
  SADeltaBetaOW as _SADeltaBetaOW,
19
13
  )
20
- from tomwer.core import settings
21
- from tomwer.core.utils.lbsram import mock_low_memory
22
14
  from tomwer.core.process.reconstruction.scores import ComputedScore
23
15
  from tomwer.core.utils.scanutils import MockNXtomo
16
+ from tomwer.tests.conftest import qtapp # noqa F401
24
17
 
25
18
  logger = logging.getLogger(__name__)
26
19
 
27
20
 
28
21
  class SADeltaBetaOW(_SADeltaBetaOW):
22
+ """class saving scan finished to keep a trace on those."""
23
+
29
24
  def __init__(self, parent=None):
30
25
  self._scans_finished = []
31
26
  super().__init__(parent)
32
27
 
33
28
  def processing_finished(self, scan):
34
- # TODO: add message processing finished
35
29
  self._scans_finished.append(scan)
36
30
 
37
31
  @property
@@ -43,152 +37,108 @@ class SADeltaBetaOW(_SADeltaBetaOW):
43
37
  super().close()
44
38
 
45
39
 
46
- class TestProcessing(TestCaseQt):
47
- DIM = 100
48
-
49
- def setUp(self):
50
- super().setUp()
51
- self._source_dir = tempfile.mkdtemp()
52
-
53
- def create_scan(folder_name):
54
- _dir = os.path.join(self._source_dir, folder_name)
55
- return MockNXtomo(
56
- scan_path=_dir,
57
- n_ini_proj=20,
58
- n_proj=20,
59
- n_alignement_proj=2,
60
- create_final_flat=False,
61
- create_ini_dark=True,
62
- create_ini_flat=True,
63
- n_refs=1,
64
- dim=self.DIM,
65
- ).scan
66
-
67
- # create scans
68
- self.scan_1 = create_scan("scan_1")
69
- self.scan_2 = create_scan("scan_2")
70
- self.scan_3 = create_scan("scan_3")
71
- self._process_manager = ProcessManager()
72
-
73
- self.widget = SADeltaBetaOW()
74
- self.widget.show()
75
-
76
- def patch_score(cor):
77
- data = numpy.random.random(TestProcessing.DIM * TestProcessing.DIM)
78
- data = data.reshape(TestProcessing.DIM, TestProcessing.DIM)
79
- slice_file_path = os.path.join(
80
- self._source_dir, str(uuid.uuid1()) + ".hdf5"
81
- )
82
- data_url = DataUrl(
83
- file_path=slice_file_path, data_path="data", scheme="silx"
84
- )
85
- with h5py.File(slice_file_path, mode="a") as h5f:
86
- h5f["data"] = data
87
- return data_url, ComputedScore(
88
- tv=numpy.random.random(),
89
- std=numpy.random.random(),
90
- )
91
-
92
- self.widget._widget._processing_stack.patch_processing(patch_score)
93
-
94
- def tearDown(self):
95
- mock_low_memory(False)
96
- settings.mock_lsbram(False)
97
- self.widget.setAttribute(qt.Qt.WA_DeleteOnClose)
98
- self.widget.close()
99
- self.widget = None
100
- self.qapp.processEvents()
101
- shutil.rmtree(self._source_dir)
102
- gc.collect()
103
-
104
- def test_serializing(self):
105
- pickle.dumps(self.widget.getConfiguration())
106
-
107
- def test_literal_dumps(self):
108
- literal_dumps(self.widget.getConfiguration())
109
-
110
- def testAutoFocusUnlock(self):
111
- self.widget.lockAutofocus(False)
112
-
113
- def manual_processing():
114
- self.widget.compute()
115
- self.qapp.processEvents()
116
- self.widget.wait_processing(5000)
117
- self.qapp.processEvents()
118
-
119
- self.widget.process(self.scan_1)
120
- manual_processing()
121
- self.assertEqual(
122
- self._process_manager.get_dataset_state(
123
- dataset_id=self.scan_1.get_identifier(),
124
- process=self.widget,
125
- ),
126
- DatasetState.WAIT_USER_VALIDATION,
127
- )
40
+ FRAME_DIM = 100
41
+
42
+
43
+ def create_scan(output_dir):
44
+ return MockNXtomo(
45
+ scan_path=output_dir,
46
+ n_ini_proj=20,
47
+ n_proj=20,
48
+ n_alignement_proj=2,
49
+ create_final_flat=False,
50
+ create_ini_dark=True,
51
+ create_ini_flat=True,
52
+ n_refs=1,
53
+ dim=FRAME_DIM,
54
+ ).scan
55
+
56
+
57
+ def patch_score(*args, **kwargs):
58
+ """Function to save some result"""
59
+ return DataUrl(
60
+ file_path="/no_existing/path.hdf5",
61
+ data_path="/no_existing_data_path",
62
+ scheme="silx",
63
+ ), ComputedScore(
64
+ tv=numpy.random.random(),
65
+ std=numpy.random.random(),
66
+ )
67
+
68
+
69
+ def test_SADeltaBetaOW(
70
+ qtapp, # noqa F811
71
+ tmp_path,
72
+ ):
73
+ source_dir = tmp_path / "source"
74
+ source_dir.mkdir()
128
75
 
129
- self.widget.process(self.scan_2)
130
- manual_processing()
131
- self.assertEqual(len(self.widget.scans_finished), 0)
132
- self.assertEqual(
133
- self._process_manager.get_dataset_state(
134
- dataset_id=self.scan_1.get_identifier(),
135
- process=self.widget,
136
- ),
137
- DatasetState.SKIPPED,
76
+ # create scans
77
+ scan_1 = create_scan(os.path.join(source_dir, "scan_1"))
78
+ scan_2 = create_scan(os.path.join(source_dir, "scan_2"))
79
+ scan_3 = create_scan(os.path.join(source_dir, "scan_3"))
80
+
81
+ process_manager = ProcessManager()
82
+
83
+ widget = SADeltaBetaOW()
84
+ widget.show()
85
+
86
+ widget._widget._processing_stack.patch_processing(patch_score)
87
+
88
+ # make sure the configuration is serializable
89
+ pickle.dumps(widget.getConfiguration())
90
+
91
+ # make sure this is compatible with 'literal dumps'
92
+ literal_dumps(widget.getConfiguration())
93
+
94
+ # test behavior when 'autofocus' is lock. (in this case we expect to take the dataset with the higher score) and continue
95
+ widget.lockAutofocus(False)
96
+
97
+ def manual_processing():
98
+ widget.compute()
99
+ qt.QApplication.processEvents()
100
+ widget.wait_processing(5000)
101
+ qt.QApplication.processEvents()
102
+
103
+ widget.process(scan_1)
104
+ manual_processing()
105
+ assert (
106
+ process_manager.get_dataset_state(
107
+ dataset_id=scan_1.get_identifier(),
108
+ process=widget,
138
109
  )
139
- self.assertEqual(
140
- self._process_manager.get_dataset_state(
141
- dataset_id=self.scan_2.get_identifier(),
142
- process=self.widget,
143
- ),
144
- DatasetState.WAIT_USER_VALIDATION,
110
+ == DatasetState.WAIT_USER_VALIDATION
111
+ )
112
+
113
+ widget.process(scan_2)
114
+ manual_processing()
115
+ assert len(widget.scans_finished) == 0
116
+ assert (
117
+ process_manager.get_dataset_state(
118
+ dataset_id=scan_1.get_identifier(),
119
+ process=widget,
145
120
  )
146
- self.widget.process(self.scan_3)
147
- manual_processing()
148
- self.widget.validateCurrentScan()
149
- self.assertEqual(
150
- self._process_manager.get_dataset_state(
151
- dataset_id=self.scan_3.get_identifier(),
152
- process=self.widget,
153
- ),
154
- DatasetState.SUCCEED,
121
+ == DatasetState.SKIPPED
122
+ )
123
+
124
+ assert (
125
+ process_manager.get_dataset_state(
126
+ dataset_id=scan_2.get_identifier(),
127
+ process=widget,
155
128
  )
156
- # insure a cor has been registered
157
- self.assertNotEqual(
158
- self.scan_3.sa_delta_beta_params.selected_delta_beta_value, None
129
+ == DatasetState.WAIT_USER_VALIDATION
130
+ )
131
+
132
+ widget.process(scan_3)
133
+ manual_processing()
134
+ widget.validateCurrentScan()
135
+ assert (
136
+ process_manager.get_dataset_state(
137
+ dataset_id=scan_3.get_identifier(),
138
+ process=widget,
159
139
  )
140
+ == DatasetState.SUCCEED
141
+ )
160
142
 
161
- def testTestLbsram(self):
162
- mock_low_memory(True)
163
- settings.mock_lsbram(True)
164
- for scan in (self.scan_1, self.scan_2, self.scan_3):
165
- self.widget.process(scan)
166
- self.widget.wait_processing(5000)
167
- self.qapp.processEvents()
168
-
169
- for scan in (self.scan_1, self.scan_2, self.scan_3):
170
- with self.subTest(scan=str(scan)):
171
- self.assertEqual(
172
- self._process_manager.get_dataset_state(
173
- dataset_id=scan.get_identifier(),
174
- process=self.widget,
175
- ),
176
- DatasetState.SKIPPED,
177
- )
178
-
179
- def testAutoFocusLock(self):
180
- self.widget.lockAutofocus(True)
181
- for scan in (self.scan_1, self.scan_2, self.scan_3):
182
- self.widget.process(scan)
183
- self.widget.wait_processing(5000)
184
- self.qapp.processEvents()
185
-
186
- for scan in (self.scan_1, self.scan_2, self.scan_3):
187
- with self.subTest(scan=str(scan)):
188
- self.assertEqual(
189
- self._process_manager.get_dataset_state(
190
- dataset_id=scan.get_identifier(),
191
- process=self.widget,
192
- ),
193
- DatasetState.SUCCEED,
194
- )
143
+ # ensure a cor has been registered
144
+ assert scan_3.sa_delta_beta_params.selected_delta_beta_value is not None