tomwer 1.3.6__py3-none-any.whl → 1.3.7__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.
- orangecontrib/tomwer/test/TestAcquisition.py +246 -0
- orangecontrib/tomwer/widgets/cluster/test/test_future_supervisorow.py +87 -0
- orangecontrib/tomwer/widgets/cluster/test/test_slurm_clusterow.py +67 -0
- orangecontrib/tomwer/widgets/control/test/test_advancement.py +51 -0
- orangecontrib/tomwer/widgets/control/test/test_data_validator.py +55 -0
- orangecontrib/tomwer/widgets/control/test/test_datadiscovery.py +131 -0
- orangecontrib/tomwer/widgets/control/test/test_datalist.py +70 -0
- orangecontrib/tomwer/widgets/control/test/test_datalistener.py +137 -0
- orangecontrib/tomwer/widgets/control/test/test_dataselector.py +95 -0
- orangecontrib/tomwer/widgets/control/test/test_datawatcher.py +436 -0
- orangecontrib/tomwer/widgets/control/test/test_emailow.py +29 -0
- orangecontrib/tomwer/widgets/control/test/test_notifier.py +51 -0
- orangecontrib/tomwer/widgets/control/test/test_nxtomo_concatenate_ow.py +64 -0
- orangecontrib/tomwer/widgets/control/test/test_nxtomomill.py +160 -0
- orangecontrib/tomwer/widgets/control/test/test_reduce_dark_flat_selector.py +40 -0
- orangecontrib/tomwer/widgets/control/test/test_singletomoobj.py +40 -0
- orangecontrib/tomwer/widgets/control/test/test_timerow.py +51 -0
- orangecontrib/tomwer/widgets/control/test/test_tomoobj_serie.py +96 -0
- orangecontrib/tomwer/widgets/control/test/test_volume_selector.py +69 -0
- orangecontrib/tomwer/widgets/control/test/test_volumesymlink.py +51 -0
- orangecontrib/tomwer/widgets/debugtools/test/test_dataset_generator.py +57 -0
- orangecontrib/tomwer/widgets/debugtools/test/test_object_inspector.py +62 -0
- orangecontrib/tomwer/widgets/other/test/test_pythonscript.py +31 -0
- orangecontrib/tomwer/widgets/reconstruction/test/test_axis.py +224 -0
- orangecontrib/tomwer/widgets/reconstruction/test/test_cast_volumeow.py +85 -0
- orangecontrib/tomwer/widgets/reconstruction/test/test_dark_refs_widget.py +136 -0
- orangecontrib/tomwer/widgets/reconstruction/test/test_delta_beta_selector.py +15 -0
- orangecontrib/tomwer/widgets/reconstruction/test/test_i_norm.py +226 -0
- orangecontrib/tomwer/widgets/reconstruction/test/test_nabu_helical_prepare_weights_double.py +20 -0
- orangecontrib/tomwer/widgets/reconstruction/test/test_nabu_volume.py +100 -0
- orangecontrib/tomwer/widgets/reconstruction/test/test_nabu_widget.py +107 -0
- orangecontrib/tomwer/widgets/reconstruction/test/test_sa_delta_beta.py +194 -0
- orangecontrib/tomwer/widgets/reconstruction/test/test_saaxis.py +220 -0
- orangecontrib/tomwer/widgets/stitching/test/test_zstitching.py +308 -0
- orangecontrib/tomwer/widgets/test/test_conditions.py +111 -0
- orangecontrib/tomwer/widgets/test/test_darkref.py +251 -0
- orangecontrib/tomwer/widgets/test/test_foldertransfert.py +131 -0
- orangecontrib/tomwer/widgets/visualization/test/test_dataviewerow.py +83 -0
- orangecontrib/tomwer/widgets/visualization/test/test_diffviewerow.py +65 -0
- orangecontrib/tomwer/widgets/visualization/test/test_live_sliceow.py +63 -0
- orangecontrib/tomwer/widgets/visualization/test/test_nxtomo_metadata_viewer.py +29 -0
- orangecontrib/tomwer/widgets/visualization/test/test_radio_stackow.py +56 -0
- orangecontrib/tomwer/widgets/visualization/test/test_sample_movedow.py +72 -0
- orangecontrib/tomwer/widgets/visualization/test/test_sinogram_viewerow.py +56 -0
- orangecontrib/tomwer/widgets/visualization/test/test_slice_stackow.py +57 -0
- orangecontrib/tomwer/widgets/visualization/test/test_volume_viewerow.py +57 -0
- tomwer/core/log/test/test_processlog.py +41 -0
- tomwer/core/process/edit/test/test_darkflatpatch.py +269 -0
- tomwer/core/process/edit/test/test_imagekey_editor.py +125 -0
- tomwer/core/process/icat/test/test_create_screenshots.py +98 -0
- tomwer/core/process/icat/test/test_gallery.py +170 -0
- tomwer/core/process/reconstruction/nabu/test/test_castvolume.py +143 -0
- tomwer/core/process/reconstruction/nabu/test/test_nabu_utils.py +203 -0
- tomwer/core/process/reconstruction/nabu/test/test_nabunormalization.py +222 -0
- tomwer/core/process/script/test/test_script.py +68 -0
- tomwer/core/process/stitching/test/test_metadataholder.py +17 -0
- tomwer/core/process/visualization/test/test_data_viewer.py +39 -0
- tomwer/core/process/visualization/test/test_diff_viewer.py +39 -0
- tomwer/core/process/visualization/test/test_image_stack_viewer.py +41 -0
- tomwer/core/process/visualization/test/test_radio_stack.py +39 -0
- tomwer/core/process/visualization/test/test_sample_moved.py +41 -0
- tomwer/core/process/visualization/test/test_sinogram_viewer.py +39 -0
- tomwer/core/process/visualization/test/test_slice_stack.py +39 -0
- tomwer/core/process/visualization/test/test_volume_viewer.py +39 -0
- tomwer/core/utils/test/test_image.py +30 -0
- tomwer/core/utils/test/test_nxtomo.py +66 -0
- tomwer/core/utils/test/test_scan_utils.py +46 -0
- tomwer/core/utils/test/test_time.py +6 -0
- tomwer/core/volume/test/test_volumes.py +21 -0
- tomwer/gui/control/serie/test/test_creator.py +451 -0
- tomwer/gui/control/serie/test/test_nxtomo_concatenate.py +21 -0
- tomwer/gui/icat/test/test_create_screenshots_gui.py +23 -0
- tomwer/gui/icat/test/test_gallery_gui.py +37 -0
- tomwer/gui/reconstruction/nabu/test/test_check.py +92 -0
- tomwer/gui/reconstruction/nabu/test/test_ctf.py +46 -0
- tomwer/gui/reconstruction/nabu/test/test_helical.py +21 -0
- tomwer/gui/reconstruction/nabu/test/test_nabu_preprocessing.py +81 -0
- tomwer/gui/reconstruction/normalization/test/test_intensity.py +119 -0
- tomwer/gui/stitching/config/tests/test_axisparams.py +25 -0
- tomwer/gui/stitching/tests/test_axis_ordered_list.py +21 -0
- tomwer/gui/stitching/tests/test_normalization.py +27 -0
- tomwer/gui/stitching/tests/test_preview.py +85 -0
- tomwer/gui/stitching/tests/test_stitching_raw.py +110 -0
- tomwer/gui/stitching/tests/test_z_stitching.py +67 -0
- tomwer/gui/stitching/tests/utils.py +79 -0
- tomwer/gui/stitching/z_stitching/tests/test_fine_estimation.py +35 -0
- tomwer/gui/stitching/z_stitching/tests/test_raw_estimation.py +215 -0
- tomwer/gui/stitching/z_stitching/tests/test_stitching_window.py +51 -0
- tomwer/gui/utils/test/test_completer.py +67 -0
- tomwer/gui/utils/test/test_line_selector.py +21 -0
- tomwer/gui/utils/test/test_splashscreen.py +8 -0
- tomwer/gui/utils/test/test_vignettes.py +68 -0
- tomwer/io/utils/test/test_raw_and_processed_data.py +10 -0
- tomwer/io/utils/test/test_utils.py +92 -0
- tomwer/synctools/stacks/reconstruction/castvolume.py +20 -5
- tomwer/tests/test_ewoks/test_conversion.py +104 -0
- tomwer/tests/test_ewoks/test_single_node_execution.py +112 -0
- tomwer/tests/test_ewoks/test_workflows.py +160 -0
- tomwer/version.py +1 -1
- {tomwer-1.3.6.dist-info → tomwer-1.3.7.dist-info}/METADATA +1 -1
- {tomwer-1.3.6.dist-info → tomwer-1.3.7.dist-info}/RECORD +107 -10
- /tomwer-1.3.6-py3.11-nspkg.pth → /tomwer-1.3.7-py3.11-nspkg.pth +0 -0
- {tomwer-1.3.6.dist-info → tomwer-1.3.7.dist-info}/LICENSE +0 -0
- {tomwer-1.3.6.dist-info → tomwer-1.3.7.dist-info}/WHEEL +0 -0
- {tomwer-1.3.6.dist-info → tomwer-1.3.7.dist-info}/entry_points.txt +0 -0
- {tomwer-1.3.6.dist-info → tomwer-1.3.7.dist-info}/namespace_packages.txt +0 -0
- {tomwer-1.3.6.dist-info → tomwer-1.3.7.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,92 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# /*##########################################################################
|
3
|
+
#
|
4
|
+
# Copyright (c) 2016-2017 European Synchrotron Radiation Facility
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the "Software"), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
14
|
+
# all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
# THE SOFTWARE.
|
23
|
+
#
|
24
|
+
# ###########################################################################*/
|
25
|
+
"""
|
26
|
+
contains utils for inputs and outputs
|
27
|
+
"""
|
28
|
+
|
29
|
+
__authors__ = ["H. Payno"]
|
30
|
+
__license__ = "MIT"
|
31
|
+
__date__ = "15/12/2021"
|
32
|
+
|
33
|
+
import os
|
34
|
+
|
35
|
+
import h5py
|
36
|
+
import numpy
|
37
|
+
from silx.io.url import DataUrl
|
38
|
+
from tomoscan.io import HDF5File
|
39
|
+
|
40
|
+
from tomwer.core.utils import scanutils
|
41
|
+
from tomwer.io.utils import (
|
42
|
+
get_default_directory,
|
43
|
+
get_linked_files_with_entry,
|
44
|
+
get_slice_data,
|
45
|
+
)
|
46
|
+
|
47
|
+
|
48
|
+
def test_get_linked_files_with_entry(tmp_path):
|
49
|
+
"""test get_linked_files_with_entry function"""
|
50
|
+
dir_test = tmp_path / "sub"
|
51
|
+
dir_test.mkdir()
|
52
|
+
|
53
|
+
layout = h5py.VirtualLayout(shape=(4, 10, 10), dtype="i4")
|
54
|
+
for i_file in range(4):
|
55
|
+
file_name = os.path.join(dir_test, f"file_{i_file}.hdf5")
|
56
|
+
with HDF5File(file_name, "w") as h5s:
|
57
|
+
h5s.create_dataset("data", (10, 10), "i4", numpy.ones((10, 10)))
|
58
|
+
vsource = h5py.VirtualSource(file_name, "data", shape=(10, 10))
|
59
|
+
layout[i_file] = vsource
|
60
|
+
|
61
|
+
test_with_vds = os.path.join(dir_test, "file_with_vds")
|
62
|
+
with HDF5File(test_with_vds, "w") as h5s:
|
63
|
+
h5s.create_virtual_dataset("vdata", layout, fillvalue=-1)
|
64
|
+
|
65
|
+
assert len(get_linked_files_with_entry(test_with_vds, "vdata")) == 4
|
66
|
+
|
67
|
+
|
68
|
+
def test_get_default_directory():
|
69
|
+
get_default_directory()
|
70
|
+
|
71
|
+
|
72
|
+
def test_get_slice_data_vol(tmp_path):
|
73
|
+
"""test load of a .vol file"""
|
74
|
+
dir_test = tmp_path / "test_vol"
|
75
|
+
dir_test.mkdir()
|
76
|
+
vol_file_path = os.path.join(dir_test, "volume.vol")
|
77
|
+
vol_info_file_path = os.path.join(dir_test, "volume.vol.info")
|
78
|
+
|
79
|
+
shape = (4, 50, 20)
|
80
|
+
data = numpy.ones(shape)
|
81
|
+
data.astype(numpy.float32).tofile(vol_file_path)
|
82
|
+
scanutils.MockEDF._createVolInfoFile(
|
83
|
+
filePath=vol_info_file_path,
|
84
|
+
shape=shape,
|
85
|
+
)
|
86
|
+
|
87
|
+
vol = get_slice_data(DataUrl(file_path=vol_file_path))
|
88
|
+
assert vol is not None
|
89
|
+
assert vol.shape == shape
|
90
|
+
vol = get_slice_data(DataUrl(file_path=vol_info_file_path))
|
91
|
+
assert vol is not None
|
92
|
+
assert vol.shape == shape
|
@@ -94,11 +94,26 @@ class CastVolumeProcessStack(FIFO, qt.QObject):
|
|
94
94
|
self.scan_ready(scan=data)
|
95
95
|
else:
|
96
96
|
self._data_currently_computed = data
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
97
|
+
try:
|
98
|
+
self._computationThread.init(data=data, configuration=configuration)
|
99
|
+
except ValueError as e:
|
100
|
+
# initialization can fail (for example for cast volume is there is no volume or be case this will raise an error)
|
101
|
+
# then we want to keep the thread active
|
102
|
+
self._data_currently_computed = None
|
103
|
+
ProcessManager().notify_dataset_state(
|
104
|
+
dataset=data, process=self._process_id, state=DatasetState.SKIPPED
|
105
|
+
)
|
106
|
+
_logger.processSkipped(f"thread initialization failed. Error is {e}")
|
107
|
+
if callback is not None:
|
108
|
+
callback()
|
109
|
+
self.scan_ready(scan=data)
|
110
|
+
else:
|
111
|
+
# need to manage connect before starting it because
|
112
|
+
fct_callback = functools.partial(
|
113
|
+
self._end_threaded_computation, callback
|
114
|
+
)
|
115
|
+
self._computationThread.finished.connect(fct_callback)
|
116
|
+
self._computationThread.start()
|
102
117
|
|
103
118
|
def _end_computation(self, data, future_tomo_obj, callback):
|
104
119
|
"""
|
@@ -0,0 +1,104 @@
|
|
1
|
+
import pytest
|
2
|
+
from ewoksorange.bindings import owsconvert
|
3
|
+
from tomwer.tests.datasets import TomwerCIDatasets
|
4
|
+
|
5
|
+
|
6
|
+
ows_files_to_convert = ("from_nxtomo_to_volume.ows",)
|
7
|
+
|
8
|
+
|
9
|
+
@pytest.mark.parametrize("orange_file_name", ows_files_to_convert)
|
10
|
+
def test_conversion(orange_file_name):
|
11
|
+
"""test orange file can be converted to ewoks Graph"""
|
12
|
+
scheme_file = TomwerCIDatasets.get_dataset(f"workflows/{orange_file_name}")
|
13
|
+
graph = owsconvert.ows_to_ewoks(scheme_file)
|
14
|
+
# make sure settings where correctly saved
|
15
|
+
assert len(graph.graph.nodes) == 7
|
16
|
+
assert len(graph.graph.edges) == 6
|
17
|
+
# make sure the settings are properly loaded
|
18
|
+
for node in graph.graph.nodes.values():
|
19
|
+
assert node["task_type"] == "class"
|
20
|
+
assert node["task_identifier"].startswith("tomwer")
|
21
|
+
# check settings of some specific nodes
|
22
|
+
# dark and flat
|
23
|
+
dark_flat_node = graph.graph.nodes["1"]
|
24
|
+
assert (
|
25
|
+
dark_flat_node["task_identifier"]
|
26
|
+
== "tomwer.core.process.reconstruction.darkref.darkrefscopy.DarkRefsCopy"
|
27
|
+
)
|
28
|
+
assert "default_inputs" in dark_flat_node
|
29
|
+
|
30
|
+
def fileter_dark_ref_params(my_dict):
|
31
|
+
return my_dict["name"] == "dark_ref_params"
|
32
|
+
|
33
|
+
dark_ref_params_settings = tuple(
|
34
|
+
filter(fileter_dark_ref_params, dark_flat_node["default_inputs"])
|
35
|
+
)
|
36
|
+
assert len(dark_ref_params_settings) == 1
|
37
|
+
dark_ref_params_as_dict = dark_ref_params_settings[0]["value"]
|
38
|
+
|
39
|
+
assert "DOWHEN" in dark_ref_params_as_dict
|
40
|
+
assert "DARKCAL" in dark_ref_params_as_dict
|
41
|
+
assert "DKFILE" in dark_ref_params_as_dict
|
42
|
+
|
43
|
+
# axis
|
44
|
+
axis_node = graph.graph.nodes["2"]
|
45
|
+
assert (
|
46
|
+
axis_node["task_identifier"]
|
47
|
+
== "tomwer.core.process.reconstruction.axis.axis.AxisTask"
|
48
|
+
)
|
49
|
+
assert "default_inputs" in axis_node
|
50
|
+
assert len(axis_node["default_inputs"]) == 2 # axis_params + gui metadata
|
51
|
+
|
52
|
+
def filter_axis_params(my_dict):
|
53
|
+
return my_dict["name"] == "axis_params"
|
54
|
+
|
55
|
+
axis_params_settings = tuple(
|
56
|
+
filter(filter_axis_params, axis_node["default_inputs"])
|
57
|
+
)
|
58
|
+
assert len(axis_params_settings) == 1
|
59
|
+
axis_params_as_dict = axis_params_settings[0]["value"]
|
60
|
+
|
61
|
+
assert "MODE" in axis_params_as_dict
|
62
|
+
assert "POSITION_VALUE" in axis_params_as_dict
|
63
|
+
assert "SINOGRAM_LINE" in axis_params_as_dict
|
64
|
+
|
65
|
+
# nabu slice
|
66
|
+
nabu_slice_node = graph.graph.nodes["3"]
|
67
|
+
assert (
|
68
|
+
nabu_slice_node["task_identifier"]
|
69
|
+
== "tomwer.core.process.reconstruction.nabu.nabuslices.NabuSlicesTask"
|
70
|
+
)
|
71
|
+
assert "default_inputs" in axis_node
|
72
|
+
|
73
|
+
def filter_nabu_params(my_dict):
|
74
|
+
return my_dict["name"] == "nabu_params"
|
75
|
+
|
76
|
+
nabu_params_settings = tuple(
|
77
|
+
filter(filter_nabu_params, nabu_slice_node["default_inputs"])
|
78
|
+
)
|
79
|
+
assert len(nabu_params_settings) == 1
|
80
|
+
nabu_params_as_dict = nabu_params_settings[0]["value"]
|
81
|
+
|
82
|
+
assert "preproc" in nabu_params_as_dict
|
83
|
+
assert "phase" in nabu_params_as_dict
|
84
|
+
assert "tomwer_slices" in nabu_params_as_dict
|
85
|
+
|
86
|
+
# nabu volume
|
87
|
+
nabu_volume_node = graph.graph.nodes["4"]
|
88
|
+
assert (
|
89
|
+
nabu_volume_node["task_identifier"]
|
90
|
+
== "tomwer.core.process.reconstruction.nabu.nabuvolume.NabuVolumeTask"
|
91
|
+
)
|
92
|
+
assert "default_inputs" in axis_node
|
93
|
+
|
94
|
+
def filter_nabu_volume_params(my_dict):
|
95
|
+
return my_dict["name"] == "nabu_volume_params"
|
96
|
+
|
97
|
+
nabu_volume_params_settings = tuple(
|
98
|
+
filter(filter_nabu_volume_params, nabu_volume_node["default_inputs"])
|
99
|
+
)
|
100
|
+
assert len(nabu_volume_params_settings) == 1
|
101
|
+
nabu_volume_params_as_dict = nabu_volume_params_settings[0]["value"]
|
102
|
+
|
103
|
+
assert "start_z" in nabu_volume_params_as_dict
|
104
|
+
assert "end_z" in nabu_volume_params_as_dict
|
@@ -0,0 +1,112 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# /*##########################################################################
|
3
|
+
#
|
4
|
+
# Copyright (c) 2016 European Synchrotron Radiation Facility
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the "Software"), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
14
|
+
# all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
# THE SOFTWARE.
|
23
|
+
#
|
24
|
+
# ###########################################################################*/
|
25
|
+
|
26
|
+
__authors__ = ["C.Nemoz", "H.Payno"]
|
27
|
+
__license__ = "MIT"
|
28
|
+
__date__ = "18/08/2021"
|
29
|
+
|
30
|
+
import os
|
31
|
+
import tempfile
|
32
|
+
from glob import glob
|
33
|
+
|
34
|
+
import pytest
|
35
|
+
from ewokscore.graph import analysis, load_graph
|
36
|
+
from ewokscore.graph.validate import validate_graph
|
37
|
+
|
38
|
+
from tomwer.core.utils.scanutils import HDF5MockContext
|
39
|
+
from nabu.pipeline.config import get_default_nabu_config
|
40
|
+
from nabu.pipeline.fullfield.nabu_config import (
|
41
|
+
nabu_config as nabu_fullfield_default_config,
|
42
|
+
)
|
43
|
+
|
44
|
+
try:
|
45
|
+
from nabu.pipeline.fullfield.reconstruction import ( # noqa F401
|
46
|
+
FullFieldReconstructor,
|
47
|
+
)
|
48
|
+
except ImportError:
|
49
|
+
try:
|
50
|
+
from nabu.pipeline.fullfield.local_reconstruction import ( # noqa F401
|
51
|
+
ChunkedReconstructor,
|
52
|
+
)
|
53
|
+
except ImportError:
|
54
|
+
has_nabu = False
|
55
|
+
else:
|
56
|
+
has_nabu = True
|
57
|
+
else:
|
58
|
+
has_nabu = True
|
59
|
+
|
60
|
+
pytest.mark.skipif(condition=not has_nabu, reason="nabu not installed")
|
61
|
+
|
62
|
+
|
63
|
+
classes_to_test = {
|
64
|
+
"darkref": "tomwer.core.process.reconstruction.darkref.darkrefs.DarkRefs",
|
65
|
+
"axis": "tomwer.core.process.reconstruction.axis.axis.AxisProcess",
|
66
|
+
"nabu slices": "tomwer.core.process.reconstruction.nabu.nabuslices.NabuSlices",
|
67
|
+
}
|
68
|
+
|
69
|
+
|
70
|
+
@pytest.mark.parametrize("node_name, node_qual_name", classes_to_test.items())
|
71
|
+
def test_single_class_instanciation(node_name, node_qual_name):
|
72
|
+
with HDF5MockContext(
|
73
|
+
scan_path=os.path.join(tempfile.mkdtemp(), "scan_test"), n_proj=100
|
74
|
+
) as scan:
|
75
|
+
# insure no cfg yet
|
76
|
+
assert len(glob(os.path.join(scan.path, "*.cfg"))) == 0
|
77
|
+
|
78
|
+
graph = load_graph(
|
79
|
+
{
|
80
|
+
"nodes": [
|
81
|
+
{
|
82
|
+
"id": node_name,
|
83
|
+
"task_type": "class",
|
84
|
+
"task_identifier": node_qual_name,
|
85
|
+
"default_inputs": [
|
86
|
+
{
|
87
|
+
"name": "data",
|
88
|
+
"value": scan,
|
89
|
+
},
|
90
|
+
{
|
91
|
+
"name": "nabu_params",
|
92
|
+
"value": get_default_nabu_config(
|
93
|
+
nabu_fullfield_default_config
|
94
|
+
),
|
95
|
+
},
|
96
|
+
],
|
97
|
+
},
|
98
|
+
]
|
99
|
+
}
|
100
|
+
)
|
101
|
+
|
102
|
+
assert graph.is_cyclic is False, "graph is expected to be acyclic"
|
103
|
+
assert analysis.start_nodes(graph.graph) == {
|
104
|
+
node_name
|
105
|
+
}, "graph is expected to have only on start nodes"
|
106
|
+
validate_graph(graph.graph)
|
107
|
+
result = graph.execute(varinfo=None)
|
108
|
+
|
109
|
+
assert analysis.end_nodes(graph.graph) == {
|
110
|
+
node_name
|
111
|
+
}, "graph is expected to have only one end node"
|
112
|
+
assert "data" in result, "data is expected to be part of the output_values"
|
@@ -0,0 +1,160 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# /*##########################################################################
|
3
|
+
#
|
4
|
+
# Copyright (c) 2016 European Synchrotron Radiation Facility
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the "Software"), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
14
|
+
# all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
# THE SOFTWARE.
|
23
|
+
#
|
24
|
+
# ###########################################################################*/
|
25
|
+
|
26
|
+
__authors__ = ["C.Nemoz", "H.Payno"]
|
27
|
+
__license__ = "MIT"
|
28
|
+
__date__ = "18/08/2021"
|
29
|
+
|
30
|
+
|
31
|
+
import os
|
32
|
+
import tempfile
|
33
|
+
from glob import glob
|
34
|
+
|
35
|
+
from ewoks import execute_graph
|
36
|
+
from ewokscore.graph import analysis, load_graph
|
37
|
+
from ewokscore.graph.validate import validate_graph
|
38
|
+
|
39
|
+
from tomwer.core.utils.scanutils import HDF5MockContext
|
40
|
+
from tomwer.core.process.reconstruction.output import PROCESS_FOLDER_NAME
|
41
|
+
|
42
|
+
try:
|
43
|
+
from nabu.pipeline.fullfield.reconstruction import ( # noqa F401
|
44
|
+
FullFieldReconstructor,
|
45
|
+
)
|
46
|
+
except ImportError:
|
47
|
+
try:
|
48
|
+
from nabu.pipeline.fullfield.local_reconstruction import ( # noqa F401
|
49
|
+
ChunkedReconstructor,
|
50
|
+
)
|
51
|
+
except ImportError:
|
52
|
+
has_nabu = False
|
53
|
+
else:
|
54
|
+
has_nabu = True
|
55
|
+
else:
|
56
|
+
has_nabu = True
|
57
|
+
|
58
|
+
|
59
|
+
def test_simple_workflow_nabu():
|
60
|
+
"""Test the workflow: darkref -> axis -> nabu slices -> nabu volume"""
|
61
|
+
|
62
|
+
with HDF5MockContext(
|
63
|
+
scan_path=os.path.join(tempfile.mkdtemp(), "scan_test"), n_proj=100
|
64
|
+
) as scan:
|
65
|
+
# insure no cfg yet
|
66
|
+
assert len(glob(os.path.join(scan.path, "*.cfg"))) == 0
|
67
|
+
assert not os.path.exists(
|
68
|
+
scan.process_file
|
69
|
+
), "check tomwer should not have been processed yet"
|
70
|
+
|
71
|
+
graph = load_graph(
|
72
|
+
source={
|
73
|
+
"nodes": [
|
74
|
+
{
|
75
|
+
"id": "darkref",
|
76
|
+
"task_type": "class",
|
77
|
+
"task_identifier": "tomwer.core.process.reconstruction.darkref.darkrefs.DarkRefs",
|
78
|
+
},
|
79
|
+
{
|
80
|
+
"id": "axis",
|
81
|
+
"task_type": "class",
|
82
|
+
"task_identifier": "tomwer.core.process.reconstruction.axis.axis.AxisProcess",
|
83
|
+
"default_inputs": [
|
84
|
+
{
|
85
|
+
"name": "axis_params",
|
86
|
+
"value": {
|
87
|
+
"MODE": "manual",
|
88
|
+
"POSITION_VALUE": 0.2,
|
89
|
+
},
|
90
|
+
},
|
91
|
+
],
|
92
|
+
},
|
93
|
+
{
|
94
|
+
"id": "nabu slices",
|
95
|
+
"task_type": "class",
|
96
|
+
"task_identifier": "tomwer.core.process.reconstruction.nabu.nabuslices.NabuSlices",
|
97
|
+
"dry_run": True, # as this is a mock dataset avoid to reconstruct it and only check for the .cfg file created
|
98
|
+
"default_inputs": [
|
99
|
+
{
|
100
|
+
"name": "nabu_params",
|
101
|
+
"value": {"tomwer_slices": 2},
|
102
|
+
}
|
103
|
+
],
|
104
|
+
},
|
105
|
+
{
|
106
|
+
"id": "nabu volume",
|
107
|
+
"task_type": "class",
|
108
|
+
"task_identifier": "tomwer.core.process.reconstruction.nabu.nabuvolume.NabuVolume",
|
109
|
+
"dry_run": True,
|
110
|
+
"default_inputs": [
|
111
|
+
{
|
112
|
+
"name": "dry_run",
|
113
|
+
"value": True,
|
114
|
+
}
|
115
|
+
],
|
116
|
+
},
|
117
|
+
],
|
118
|
+
"links": [
|
119
|
+
{
|
120
|
+
"source": "darkref",
|
121
|
+
"target": "axis",
|
122
|
+
"map_all_data": True,
|
123
|
+
},
|
124
|
+
{
|
125
|
+
"source": "axis",
|
126
|
+
"target": "nabu slices",
|
127
|
+
"data_mapping": [ # same as all arguments but just here to test both
|
128
|
+
{
|
129
|
+
"source_output": "data",
|
130
|
+
"target_input": "data",
|
131
|
+
},
|
132
|
+
],
|
133
|
+
},
|
134
|
+
{
|
135
|
+
"source": "nabu slices",
|
136
|
+
"target": "nabu volume",
|
137
|
+
"map_all_data": True,
|
138
|
+
},
|
139
|
+
],
|
140
|
+
}
|
141
|
+
)
|
142
|
+
assert graph.is_cyclic is False, "graph is expected to be acyclic"
|
143
|
+
assert analysis.start_nodes(graph=graph.graph) == {
|
144
|
+
"darkref"
|
145
|
+
}, "start node should be a single task `darkref`"
|
146
|
+
validate_graph(graph.graph)
|
147
|
+
result = execute_graph(
|
148
|
+
graph,
|
149
|
+
inputs=[
|
150
|
+
{"id": "darkref", "name": "data", "value": scan},
|
151
|
+
],
|
152
|
+
)
|
153
|
+
assert analysis.end_nodes(graph=graph.graph) == {
|
154
|
+
"nabu volume"
|
155
|
+
}, "should only have one result nodes"
|
156
|
+
assert "data" in result, f"cannot find `nabu volume` in {result}"
|
157
|
+
assert os.path.exists(scan.process_file), "check tomwer has been processed"
|
158
|
+
assert os.path.exists(
|
159
|
+
os.path.join(scan.path, PROCESS_FOLDER_NAME, "nabu_cfg_files")
|
160
|
+
), "nabu has not been executed (even in dry mode)"
|
tomwer/version.py
CHANGED