dkist-processing-core 2.0.2rc1__tar.gz → 2.1.0__tar.gz

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 (50) hide show
  1. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/CHANGELOG.rst +18 -0
  2. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/PKG-INFO +1 -1
  3. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/dkist_processing_core/__init__.py +1 -0
  4. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/dkist_processing_core/_node.py +12 -0
  5. dkist-processing-core-2.1.0/dkist_processing_core/resource_queue.py +9 -0
  6. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/dkist_processing_core/tests/conftest.py +11 -1
  7. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/dkist_processing_core/tests/test_failure_callback.py +2 -2
  8. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/dkist_processing_core/tests/test_node.py +35 -9
  9. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/dkist_processing_core/tests/test_workflow.py +12 -4
  10. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/dkist_processing_core/workflow.py +6 -0
  11. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/dkist_processing_core.egg-info/PKG-INFO +1 -1
  12. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/dkist_processing_core.egg-info/SOURCES.txt +1 -1
  13. dkist-processing-core-2.0.2rc1/changelog/21.misc.rst +0 -1
  14. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/.gitignore +0 -0
  15. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/.pre-commit-config.yaml +0 -0
  16. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/.readthedocs.yml +0 -0
  17. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/README.rst +0 -0
  18. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/bitbucket-pipelines.yml +0 -0
  19. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/changelog/.gitempty +0 -0
  20. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/check_changelog_updated.sh +0 -0
  21. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/dkist_processing_core/_failure_callback.py +0 -0
  22. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/dkist_processing_core/build_utils.py +0 -0
  23. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/dkist_processing_core/task.py +0 -0
  24. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/dkist_processing_core/tests/__init__.py +0 -0
  25. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/dkist_processing_core/tests/invalid_workflow_package/__init__.py +0 -0
  26. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/dkist_processing_core/tests/invalid_workflow_package/workflow.py +0 -0
  27. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/dkist_processing_core/tests/task_example.py +0 -0
  28. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/dkist_processing_core/tests/test_build_utils.py +0 -0
  29. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/dkist_processing_core/tests/test_export.py +0 -0
  30. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/dkist_processing_core/tests/test_task.py +0 -0
  31. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/dkist_processing_core/tests/valid_workflow_package/__init__.py +0 -0
  32. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/dkist_processing_core/tests/valid_workflow_package/workflow.py +0 -0
  33. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/dkist_processing_core/tests/zero_node_workflow_package/__init__.py +0 -0
  34. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/dkist_processing_core/tests/zero_node_workflow_package/workflow.py +0 -0
  35. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/dkist_processing_core.egg-info/dependency_links.txt +0 -0
  36. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/dkist_processing_core.egg-info/requires.txt +0 -0
  37. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/dkist_processing_core.egg-info/top_level.txt +0 -0
  38. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/docs/Makefile +0 -0
  39. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/docs/auto-proc-concept-model.png +0 -0
  40. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/docs/auto_proc_brick.png +0 -0
  41. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/docs/automated-processing-deployed.png +0 -0
  42. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/docs/changelog.rst +0 -0
  43. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/docs/conf.py +0 -0
  44. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/docs/index.rst +0 -0
  45. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/docs/make.bat +0 -0
  46. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/docs/requirements.txt +0 -0
  47. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/licenses/LICENSE.rst +0 -0
  48. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/pyproject.toml +0 -0
  49. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/setup.cfg +0 -0
  50. {dkist-processing-core-2.0.2rc1 → dkist-processing-core-2.1.0}/setup.py +0 -0
@@ -1,3 +1,21 @@
1
+ v2.1.0 (2023-09-08)
2
+ ===================
3
+
4
+ Features
5
+ --------
6
+
7
+ - Support assigning a resource queue to a node in a workflow when adding it to the workflow. (`#22 <https://bitbucket.org/dkistdc/dkist-processing-core/pull-requests/22>`__)
8
+
9
+
10
+ v2.0.2 (2023-07-11)
11
+ ===================
12
+
13
+ Misc
14
+ ----
15
+
16
+ - Update airflow dependency to 2.6.3 (`#21 <https://bitbucket.org/dkistdc/dkist-processing-core/pull-requests/21>`__)
17
+
18
+
1
19
  v2.0.1 (2023-06-28)
