dkist-processing-test 1.21.3__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.
Potentially problematic release.
This version of dkist-processing-test might be problematic. Click here for more details.
- dkist_processing_test/__init__.py +11 -0
- dkist_processing_test/config.py +10 -0
- dkist_processing_test/models/__init__.py +0 -0
- dkist_processing_test/models/constants.py +18 -0
- dkist_processing_test/models/parameters.py +35 -0
- dkist_processing_test/tasks/__init__.py +10 -0
- dkist_processing_test/tasks/exercise_numba.py +42 -0
- dkist_processing_test/tasks/fail.py +11 -0
- dkist_processing_test/tasks/fake_science.py +101 -0
- dkist_processing_test/tasks/high_memory.py +20 -0
- dkist_processing_test/tasks/manual.py +26 -0
- dkist_processing_test/tasks/movie.py +53 -0
- dkist_processing_test/tasks/noop.py +15 -0
- dkist_processing_test/tasks/parse.py +88 -0
- dkist_processing_test/tasks/quality.py +30 -0
- dkist_processing_test/tasks/trial_output_data.py +46 -0
- dkist_processing_test/tasks/write_l1.py +64 -0
- dkist_processing_test/tests/__init__.py +0 -0
- dkist_processing_test/tests/conftest.py +64 -0
- dkist_processing_test/tests/test_parameters.py +103 -0
- dkist_processing_test/tests/test_tasks.py +724 -0
- dkist_processing_test/tests/test_workflows.py +9 -0
- dkist_processing_test/workflows/__init__.py +1 -0
- dkist_processing_test/workflows/common_tasks.py +231 -0
- dkist_processing_test/workflows/end_to_end.py +58 -0
- dkist_processing_test/workflows/exercise_numba.py +13 -0
- dkist_processing_test/workflows/fail.py +16 -0
- dkist_processing_test/workflows/noop.py +28 -0
- dkist_processing_test/workflows/resource_queue.py +19 -0
- dkist_processing_test/workflows/trial_end_to_end.py +64 -0
- dkist_processing_test-1.21.3.dist-info/METADATA +79 -0
- dkist_processing_test-1.21.3.dist-info/RECORD +34 -0
- dkist_processing_test-1.21.3.dist-info/WHEEL +5 -0
- dkist_processing_test-1.21.3.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
import pytest
|
|
5
|
+
from dkist_processing_common.tasks import WorkflowTaskBase
|
|
6
|
+
from dkist_processing_common.tasks.mixin.input_dataset import InputDatasetParameterValue
|
|
7
|
+
|
|
8
|
+
from dkist_processing_test.models.parameters import TestParameters
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@pytest.fixture(scope="session")
|
|
12
|
+
def file_parameter(
|
|
13
|
+
tmp_path_factory, random_parameter_hdulist, parameter_file_object_key
|
|
14
|
+
) -> tuple[InputDatasetParameterValue, float, float, float]:
|
|
15
|
+
hdul, mu, std, const = random_parameter_hdulist
|
|
16
|
+
file_path = tmp_path_factory.mktemp("parameters") / parameter_file_object_key
|
|
17
|
+
hdul.writeto(file_path)
|
|
18
|
+
|
|
19
|
+
value = {
|
|
20
|
+
"bucket": "raw",
|
|
21
|
+
"objectKey": parameter_file_object_key,
|
|
22
|
+
"param_path": file_path,
|
|
23
|
+
"is_file": True,
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
parameter_value = InputDatasetParameterValue(
|
|
27
|
+
parameter_value_id=1,
|
|
28
|
+
parameter_value=value,
|
|
29
|
+
parameter_value_start_date=datetime(1946, 11, 20),
|
|
30
|
+
)
|
|
31
|
+
return parameter_value, mu, std, const
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@pytest.fixture(scope="session")
|
|
35
|
+
def wavelength_parameter() -> InputDatasetParameterValue:
|
|
36
|
+
value = {"wavelength": [1.0, 2.0, 3.0], "values": ["one", "two", "three"]}
|
|
37
|
+
|
|
38
|
+
parameter_value = InputDatasetParameterValue(
|
|
39
|
+
parameter_value_id=2,
|
|
40
|
+
parameter_value=value,
|
|
41
|
+
parameter_value_start_date=datetime(1946, 11, 20),
|
|
42
|
+
)
|
|
43
|
+
return parameter_value
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@pytest.fixture(scope="session")
|
|
47
|
+
def parameter_dict_with_path(file_parameter, wavelength_parameter):
|
|
48
|
+
"""Enough of an input dataset parameters part to exercise file loading parameters."""
|
|
49
|
+
file_parameter_value, _, _, _ = file_parameter
|
|
50
|
+
|
|
51
|
+
param_dict = {
|
|
52
|
+
"test_random_data": [file_parameter_value],
|
|
53
|
+
"test_wavelength_category": [wavelength_parameter],
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return param_dict
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
@pytest.fixture(scope="session")
|
|
60
|
+
def task_with_parameters(parameter_dict_with_path):
|
|
61
|
+
class TaskWithParameters(WorkflowTaskBase):
|
|
62
|
+
def __init__(
|
|
63
|
+
self,
|
|
64
|
+
recipe_run_id: int,
|
|
65
|
+
workflow_name: str,
|
|
66
|
+
workflow_version: str,
|
|
67
|
+
):
|
|
68
|
+
super().__init__(
|
|
69
|
+
recipe_run_id=recipe_run_id,
|
|
70
|
+
workflow_name=workflow_name,
|
|
71
|
+
workflow_version=workflow_version,
|
|
72
|
+
)
|
|
73
|
+
self.parameters = TestParameters(
|
|
74
|
+
parameter_dict_with_path, wavelength=2.0, obs_ip_start_time="2024-06-11T12:00:00"
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
def run(self):
|
|
78
|
+
"""Do stuff."""
|
|
79
|
+
pass
|
|
80
|
+
|
|
81
|
+
task = TaskWithParameters(
|
|
82
|
+
recipe_run_id=0,
|
|
83
|
+
workflow_name="do_stuff",
|
|
84
|
+
workflow_version="VX.Y",
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
return task
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def test_parameter(task_with_parameters, file_parameter):
|
|
91
|
+
"""
|
|
92
|
+
Given: A task with parameters that depend on files
|
|
93
|
+
When: Accessing those parameters
|
|
94
|
+
Then: The correct values are returned
|
|
95
|
+
"""
|
|
96
|
+
task = task_with_parameters
|
|
97
|
+
_, mu, std, const = file_parameter
|
|
98
|
+
|
|
99
|
+
assert type(task.parameters.randomness) is tuple
|
|
100
|
+
np.testing.assert_allclose(np.array(task.parameters.randomness), np.array([mu, std]), rtol=1)
|
|
101
|
+
|
|
102
|
+
assert task.parameters.constant == const
|
|
103
|
+
assert task.parameters.wavelength_category == "two"
|