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
@@ -1,150 +0,0 @@
|
|
1
|
-
"""Provide tests 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
|
-
import logging
|
8
|
-
from abc import ABC
|
9
|
-
from typing import Type
|
10
|
-
|
11
|
-
import pytest
|
12
|
-
|
13
|
-
from junifer.datagrabber import PatternDataGrabber
|
14
|
-
from junifer.pipeline.registry import (
|
15
|
-
build,
|
16
|
-
get_class,
|
17
|
-
get_step_names,
|
18
|
-
register,
|
19
|
-
)
|
20
|
-
from junifer.storage import SQLiteFeatureStorage
|
21
|
-
|
22
|
-
|
23
|
-
def test_register_invalid_step():
|
24
|
-
"""Test register invalid step name."""
|
25
|
-
with pytest.raises(ValueError, match="Invalid step:"):
|
26
|
-
register(step="foo", name="bar", klass=str)
|
27
|
-
|
28
|
-
|
29
|
-
# TODO: improve parametrization
|
30
|
-
@pytest.mark.parametrize(
|
31
|
-
"step, name, klass",
|
32
|
-
[
|
33
|
-
("datagrabber", "pattern-dg", PatternDataGrabber),
|
34
|
-
("storage", "sqlite-storage", SQLiteFeatureStorage),
|
35
|
-
],
|
36
|
-
)
|
37
|
-
def test_register(
|
38
|
-
caplog: pytest.LogCaptureFixture, step: str, name: str, klass: Type
|
39
|
-
) -> None:
|
40
|
-
"""Test register.
|
41
|
-
|
42
|
-
Parameters
|
43
|
-
----------
|
44
|
-
caplog : pytest.LogCaptureFixture
|
45
|
-
The pytest.LogCaptureFixture object.
|
46
|
-
step : str
|
47
|
-
The parametrized name of the step.
|
48
|
-
name : str
|
49
|
-
The parametrized name of the function.
|
50
|
-
klass : str
|
51
|
-
The parametrized name of the base class.
|
52
|
-
|
53
|
-
"""
|
54
|
-
with caplog.at_level(logging.INFO):
|
55
|
-
# Register
|
56
|
-
register(step=step, name=name, klass=klass)
|
57
|
-
# Check logging message
|
58
|
-
assert "Registering" in caplog.text
|
59
|
-
|
60
|
-
|
61
|
-
def test_get_step_names_invalid_step() -> None:
|
62
|
-
"""Test get step name invalid step name."""
|
63
|
-
with pytest.raises(ValueError, match="Invalid step:"):
|
64
|
-
get_step_names(step="foo")
|
65
|
-
|
66
|
-
|
67
|
-
def test_get_step_names_absent() -> None:
|
68
|
-
"""Test get step names for absent name."""
|
69
|
-
# Get step names for datagrabber
|
70
|
-
datagrabbers = get_step_names(step="datagrabber")
|
71
|
-
# Check for datagrabber step name
|
72
|
-
assert "bar" not in datagrabbers
|
73
|
-
|
74
|
-
|
75
|
-
def test_get_step_names() -> None:
|
76
|
-
"""Test get step names."""
|
77
|
-
# Register datagrabber
|
78
|
-
register(step="datagrabber", name="bar", klass=str)
|
79
|
-
# Get step names for datagrabber
|
80
|
-
datagrabbers = get_step_names(step="datagrabber")
|
81
|
-
# Check for datagrabber step name
|
82
|
-
assert "bar" in datagrabbers
|
83
|
-
|
84
|
-
|
85
|
-
def test_get_class_invalid_step() -> None:
|
86
|
-
"""Test get class invalid step name."""
|
87
|
-
with pytest.raises(ValueError, match="Invalid step:"):
|
88
|
-
get_class(step="foo", name="bar")
|
89
|
-
|
90
|
-
|
91
|
-
def test_get_class_invalid_name() -> None:
|
92
|
-
"""Test get class invalid function name."""
|
93
|
-
with pytest.raises(ValueError, match="Invalid name:"):
|
94
|
-
get_class(step="datagrabber", name="foo")
|
95
|
-
|
96
|
-
|
97
|
-
# TODO: enable parametrization
|
98
|
-
def test_get_class():
|
99
|
-
"""Test get class."""
|
100
|
-
# Register datagrabber
|
101
|
-
register(step="datagrabber", name="bar", klass=str)
|
102
|
-
# Get class
|
103
|
-
obj = get_class(step="datagrabber", name="bar")
|
104
|
-
assert isinstance(obj, type(str))
|
105
|
-
|
106
|
-
|
107
|
-
# TODO: possible parametrization?
|
108
|
-
def test_build():
|
109
|
-
"""Test building objects from names."""
|
110
|
-
import numpy as np
|
111
|
-
|
112
|
-
# Define abstract base class
|
113
|
-
class SuperClass(ABC):
|
114
|
-
pass
|
115
|
-
|
116
|
-
# Define concrete class
|
117
|
-
class ConcreteClass(SuperClass):
|
118
|
-
def __init__(self, value=1):
|
119
|
-
self.value = value
|
120
|
-
|
121
|
-
# Register
|
122
|
-
register(step="datagrabber", name="concrete", klass=ConcreteClass)
|
123
|
-
|
124
|
-
# Build
|
125
|
-
obj = build(step="datagrabber", name="concrete", baseclass=SuperClass)
|
126
|
-
assert isinstance(obj, ConcreteClass)
|
127
|
-
assert obj.value == 1
|
128
|
-
|
129
|
-
# Build
|
130
|
-
obj = build(
|
131
|
-
step="datagrabber",
|
132
|
-
name="concrete",
|
133
|
-
baseclass=SuperClass,
|
134
|
-
init_params={"value": 2},
|
135
|
-
)
|
136
|
-
assert isinstance(obj, ConcreteClass)
|
137
|
-
assert obj.value == 2
|
138
|
-
|
139
|
-
# Check error
|
140
|
-
with pytest.raises(ValueError, match="Must inherit"):
|
141
|
-
build(step="datagrabber", name="concrete", baseclass=np.ndarray)
|
142
|
-
|
143
|
-
# Check error
|
144
|
-
with pytest.raises(RuntimeError, match="Failed to create"):
|
145
|
-
build(
|
146
|
-
step="datagrabber",
|
147
|
-
name="concrete",
|
148
|
-
baseclass=SuperClass,
|
149
|
-
init_params={"wrong": 2},
|
150
|
-
)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|