junifer 0.0.6.dev150__py3-none-any.whl → 0.0.6.dev175__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.
- junifer/__init__.pyi +2 -0
- junifer/_version.py +2 -2
- junifer/api/decorators.py +6 -11
- junifer/api/functions.py +74 -62
- junifer/api/tests/test_functions.py +2 -2
- junifer/datagrabber/aomic/piop2.py +1 -1
- junifer/pipeline/__init__.pyi +2 -2
- junifer/pipeline/pipeline_component_registry.py +299 -0
- junifer/pipeline/tests/test_pipeline_component_registry.py +201 -0
- junifer/testing/__init__.pyi +2 -2
- junifer/testing/registry.py +4 -7
- junifer/testing/tests/test_testing_registry.py +9 -17
- {junifer-0.0.6.dev150.dist-info → junifer-0.0.6.dev175.dist-info}/METADATA +1 -1
- {junifer-0.0.6.dev150.dist-info → junifer-0.0.6.dev175.dist-info}/RECORD +19 -19
- junifer/pipeline/registry.py +0 -245
- junifer/pipeline/tests/test_registry.py +0 -150
- {junifer-0.0.6.dev150.dist-info → junifer-0.0.6.dev175.dist-info}/AUTHORS.rst +0 -0
- {junifer-0.0.6.dev150.dist-info → junifer-0.0.6.dev175.dist-info}/LICENSE.md +0 -0
- {junifer-0.0.6.dev150.dist-info → junifer-0.0.6.dev175.dist-info}/WHEEL +0 -0
- {junifer-0.0.6.dev150.dist-info → junifer-0.0.6.dev175.dist-info}/entry_points.txt +0 -0
- {junifer-0.0.6.dev150.dist-info → junifer-0.0.6.dev175.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,201 @@
|
|
1
|
+
"""Provide tests for PipelineComponentRegistry."""
|
2
|
+
|
3
|
+
# Authors: Federico Raimondo <f.raimondo@fz-juelich.de>
|
4
|
+
# Leonard Sasse <l.sasse@fz-juelich.de>
|
5
|
+
# Synchon Mandal <s.mandal@fz-juelich.de>
|
6
|
+
# License: AGPL
|
7
|
+
|
8
|
+
import logging
|
9
|
+
from abc import ABC
|
10
|
+
from typing import Type
|
11
|
+
|
12
|
+
import pytest
|
13
|
+
|
14
|
+
from junifer.datagrabber.pattern import PatternDataGrabber
|
15
|
+
from junifer.pipeline.pipeline_component_registry import (
|
16
|
+
PipelineComponentRegistry,
|
17
|
+
)
|
18
|
+
from junifer.storage import SQLiteFeatureStorage
|
19
|
+
|
20
|
+
|
21
|
+
def test_pipeline_component_registry_singleton() -> None:
|
22
|
+
"""Test that PipelineComponentRegistry is a singleton."""
|
23
|
+
registry_1 = PipelineComponentRegistry()
|
24
|
+
registry_2 = PipelineComponentRegistry()
|
25
|
+
assert id(registry_1) == id(registry_2)
|
26
|
+
|
27
|
+
|
28
|
+
def test_pipeline_component_registry_register_invalid_step():
|
29
|
+
"""Test invalid step name during component registration."""
|
30
|
+
with pytest.raises(ValueError, match="Invalid step:"):
|
31
|
+
PipelineComponentRegistry().register(step="foo", klass=str)
|
32
|
+
|
33
|
+
|
34
|
+
def test_pipeline_component_registry_steps():
|
35
|
+
"""Test steps for PipelineComponentRegistry."""
|
36
|
+
assert set(PipelineComponentRegistry().steps) == {
|
37
|
+
"datagrabber",
|
38
|
+
"datareader",
|
39
|
+
"preprocessing",
|
40
|
+
"marker",
|
41
|
+
"storage",
|
42
|
+
}
|
43
|
+
|
44
|
+
|
45
|
+
def test_pipeline_component_registry_components():
|
46
|
+
"""Test components for PipelineComponentRegistry."""
|
47
|
+
assert set(PipelineComponentRegistry().steps) == {
|
48
|
+
"datagrabber",
|
49
|
+
"datareader",
|
50
|
+
"preprocessing",
|
51
|
+
"marker",
|
52
|
+
"storage",
|
53
|
+
}
|
54
|
+
|
55
|
+
|
56
|
+
@pytest.mark.parametrize(
|
57
|
+
"step, klass",
|
58
|
+
[
|
59
|
+
("datagrabber", PatternDataGrabber),
|
60
|
+
("storage", SQLiteFeatureStorage),
|
61
|
+
],
|
62
|
+
)
|
63
|
+
def test_pipeline_component_registry_register(
|
64
|
+
caplog: pytest.LogCaptureFixture, step: str, klass: Type
|
65
|
+
) -> None:
|
66
|
+
"""Test register for PipelineComponentRegistry.
|
67
|
+
|
68
|
+
Parameters
|
69
|
+
----------
|
70
|
+
caplog : pytest.LogCaptureFixture
|
71
|
+
The pytest.LogCaptureFixture object.
|
72
|
+
step : str
|
73
|
+
The parametrized name of the step.
|
74
|
+
klass : str
|
75
|
+
The parametrized name of the class.
|
76
|
+
|
77
|
+
"""
|
78
|
+
with caplog.at_level(logging.INFO):
|
79
|
+
# Register
|
80
|
+
PipelineComponentRegistry().register(step=step, klass=klass)
|
81
|
+
# Check logging message
|
82
|
+
assert "Registering" in caplog.text
|
83
|
+
|
84
|
+
|
85
|
+
@pytest.mark.parametrize(
|
86
|
+
"step, klass",
|
87
|
+
[
|
88
|
+
("datagrabber", PatternDataGrabber),
|
89
|
+
("storage", SQLiteFeatureStorage),
|
90
|
+
],
|
91
|
+
)
|
92
|
+
def test_pipeline_component_registry_deregister(
|
93
|
+
caplog: pytest.LogCaptureFixture, step: str, klass: Type
|
94
|
+
) -> None:
|
95
|
+
"""Test de-register for PipelineComponentRegistry.
|
96
|
+
|
97
|
+
Parameters
|
98
|
+
----------
|
99
|
+
caplog : pytest.LogCaptureFixture
|
100
|
+
The pytest.LogCaptureFixture object.
|
101
|
+
step : str
|
102
|
+
The parametrized name of the step.
|
103
|
+
klass : str
|
104
|
+
The parametrized name of the class.
|
105
|
+
|
106
|
+
"""
|
107
|
+
with caplog.at_level(logging.INFO):
|
108
|
+
# Register
|
109
|
+
PipelineComponentRegistry().deregister(step=step, klass=klass)
|
110
|
+
# Check logging message
|
111
|
+
assert "De-registering" in caplog.text
|
112
|
+
|
113
|
+
|
114
|
+
def test_pipeline_component_registry_step_components() -> None:
|
115
|
+
"""Test step components for PipelineComponentRegistry."""
|
116
|
+
# Check absent name
|
117
|
+
assert "fizz" not in PipelineComponentRegistry().step_components(
|
118
|
+
step="datagrabber"
|
119
|
+
)
|
120
|
+
|
121
|
+
# Create new class
|
122
|
+
class fizz(str):
|
123
|
+
pass
|
124
|
+
|
125
|
+
# Register datagrabber
|
126
|
+
PipelineComponentRegistry().register(step="datagrabber", klass=fizz)
|
127
|
+
# Check registered component
|
128
|
+
assert "fizz" in PipelineComponentRegistry().step_components(
|
129
|
+
step="datagrabber"
|
130
|
+
)
|
131
|
+
|
132
|
+
|
133
|
+
def test_pipeline_component_registry_get_class_invalid_name() -> None:
|
134
|
+
"""Test get class invalid name for PipelineComponentRegistry."""
|
135
|
+
with pytest.raises(ValueError, match="Invalid name:"):
|
136
|
+
PipelineComponentRegistry().get_class(step="datagrabber", name="foo")
|
137
|
+
|
138
|
+
|
139
|
+
def test_pipeline_component_registry_get_class():
|
140
|
+
"""Test get class for PipelineComponentRegistry."""
|
141
|
+
|
142
|
+
# Create new class
|
143
|
+
class bar(str):
|
144
|
+
pass
|
145
|
+
|
146
|
+
# Register datagrabber
|
147
|
+
PipelineComponentRegistry().register(step="datagrabber", klass=bar)
|
148
|
+
# Get class
|
149
|
+
obj = PipelineComponentRegistry().get_class(step="datagrabber", name="bar")
|
150
|
+
assert isinstance(obj, type(bar))
|
151
|
+
|
152
|
+
|
153
|
+
def test_pipeline_component_registry_build():
|
154
|
+
"""Test component instance building for PipelineComponentRegistry."""
|
155
|
+
import numpy as np
|
156
|
+
|
157
|
+
# Define abstract base class
|
158
|
+
class SuperClass(ABC):
|
159
|
+
pass
|
160
|
+
|
161
|
+
# Define concrete class
|
162
|
+
class ConcreteClass(SuperClass):
|
163
|
+
def __init__(self, value=1):
|
164
|
+
self.value = value
|
165
|
+
|
166
|
+
# Register
|
167
|
+
PipelineComponentRegistry().register(
|
168
|
+
step="datagrabber", klass=ConcreteClass
|
169
|
+
)
|
170
|
+
|
171
|
+
# Build
|
172
|
+
obj = PipelineComponentRegistry().build_component_instance(
|
173
|
+
step="datagrabber", name="ConcreteClass", baseclass=SuperClass
|
174
|
+
)
|
175
|
+
assert isinstance(obj, ConcreteClass)
|
176
|
+
assert obj.value == 1
|
177
|
+
|
178
|
+
# Build
|
179
|
+
obj = PipelineComponentRegistry().build_component_instance(
|
180
|
+
step="datagrabber",
|
181
|
+
name="ConcreteClass",
|
182
|
+
baseclass=SuperClass,
|
183
|
+
init_params={"value": 2},
|
184
|
+
)
|
185
|
+
assert isinstance(obj, ConcreteClass)
|
186
|
+
assert obj.value == 2
|
187
|
+
|
188
|
+
# Check error
|
189
|
+
with pytest.raises(ValueError, match="Must inherit"):
|
190
|
+
PipelineComponentRegistry().build_component_instance(
|
191
|
+
step="datagrabber", name="ConcreteClass", baseclass=np.ndarray
|
192
|
+
)
|
193
|
+
|
194
|
+
# Check error
|
195
|
+
with pytest.raises(RuntimeError, match="Failed to create"):
|
196
|
+
PipelineComponentRegistry().build_component_instance(
|
197
|
+
step="datagrabber",
|
198
|
+
name="ConcreteClass",
|
199
|
+
baseclass=SuperClass,
|
200
|
+
init_params={"wrong": 2},
|
201
|
+
)
|
junifer/testing/__init__.pyi
CHANGED
junifer/testing/registry.py
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# Synchon Mandal <s.mandal@fz-juelich.de>
|
5
5
|
# License: AGPL
|
6
6
|
|
7
|
-
from ..pipeline
|
7
|
+
from ..pipeline import PipelineComponentRegistry
|
8
8
|
from .datagrabbers import (
|
9
9
|
OasisVBMTestingDataGrabber,
|
10
10
|
PartlyCloudyTestingDataGrabber,
|
@@ -13,20 +13,17 @@ from .datagrabbers import (
|
|
13
13
|
|
14
14
|
|
15
15
|
# Register testing DataGrabbers
|
16
|
-
register(
|
16
|
+
PipelineComponentRegistry().register(
|
17
17
|
step="datagrabber",
|
18
|
-
name="OasisVBMTestingDataGrabber",
|
19
18
|
klass=OasisVBMTestingDataGrabber,
|
20
19
|
)
|
21
20
|
|
22
|
-
register(
|
21
|
+
PipelineComponentRegistry().register(
|
23
22
|
step="datagrabber",
|
24
|
-
name="SPMAuditoryTestingDataGrabber",
|
25
23
|
klass=SPMAuditoryTestingDataGrabber,
|
26
24
|
)
|
27
25
|
|
28
|
-
register(
|
26
|
+
PipelineComponentRegistry().register(
|
29
27
|
step="datagrabber",
|
30
|
-
name="PartlyCloudyTestingDataGrabber",
|
31
28
|
klass=PartlyCloudyTestingDataGrabber,
|
32
29
|
)
|
@@ -1,24 +1,16 @@
|
|
1
1
|
"""Provide tests for testing registry."""
|
2
2
|
|
3
|
-
|
3
|
+
# Authors: Federico Raimondo <f.raimondo@fz-juelich.de>
|
4
|
+
# Synchon Mandal <s.mandal@fz-juelich.de>
|
5
|
+
# License: AGPL
|
4
6
|
|
5
|
-
from junifer.pipeline
|
7
|
+
from junifer.pipeline import PipelineComponentRegistry
|
6
8
|
|
7
9
|
|
8
10
|
def test_testing_registry() -> None:
|
9
11
|
"""Test testing registry."""
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
assert "OasisVBMTestingDataGrabber" not in get_step_names("datagrabber")
|
16
|
-
assert "SPMAuditoryTestingDataGrabber" not in get_step_names("datagrabber")
|
17
|
-
assert "PartlyCloudyTestingDataGrabber" not in get_step_names(
|
18
|
-
"datagrabber"
|
19
|
-
)
|
20
|
-
importlib.reload(junifer.testing.registry) # type: ignore
|
21
|
-
|
22
|
-
assert "OasisVBMTestingDataGrabber" in get_step_names("datagrabber")
|
23
|
-
assert "SPMAuditoryTestingDataGrabber" in get_step_names("datagrabber")
|
24
|
-
assert "PartlyCloudyTestingDataGrabber" in get_step_names("datagrabber")
|
12
|
+
assert {
|
13
|
+
"OasisVBMTestingDataGrabber",
|
14
|
+
"SPMAuditoryTestingDataGrabber",
|
15
|
+
"PartlyCloudyTestingDataGrabber",
|
16
|
+
}.issubset(set(PipelineComponentRegistry().step_components("datagrabber")))
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: junifer
|
3
|
-
Version: 0.0.6.
|
3
|
+
Version: 0.0.6.dev175
|
4
4
|
Summary: JUelich NeuroImaging FEature extractoR
|
5
5
|
Author-email: Fede Raimondo <f.raimondo@fz-juelich.de>, Synchon Mandal <s.mandal@fz-juelich.de>
|
6
6
|
Maintainer-email: Fede Raimondo <f.raimondo@fz-juelich.de>, Synchon Mandal <s.mandal@fz-juelich.de>
|
@@ -1,12 +1,12 @@
|
|
1
1
|
junifer/__init__.py,sha256=2McgH1yNue6Z1V26-uN_mfMjbTcx4CLhym-DMBl5xA4,266
|
2
|
-
junifer/__init__.pyi,sha256=
|
3
|
-
junifer/_version.py,sha256=
|
2
|
+
junifer/__init__.pyi,sha256=uPLuY27S7AY4kFzJX0ncCpzHnWJdztveMJpY3Di-wwQ,482
|
3
|
+
junifer/_version.py,sha256=kxb4jDdB46TYAsROV8U-peWvw8kJsVsZHpoSPS_JLT0,428
|
4
4
|
junifer/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
5
|
junifer/stats.py,sha256=BjQb2lfTGDP9l4UuQYmJFcJJNRfbJDGlNvC06SJaDDE,6237
|
6
6
|
junifer/api/__init__.py,sha256=aAXW_KAEGQ8aAP5Eni2G1R4MWBF7UgjKOgM6akLuJco,252
|
7
7
|
junifer/api/__init__.pyi,sha256=UJu55ApMFd43N0xlQyNKrYpCdzqhAxA3Jjaj0ETwCXU,169
|
8
|
-
junifer/api/decorators.py,sha256=
|
9
|
-
junifer/api/functions.py,sha256=
|
8
|
+
junifer/api/decorators.py,sha256=nzricZsr0xawk3WDUCyKLWC6WcKN_T0SYIOkGVeoZs8,2726
|
9
|
+
junifer/api/functions.py,sha256=Q3X5d_sB5SKcPfNLOi49GnXdln_FUqLpo1TbUK-2j1M,12792
|
10
10
|
junifer/api/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
11
|
junifer/api/queue_context/__init__.py,sha256=glr8x4aMm4EvVrHywDIlugdNlwD1RzqV2FTDNPqYQZ4,204
|
12
12
|
junifer/api/queue_context/__init__.pyi,sha256=LoDQFGZ9wCDmgx5a1_nhKo4zOSvqViXZ8V882DksF7U,246
|
@@ -39,7 +39,7 @@ junifer/api/res/fsl/flirt,sha256=tSjiUco8ui8AbHD7mTzChEwbR0Rf_4iJTgzYTPF_WuQ,42
|
|
39
39
|
junifer/api/res/fsl/img2imgcoord,sha256=Zmaw3oJYrEltcXiPyEubXry9ppAq3SND52tdDWGgeZk,49
|
40
40
|
junifer/api/res/fsl/run_fsl_docker.sh,sha256=pq-fcNdLuvHzVIQePN4GebZGlcE2UF-xj5rBIqAMz4g,1122
|
41
41
|
junifer/api/res/fsl/std2imgcoord,sha256=-X5wRH6XMl0yqnTACJX6MFhO8DFOEWg42MHRxGvimXg,49
|
42
|
-
junifer/api/tests/test_functions.py,sha256=
|
42
|
+
junifer/api/tests/test_functions.py,sha256=1l91zo7HUAyI5Uj_Brn8P-FHCSDdBkhs3rHIs56uMbI,17805
|
43
43
|
junifer/cli/__init__.py,sha256=DS3kZKHeVDxt6d1MLBerZ2fcAwrEBHee5JOBhOLajUI,197
|
44
44
|
junifer/cli/__init__.pyi,sha256=PiV4znUnzSeuSSJGz-RT8N21PiMqoSMwYcypi7nt2Js,40
|
45
45
|
junifer/cli/cli.py,sha256=LoIWiAU6e5UtcP2Hibx-PDo2QcDqEbrlvzTTSI8rPUQ,13202
|
@@ -119,7 +119,7 @@ junifer/datagrabber/aomic/__init__.py,sha256=ATxzXq9NBPmWowTMuL77zqrmIbbnk0Wd1iX
|
|
119
119
|
junifer/datagrabber/aomic/__init__.pyi,sha256=Rp6C075fZDdKY8VIq508_g4NhVj8bWzR6zb9yln761Q,189
|
120
120
|
junifer/datagrabber/aomic/id1000.py,sha256=wJpZiSZrsfil5w-506bOtKMWm3FllnbB8-cMvGDPiLM,7219
|
121
121
|
junifer/datagrabber/aomic/piop1.py,sha256=AcjIueSUmhepuIfmbMEpocV7grUbJ2xKXG94O1dq2FA,9637
|
122
|
-
junifer/datagrabber/aomic/piop2.py,sha256
|
122
|
+
junifer/datagrabber/aomic/piop2.py,sha256=-3M7miEtubF8Dl66OBtaPOlNiQZiVkvTOlgsEExP-ic,9298
|
123
123
|
junifer/datagrabber/aomic/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
124
124
|
junifer/datagrabber/aomic/tests/test_id1000.py,sha256=AWacDroSxvRjzozFjyRlDpiJpPflYRfhDm_RANrYAKM,3283
|
125
125
|
junifer/datagrabber/aomic/tests/test_piop1.py,sha256=J9ei2HLzdJPciysWjRo33cbZsqPF1OEDySmQWWNvYuM,4820
|
@@ -246,18 +246,18 @@ junifer/onthefly/_brainprint.py,sha256=-q5j5xOkuZD_f-pjWi-b8VRqM9ZXDk1TnccuQDfLw
|
|
246
246
|
junifer/onthefly/read_transform.py,sha256=kZ-N_fKe9glaBTjhj_HXrdTtWXGI-fMoBpsawcOgsTw,4340
|
247
247
|
junifer/onthefly/tests/test_read_transform.py,sha256=D2C3IpXQHdsJSF07v8rEwGntLGXjZOserlRhebJUAVM,4719
|
248
248
|
junifer/pipeline/__init__.py,sha256=rxKQGRwc6_sts1KhVIcVVpuXeiFABf11mQQ2h5jgA3U,194
|
249
|
-
junifer/pipeline/__init__.pyi,sha256=
|
249
|
+
junifer/pipeline/__init__.pyi,sha256=hhcvNcABhtLaUQiZdTjo5sMWC3rtDkwVshL0sxD5JAE,399
|
250
250
|
junifer/pipeline/marker_collection.py,sha256=1xcJqeOZ_IerB7PAMN1itWBv8UR6lUW9xXRoIu4qLXU,5557
|
251
|
+
junifer/pipeline/pipeline_component_registry.py,sha256=fyGIEv30w01IhLBvKDmnxWtAi-Z9pRq-T1hpamDceyY,9481
|
251
252
|
junifer/pipeline/pipeline_step_mixin.py,sha256=wakimkG8GC0PWkFHMHIfgzM2yak41xLrzbVRH0oe8D4,7613
|
252
253
|
junifer/pipeline/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
253
|
-
junifer/pipeline/registry.py,sha256=BiUG2yKxbcqN9rrU7ATEG4U9QNFWuZnvbHgCP00h6l4,6748
|
254
254
|
junifer/pipeline/singleton.py,sha256=c5U8Xn10MQqaXjlLzxLbw3AmSYW6aTw_iSL0rDkbuMU,1011
|
255
255
|
junifer/pipeline/update_meta_mixin.py,sha256=A_gYCPqdPlM0Xpum9TjJowb41O7ntxQg6y4YOgYeyy4,1564
|
256
256
|
junifer/pipeline/utils.py,sha256=CAp0P7rZST7bsJ9lSlkvZgIJebHW2cIm8VXTuu1A6tE,10291
|
257
257
|
junifer/pipeline/workdir_manager.py,sha256=8vBKdb7FtQaGV66Ngu_ucJJPrh2xoxf_1jMeNpJKT2Y,8050
|
258
258
|
junifer/pipeline/tests/test_marker_collection.py,sha256=edBHfmwMTXG_q0ZagApbAbkFNoegi3hVEQiNcBtZOKc,6959
|
259
|
+
junifer/pipeline/tests/test_pipeline_component_registry.py,sha256=ww_akEhtvE1_fsWbX5Yd5w_G2Ki6w_5MInfihwwRYFk,5800
|
259
260
|
junifer/pipeline/tests/test_pipeline_step_mixin.py,sha256=_ykZzyNzREXy-r_yv1gY_jquLZzVBl8qwYrVORCKY_k,7807
|
260
|
-
junifer/pipeline/tests/test_registry.py,sha256=APC8PNmA3zJnMjLz90rZw_wK0hoag6St8AmQY6MUEqA,4121
|
261
261
|
junifer/pipeline/tests/test_update_meta_mixin.py,sha256=UeWwpUi-Q5WVd36Fgfn_utXplSVXMSjLcdO2mR2xLTk,1355
|
262
262
|
junifer/pipeline/tests/test_workdir_manager.py,sha256=E1WY4C-GDsx2c49sePqr1WR_Y3nZ1kiRn4Veu506uTs,2801
|
263
263
|
junifer/preprocess/__init__.py,sha256=91D43p254il88g-7sSN64M7HsCvwytYoiTS_GLEr37Y,342
|
@@ -299,16 +299,16 @@ junifer/storage/tests/test_sqlite.py,sha256=JPfE6r34o86XkKaB6yjMVmO_2vUV40DjsaHI
|
|
299
299
|
junifer/storage/tests/test_storage_base.py,sha256=YzgfspuggzXejyPIoRCPST3ZzH9Pi7dgl0IHN7kynXM,3071
|
300
300
|
junifer/storage/tests/test_utils.py,sha256=vRGhbeOsSn2Izhjh5AaaJkp6X2EoIQVH3a-9COFVnzg,11854
|
301
301
|
junifer/testing/__init__.py,sha256=gqfrX2c7I31VYBmH9hCUERO-61NwubT1cvy1bKM0NqU,249
|
302
|
-
junifer/testing/__init__.pyi,sha256=
|
302
|
+
junifer/testing/__init__.pyi,sha256=OFqGc5GCjoD4hPVOYNWvnvvP_RVF-oO-UQR8n9HDVtM,133
|
303
303
|
junifer/testing/datagrabbers.py,sha256=iYS4IjYbOFQw4fH8e7HNvBOsYgVjMZNodNCLoI25oNA,6601
|
304
304
|
junifer/testing/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
305
|
-
junifer/testing/registry.py,sha256=
|
305
|
+
junifer/testing/registry.py,sha256=MVO-xlzSH3pAv9ySTqO1R3sNqdnfD1Qh7oA775ZxlXs,688
|
306
306
|
junifer/testing/utils.py,sha256=TEIwdV7etWglXOFQX1O5ZR18GzfYZ0LcRqXuK-JPo8U,591
|
307
307
|
junifer/testing/data/sub-0001_task-anticipation_acq-seq_desc-confounds_regressors.tsv,sha256=iDY1apF5caxnyGqvBYWer5JRKQIfuOwoT-SzzsgL59s,406849
|
308
308
|
junifer/testing/tests/test_oasisvmbtesting_datagrabber.py,sha256=BtfExi4VF-jZsi5A3hHS_EGm2O_bJoXnxWF44Z_4i24,794
|
309
309
|
junifer/testing/tests/test_partlycloudytesting_datagrabber.py,sha256=ggU8XQQ6F0HSCh9VkbNGoaZM6CUxKXKlcuf_kGkrRF4,1297
|
310
310
|
junifer/testing/tests/test_spmauditory_datagrabber.py,sha256=1G1emk-Ze59HiNLaYsyIz5O1YGW9darcqlzvhE-J_Mc,919
|
311
|
-
junifer/testing/tests/test_testing_registry.py,sha256=
|
311
|
+
junifer/testing/tests/test_testing_registry.py,sha256=MK4a_q4MHieCvYhnhuPm_dH76lX0yyDOZP8tZ30aC7Y,508
|
312
312
|
junifer/tests/test_main.py,sha256=GMff7jlisGM9_FsiUwWDte43j-KQJGFRYZpwRRqTkd8,373
|
313
313
|
junifer/tests/test_stats.py,sha256=3vPMgYYpWxk8ECDFOMm3-dFBlh4XxjL83SwRBSBAHok,4155
|
314
314
|
junifer/utils/__init__.py,sha256=I3tYaePAD_ZEU-36-TJ_OYeqW_aMmi5MZ3jmqie6RfU,260
|
@@ -321,10 +321,10 @@ junifer/utils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
321
321
|
junifer/utils/tests/test_fs.py,sha256=WQS7cKlKEZ742CIuiOYYpueeAhY9PqlastfDVpVVtvE,923
|
322
322
|
junifer/utils/tests/test_helpers.py,sha256=k5qqfxK8dFyuewTJyR1Qn6-nFaYNuVr0ysc18bfPjyU,929
|
323
323
|
junifer/utils/tests/test_logging.py,sha256=duO4ou365hxwa_kwihFtKPLaL6LC5XHiyhOijrrngbA,8009
|
324
|
-
junifer-0.0.6.
|
325
|
-
junifer-0.0.6.
|
326
|
-
junifer-0.0.6.
|
327
|
-
junifer-0.0.6.
|
328
|
-
junifer-0.0.6.
|
329
|
-
junifer-0.0.6.
|
330
|
-
junifer-0.0.6.
|
324
|
+
junifer-0.0.6.dev175.dist-info/AUTHORS.rst,sha256=rmULKpchpSol4ExWFdm-qu4fkpSZPYqIESVJBZtGb6E,163
|
325
|
+
junifer-0.0.6.dev175.dist-info/LICENSE.md,sha256=MqCnOBu8uXsEOzRZWh9EBVfVz-kE9NkXcLCrtGXo2yU,34354
|
326
|
+
junifer-0.0.6.dev175.dist-info/METADATA,sha256=CsgsHCA_JZ2DN2_3uysC3HhYOZVpzOouUOgF1l7OJxs,8448
|
327
|
+
junifer-0.0.6.dev175.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
|
328
|
+
junifer-0.0.6.dev175.dist-info/entry_points.txt,sha256=6O8ru0BP-SP7YMUZiizFNoaZ2HvJpadO2G7nKk4PwjI,48
|
329
|
+
junifer-0.0.6.dev175.dist-info/top_level.txt,sha256=4bAq1R2QFQ4b3hohjys2JBvxrl0GKk5LNFzYvz9VGcA,8
|
330
|
+
junifer-0.0.6.dev175.dist-info/RECORD,,
|
junifer/pipeline/registry.py
DELETED
@@ -1,245 +0,0 @@
|
|
1
|
-
"""Provide functions for registry."""
|
2
|
-
|
3
|
-
# Authors: Federico Raimondo <f.raimondo@fz-juelich.de>
|
4
|
-
# Leonard Sasse <l.sasse@fz-juelich.de>
|
5
|
-
# Synchon Mandal <s.mandal@fz-juelich.de>
|
6
|
-
# License: AGPL
|
7
|
-
|
8
|
-
import importlib
|
9
|
-
from typing import TYPE_CHECKING, Dict, List, Optional, Union
|
10
|
-
|
11
|
-
from ..utils.logging import logger, raise_error
|
12
|
-
|
13
|
-
|
14
|
-
if TYPE_CHECKING:
|
15
|
-
from ..datagrabber import BaseDataGrabber
|
16
|
-
from ..storage import BaseFeatureStorage
|
17
|
-
from .pipeline_step_mixin import PipelineStepMixin
|
18
|
-
|
19
|
-
|
20
|
-
__all__ = ["register", "get_step_names", "get_class", "build"]
|
21
|
-
|
22
|
-
|
23
|
-
# Define valid steps for operation
|
24
|
-
_VALID_STEPS: List[str] = [
|
25
|
-
"datagrabber",
|
26
|
-
"datareader",
|
27
|
-
"preprocessing",
|
28
|
-
"marker",
|
29
|
-
"storage",
|
30
|
-
]
|
31
|
-
|
32
|
-
# Step to sub-package mapping
|
33
|
-
_STEP_TO_SUBPKG_MAPPINGS = {
|
34
|
-
"datagrabber": "datagrabber",
|
35
|
-
"datareader": "datareader",
|
36
|
-
"preprocessing": "preprocess",
|
37
|
-
"marker": "markers",
|
38
|
-
"storage": "storage",
|
39
|
-
}
|
40
|
-
|
41
|
-
# Define registry for valid steps
|
42
|
-
_REGISTRY: Dict[str, Dict[str, Union[str, type]]] = {
|
43
|
-
"datagrabber": {
|
44
|
-
"HCP1200": "HCP1200",
|
45
|
-
"BaseDataGrabber": "BaseDataGrabber",
|
46
|
-
"DataladAOMICID1000": "DataladAOMICID1000",
|
47
|
-
"DataladAOMICPIOP1": "DataladAOMICPIOP1",
|
48
|
-
"DataladAOMICPIOP2": "DataladAOMICPIOP2",
|
49
|
-
"DataladDataGrabber": "DataladDataGrabber",
|
50
|
-
"DataladHCP1200": "DataladHCP1200",
|
51
|
-
"DMCC13Benchmark": "DMCC13Benchmark",
|
52
|
-
"MultipleDataGrabber": "MultipleDataGrabber",
|
53
|
-
"PatternDataGrabber": "PatternDataGrabber",
|
54
|
-
"PatternDataladDataGrabber": "PatternDataladDataGrabber",
|
55
|
-
},
|
56
|
-
"datareader": {
|
57
|
-
"DefaultDataReader": "DefaultDataReader",
|
58
|
-
},
|
59
|
-
"preprocessing": {
|
60
|
-
"BasePreprocessor": "BasePreprocessor",
|
61
|
-
"Smoothing": "Smoothing",
|
62
|
-
"SpaceWarper": "SpaceWarper",
|
63
|
-
"fMRIPrepConfoundRemover": "fMRIPrepConfoundRemover",
|
64
|
-
},
|
65
|
-
"marker": {
|
66
|
-
"ALFFParcels": "ALFFParcels",
|
67
|
-
"ALFFSpheres": "ALFFSpheres",
|
68
|
-
"BaseMarker": "BaseMarker",
|
69
|
-
"BrainPrint": "BrainPrint",
|
70
|
-
"CrossParcellationFC": "CrossParcellationFC",
|
71
|
-
"EdgeCentricFCParcels": "EdgeCentricFCParcels",
|
72
|
-
"EdgeCentricFCSpheres": "EdgeCentricFCSpheres",
|
73
|
-
"FunctionalConnectivityParcels": "FunctionalConnectivityParcels",
|
74
|
-
"FunctionalConnectivitySpheres": "FunctionalConnectivitySpheres",
|
75
|
-
"ParcelAggregation": "ParcelAggregation",
|
76
|
-
"ReHoParcels": "ReHoParcels",
|
77
|
-
"ReHoSpheres": "ReHoSpheres",
|
78
|
-
"RSSETSMarker": "RSSETSMarker",
|
79
|
-
"SphereAggregation": "SphereAggregation",
|
80
|
-
"TemporalSNRParcels": "TemporalSNRParcels",
|
81
|
-
"TemporalSNRSpheres": "TemporalSNRSpheres",
|
82
|
-
},
|
83
|
-
"storage": {
|
84
|
-
"BaseFeatureStorage": "BaseFeatureStorage",
|
85
|
-
"HDF5FeatureStorage": "HDF5FeatureStorage",
|
86
|
-
"PandasBaseFeatureStorage": "PandasBaseFeatureStorage",
|
87
|
-
"SQLiteFeatureStorage": "SQLiteFeatureStorage",
|
88
|
-
},
|
89
|
-
}
|
90
|
-
|
91
|
-
|
92
|
-
def register(step: str, name: str, klass: type) -> None:
|
93
|
-
"""Register a function to be used in a pipeline step.
|
94
|
-
|
95
|
-
Parameters
|
96
|
-
----------
|
97
|
-
step : str
|
98
|
-
Name of the step.
|
99
|
-
name : str
|
100
|
-
Name of the function.
|
101
|
-
klass : class
|
102
|
-
Class to be registered.
|
103
|
-
|
104
|
-
Raises
|
105
|
-
------
|
106
|
-
ValueError
|
107
|
-
If the ``step`` is invalid.
|
108
|
-
|
109
|
-
"""
|
110
|
-
# Verify step
|
111
|
-
if step not in _VALID_STEPS:
|
112
|
-
raise_error(msg=f"Invalid step: {step}", klass=ValueError)
|
113
|
-
|
114
|
-
logger.info(f"Registering {name} in {step}")
|
115
|
-
_REGISTRY[step][name] = klass
|
116
|
-
|
117
|
-
|
118
|
-
def get_step_names(step: str) -> List[str]:
|
119
|
-
"""Get the names of the registered functions for a given step.
|
120
|
-
|
121
|
-
Parameters
|
122
|
-
----------
|
123
|
-
step : str
|
124
|
-
Name of the step.
|
125
|
-
|
126
|
-
Returns
|
127
|
-
-------
|
128
|
-
list
|
129
|
-
List of registered function names.
|
130
|
-
|
131
|
-
Raises
|
132
|
-
------
|
133
|
-
ValueError
|
134
|
-
If the ``step`` is invalid.
|
135
|
-
|
136
|
-
"""
|
137
|
-
# Verify step
|
138
|
-
if step not in _VALID_STEPS:
|
139
|
-
raise_error(msg=f"Invalid step: {step}", klass=ValueError)
|
140
|
-
|
141
|
-
return list(_REGISTRY[step].keys())
|
142
|
-
|
143
|
-
|
144
|
-
def get_class(step: str, name: str) -> type:
|
145
|
-
"""Get the class of the registered function for a given step.
|
146
|
-
|
147
|
-
Parameters
|
148
|
-
----------
|
149
|
-
step : str
|
150
|
-
Name of the step.
|
151
|
-
name : str
|
152
|
-
Name of the function.
|
153
|
-
|
154
|
-
Returns
|
155
|
-
-------
|
156
|
-
class
|
157
|
-
Registered function class.
|
158
|
-
|
159
|
-
Raises
|
160
|
-
------
|
161
|
-
ValueError
|
162
|
-
If the ``step`` or ``name`` is invalid.
|
163
|
-
|
164
|
-
"""
|
165
|
-
# Verify step
|
166
|
-
if step not in _VALID_STEPS:
|
167
|
-
raise_error(msg=f"Invalid step: {step}", klass=ValueError)
|
168
|
-
# Verify step name
|
169
|
-
if name not in _REGISTRY[step]:
|
170
|
-
raise_error(msg=f"Invalid name: {name}", klass=ValueError)
|
171
|
-
|
172
|
-
# Check if first-time import, then import it
|
173
|
-
if isinstance(_REGISTRY[step][name], str):
|
174
|
-
klass = getattr(
|
175
|
-
importlib.import_module(
|
176
|
-
f"junifer.{_STEP_TO_SUBPKG_MAPPINGS[step]}"
|
177
|
-
),
|
178
|
-
name,
|
179
|
-
)
|
180
|
-
else:
|
181
|
-
klass = _REGISTRY[step][name]
|
182
|
-
|
183
|
-
return klass
|
184
|
-
|
185
|
-
|
186
|
-
def build(
|
187
|
-
step: str,
|
188
|
-
name: str,
|
189
|
-
baseclass: type,
|
190
|
-
init_params: Optional[Dict] = None,
|
191
|
-
) -> Union["BaseDataGrabber", "PipelineStepMixin", "BaseFeatureStorage"]:
|
192
|
-
"""Ensure that the given object is an instance of the given class.
|
193
|
-
|
194
|
-
Parameters
|
195
|
-
----------
|
196
|
-
step : str
|
197
|
-
Name of the step.
|
198
|
-
name : str
|
199
|
-
Name of the function.
|
200
|
-
baseclass : class
|
201
|
-
Class to be checked against.
|
202
|
-
init_params : dict or None, optional
|
203
|
-
Parameters to pass to the base class constructor (default None).
|
204
|
-
|
205
|
-
Returns
|
206
|
-
-------
|
207
|
-
object
|
208
|
-
An instance of the given base class.
|
209
|
-
|
210
|
-
Raises
|
211
|
-
------
|
212
|
-
RuntimeError
|
213
|
-
If there is a problem creating the instance.
|
214
|
-
ValueError
|
215
|
-
If the created object with the given name is not an instance of the
|
216
|
-
base class.
|
217
|
-
|
218
|
-
"""
|
219
|
-
# Set default init parameters
|
220
|
-
if init_params is None:
|
221
|
-
init_params = {}
|
222
|
-
# Get class of the registered function
|
223
|
-
logger.debug(f"Building {step}/{name}")
|
224
|
-
klass = get_class(step=step, name=name)
|
225
|
-
logger.debug(f"\tClass: {klass.__name__}")
|
226
|
-
logger.debug(f"\tInit params: {init_params}")
|
227
|
-
try:
|
228
|
-
# Create instance of the class
|
229
|
-
object_ = klass(**init_params)
|
230
|
-
except (ValueError, TypeError) as e:
|
231
|
-
raise_error(
|
232
|
-
msg=f"Failed to create {step} ({name}). Error: {e}",
|
233
|
-
klass=RuntimeError,
|
234
|
-
exception=e,
|
235
|
-
)
|
236
|
-
# Verify created instance belongs to the base class
|
237
|
-
if not isinstance(object_, baseclass):
|
238
|
-
raise_error(
|
239
|
-
msg=(
|
240
|
-
f"Invalid {step} ({object_.__class__.__name__}). "
|
241
|
-
f"Must inherit from {baseclass.__name__}"
|
242
|
-
),
|
243
|
-
klass=ValueError,
|
244
|
-
)
|
245
|
-
return object_
|