2
20
  ===================
3
21
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dkist-processing-core
3
- Version: 2.0.2rc1
3
+ Version: 2.1.0
4
4
  Summary: Abstraction layer that is used by the DKIST Science Data Processing pipelines to process DKIST data using Apache Airflow.
5
5
  Home-page: https://bitbucket.org/dkistdc/dkist-processing-core/src/main/
6
6
  Author: NSO / AURA
@@ -2,6 +2,7 @@
2
2
  from pkg_resources import DistributionNotFound
3
3
  from pkg_resources import get_distribution
4
4
 
5
+ from dkist_processing_core.resource_queue import ResourceQueue
5
6
  from dkist_processing_core.task import TaskBase
6
7
  from dkist_processing_core.workflow import Workflow
7
8
 
@@ -4,6 +4,7 @@ from typing import Type
4
4
 
5
5
  from airflow.operators.bash import BashOperator
6
6
 
7
+ from dkist_processing_core.resource_queue import ResourceQueue
7
8
  from dkist_processing_core.task import TaskBase
8
9
 
9
10
 
@@ -20,6 +21,7 @@ class Node:
20
21
  workflow_version: str,
21
22
  workflow_package: str,
22
23
  task: task_type_hint,
24
+ resource_queue: ResourceQueue,
23
25
  upstreams: upstreams_type_hint = None,
24
26
  ):
25
27
  """Node setup."""
@@ -40,6 +42,7 @@ class Node:
40
42
  self.task = task
41
43
  self.workflow_package = workflow_package
42
44
  self.upstreams = upstreams
45
+ self.resource_queue = resource_queue
43
46
 
44
47
  @property
45
48
  def operator(self) -> BashOperator:
@@ -65,6 +68,7 @@ class Node:
65
68
  task_name='{self.task.__name__}'
66
69
  ),
67
70
  owner="DKIST Data Center",
71
+ queue="{self.resource_queue.value}",
68
72
  )
69
73
  """
70
74
 
@@ -130,3 +134,11 @@ python -m pip install {repo_name}=={version}"""
130
134
  with {self.task.__name__}(recipe_run_id={{{{dag_run.conf['recipe_run_id']}}}}, workflow_name='{self.workflow_name}', workflow_version='{self.workflow_version}') as task:
131
135
  task()
132
136
  """
137
+
138
+ def __repr__(self):
139
+ """Render node instantiation as a string."""
140
+ return f"Node(workflow_name={self.workflow_name}, workflow_version={self.workflow_version}, workflow_package={self.workflow_package}, task={self.task!r}, upstreams={self.upstreams}, queue={self.resource_queue!r})"
141
+
142
+ def __str__(self):
143
+ """Render node instance as a string."""
144
+ return repr(self)
@@ -0,0 +1,9 @@
1
+ """Resource queue names for Workflow Node specification which specify different resource needs."""
2
+ from enum import StrEnum
3
+
4
+
5
+ class ResourceQueue(StrEnum):
6
+ """Supported queue names."""
7
+
8
+ DEFAULT: str = "default"
9
+ HIGH_MEMORY: str = "high_memory"
@@ -6,6 +6,7 @@ from typing import Any
6
6
 
7
7
  import pytest
8
8
 
9
+ from dkist_processing_core import ResourceQueue
9
10
  from dkist_processing_core import TaskBase
10
11
  from dkist_processing_core import Workflow
11
12
  from dkist_processing_core._node import Node
@@ -104,8 +105,16 @@ def workflow_tasks(task_subclass) -> list[task_type_hint]:
104
105
  return [TaskA, TaskB, TaskC, TaskD]
105
106
 
106
107
 
108
+ @pytest.fixture(params=["default", "non_default"])
109
+ def queue_name(request):
110
+ """Name of the queue on the Node"""
111
+ if request.param == "default":
112
+ return ResourceQueue.DEFAULT
113
+ return ResourceQueue.HIGH_MEMORY
114
+
115
+
107
116
  @pytest.fixture(params=["0_upstream", "1_upstream", "2_upstream"])
108
- def node(workflow_tasks, request) -> tuple[Node, task_type_hint, Any, str, str]:
117
+ def node(workflow_tasks, request, queue_name) -> tuple[Node, task_type_hint, Any, str, str]:
109
118
  """Node instance and its component parts."""
110
119
  version = "V6-123"
111
120
  name = f"{request.param}_{version}"
@@ -124,6 +133,7 @@ def node(workflow_tasks, request) -> tuple[Node, task_type_hint, Any, str, str]:
124
133
  workflow_package=package,
125
134
  task=TaskA,
126
135
  upstreams=upstream[0],
136
+ resource_queue=queue_name,
127
137
  ),
128
138
  TaskA,
129
139
  upstream[1],
@@ -46,10 +46,10 @@ def env_vars(request):
46
46
  def test_recipe_run_failure_producer_factory(env_vars):
47
47
  """
48
48
  Given: recipe_run_failure_producer_factory.
49
- When: retrieving an producer from the factory.
49
+ When: retrieving a producer from the factory.
50
50
  Then: it is an instance of a talus.DurableBlockingProducerWrapper.
51
51
  """
52
- with pytest.raises(pika.exceptions.AMQPConnectionError):
52
+ with pytest.raises(pika.exceptions.AMQPError):
53
53
  recipe_run_failure_message_producer_factory().__enter__()
54
54
 
55
55
 
@@ -1,16 +1,30 @@
1
1
  """Tests of the _node.py module."""
2
2
  import subprocess
3
3
  from subprocess import CalledProcessError
4
+ from typing import Callable
4
5
 
5
6
  import pytest
6
7
  from airflow.operators.bash import BashOperator
7
8
  from jinja2 import Template
8
9
 
10
+ from dkist_processing_core import ResourceQueue
9
11
  from dkist_processing_core._node import Node
10
12
  from dkist_processing_core.tests.task_example import Task
11
13
 
12
14
 
13
- def test_nodes(node, fake_producer_factory):
15
+ @pytest.fixture()
16
+ def single_node() -> Node:
17
+ """A single Node instance."""
18
+ return Node(
19
+ workflow_name="test_node",
20
+ workflow_version="v1",
21
+ workflow_package=__package__,
22
+ task=Task,
23
+ resource_queue=ResourceQueue.DEFAULT,
24
+ )
25
+
26
+
27
+ def test_nodes(node, fake_producer_factory, queue_name):
14
28
  """
15
29
  Given: Workflow tasks to initialize a Node.
16
30
  When: Initializing the Node with valid task and upstreams.
@@ -29,6 +43,7 @@ def test_nodes(node, fake_producer_factory):
29
43
  assert node.upstreams == upstream
30
44
  assert node.task == task
31
45
  assert node.workflow_version == version
46
+ assert node.resource_queue == queue_name
32
47
 
33
48
 
34
49
  def test_node_bash_template_return_0(node):
@@ -55,20 +70,14 @@ def test_node_bash_template_return_1(node):
55
70
  subprocess.run(node._bash_template(cmd), shell=True, check=True)
56
71
 
57
72
 
58
- def test_node_python():
73
+ def test_node_python(single_node):
59
74
  """
60
75
  Given: Python jinja rendered with dag run data from a node instance.
61
76
  When: parsing the python call.
62
77
  Then: no exceptions raised.
63
78
  """
64
79
  # Given
65
- node = Node(
66
- workflow_name="test_node_python",
67
- workflow_version="v1",
68
- workflow_package=__package__,
69
- task=Task,
70
- )
71
- code_template = Template(node._python)
80
+ code_template = Template(single_node._python)
72
81
 
73
82
  class RenderData:
74
83
  def __init__(self):
@@ -114,3 +123,20 @@ def test_invalid_node(task_subclass):
114
123
  task=GoodTask,
115
124
  upstreams=[GoodTask, BadTask],
116
125
  )
126
+
127
+
128
+ @pytest.mark.parametrize(
129
+ "func, attr",
130
+ [
131
+ pytest.param(repr, "__repr__", id="repr"),
132
+ pytest.param(str, "__str__", id="str"),
133
+ ],
134
+ )
135
+ def test_node_dunder(single_node, func: Callable, attr: str):
136
+ """
137
+ Given: Node instance
138
+ When: retrieving dunder method that should be implemented.
139
+ Then: It is implemented.
140
+ """
141
+ assert getattr(single_node, attr, None)
142
+ assert func(single_node)
@@ -5,6 +5,7 @@ from typing import Callable
5
5
  import pytest
6
6
  from airflow import DAG
7
7
 
8
+ from dkist_processing_core import ResourceQueue
8
9
  from dkist_processing_core import Workflow
9
10
 
10
11
 
@@ -42,7 +43,14 @@ def test_workflow_metadata(workflow):
42
43
  )
43
44
 
44
45
 
45
- def test_workflow_add_node(workflow_tasks, workflow):
46
+ @pytest.mark.parametrize(
47
+ "queue",
48
+ [
49
+ pytest.param(None, id="None"),
50
+ pytest.param(ResourceQueue.HIGH_MEMORY, id="Specified"),
51
+ ],
52
+ )
53
+ def test_workflow_add_node(workflow_tasks, workflow, queue):
46
54
  """
47
55
  Given: A set of tasks and a workflow instance.
48
56
  When: Adding the tasks to the workflow in the
@@ -79,7 +87,7 @@ def test_workflow_add_node(workflow_tasks, workflow):
79
87
  },
80
88
  }
81
89
  for task, upstream in task_definitions.items():
82
- workflow_instance.add_node(task, upstreams=upstream)
90
+ workflow_instance.add_node(task, resource_queue=queue, upstreams=upstream)
83
91
 
84
92
  dag = workflow_instance.load()
85
93
  assert dag.task_count == 4
@@ -115,9 +123,9 @@ def test_invalid_workflow_add_node(workflow):
115
123
  pytest.param(str, "__str__", id="str"),
116
124
  ],
117
125
  )
118
- def test_tag_db_dunder(workflow, func: Callable, attr):
126
+ def test_workflow_dunder(workflow, func: Callable, attr):
119
127
  """
120
- Given: Connection to a tag database.
128
+ Given: workflow instance.
121
129
  When: retrieving dunder method that should be implemented.
122
130
  Then: It is implemented.
123
131
  """
@@ -6,6 +6,7 @@ from pathlib import Path
6
6
 
7
7
  from airflow import DAG
8
8
 
9
+ from dkist_processing_core import ResourceQueue
9
10
  from dkist_processing_core._node import Node
10
11
  from dkist_processing_core._node import task_type_hint
11
12
  from dkist_processing_core._node import upstreams_type_hint
@@ -161,13 +162,18 @@ class Workflow:
161
162
  self,
162
163
  task: task_type_hint,
163
164
  upstreams: upstreams_type_hint = None,
165
+ resource_queue: ResourceQueue | None = None,
164
166
  ) -> None:
165
167
  """Add a node and edges from that node to the workflow."""
168
+ if resource_queue is None:
169
+ resource_queue = ResourceQueue.DEFAULT
170
+
166
171
  node = Node(
167
172
  workflow_name=self.workflow_name,
168
173
  workflow_version=self.workflow_version,
169
174
  workflow_package=self.workflow_package,
170
175
  task=task,
176
+ resource_queue=resource_queue,
171
177
  upstreams=upstreams,
172
178
  )
173
179
  self.nodes.append(node)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dkist-processing-core
3
- Version: 2.0.2rc1
3
+ Version: 2.1.0
4
4
  Summary: Abstraction layer that is used by the DKIST Science Data Processing pipelines to process DKIST data using Apache Airflow.
5
5
  Home-page: https://bitbucket.org/dkistdc/dkist-processing-core/src/main/
6
6
  Author: NSO / AURA
@@ -9,11 +9,11 @@ pyproject.toml
9
9
  setup.cfg
10
10
  setup.py
11
11
  changelog/.gitempty
12
- changelog/21.misc.rst
13
12
  dkist_processing_core/__init__.py
14
13
  dkist_processing_core/_failure_callback.py
15
14
  dkist_processing_core/_node.py
16
15
  dkist_processing_core/build_utils.py
16
+ dkist_processing_core/resource_queue.py
17
17
  dkist_processing_core/task.py
18
18
  dkist_processing_core/workflow.py
19
19
  dkist_processing_core.egg-info/PKG-INFO
@@ -1 +0,0 @@
1
- Update airflow dependency to 2.6.3.