dkist-processing-core 7.2.2rc1__tar.gz → 7.2.2rc2__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.
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/PKG-INFO +1 -1
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core/build_utils.py +1 -4
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core/notebook_utils.py +22 -27
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core/tests/test_notebook_utils.py +16 -7
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core/workflow.py +3 -3
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core.egg-info/PKG-INFO +1 -1
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/.gitignore +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/.pre-commit-config.yaml +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/.readthedocs.yml +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/.snyk +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/CHANGELOG.rst +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/README.rst +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/bitbucket-pipelines.yml +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/changelog/.gitempty +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/changelog/72.misc.rst +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/changelog/76.feature.1.rst +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/changelog/76.feature.2.rst +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/changelog/77.misc.rst +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core/__init__.py +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core/config.py +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core/failure_callback.py +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core/node.py +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core/resource_queue.py +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core/task.py +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core/tests/__init__.py +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core/tests/conftest.py +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core/tests/invalid_workflow_cyclic/__init__.py +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core/tests/invalid_workflow_cyclic/workflow.py +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core/tests/invalid_workflow_for_docker_multi_category/__init__.py +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core/tests/invalid_workflow_for_docker_multi_category/workflow.py +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core/tests/task_example.py +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core/tests/test_build_utils.py +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core/tests/test_export.py +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core/tests/test_failure_callback.py +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core/tests/test_node.py +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core/tests/test_task.py +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core/tests/test_workflow.py +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core/tests/valid_workflow_package/__init__.py +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core/tests/valid_workflow_package/workflow.py +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core/tests/zero_node_workflow_package/__init__.py +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core/tests/zero_node_workflow_package/workflow.py +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core.egg-info/SOURCES.txt +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core.egg-info/dependency_links.txt +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core.egg-info/requires.txt +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core.egg-info/top_level.txt +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/docs/Makefile +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/docs/auto-proc-concept-model.png +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/docs/auto_proc_brick.png +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/docs/automated-processing-deployed.png +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/docs/changelog.rst +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/docs/conf.py +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/docs/index.rst +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/docs/landing_page.rst +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/docs/make.bat +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/docs/requirements.txt +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/licenses/LICENSE.rst +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/pyproject.toml +0 -0
- {dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/setup.cfg +0 -0
|
@@ -119,10 +119,7 @@ class NotebookDockerfile:
|
|
|
119
119
|
"COPY . /app",
|
|
120
120
|
"WORKDIR /app",
|
|
121
121
|
"RUN python -m pip install -U pip",
|
|
122
|
-
"RUN pip install
|
|
123
|
-
"RUN pip freeze | grep notebook= > constraints.txt",
|
|
124
|
-
"RUN cat constraints.txt",
|
|
125
|
-
"RUN python -m pip install -c constraints.txt .",
|
|
122
|
+
"RUN python -m pip install .",
|
|
126
123
|
]
|
|
127
124
|
|
|
128
125
|
@property
|
|
@@ -2,19 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
import time
|
|
4
4
|
from pathlib import Path
|
|
5
|
+
from uuid import uuid4
|
|
5
6
|
|
|
6
7
|
import nbformat
|
|
7
8
|
from nbconvert import MarkdownExporter
|
|
8
9
|
|
|
9
|
-
DEFAULT_EXPORT_SENTINEL = "MPW_EXPORT_READY"
|
|
10
|
-
|
|
11
10
|
|
|
12
11
|
def wait_for_notebook_save(
|
|
13
|
-
notebook_path: Path
|
|
14
|
-
sentinel: str =
|
|
15
|
-
attempts=120,
|
|
16
|
-
delay_s=1,
|
|
17
|
-
):
|
|
12
|
+
notebook_path: Path,
|
|
13
|
+
sentinel: str | None = None,
|
|
14
|
+
attempts: int = 120,
|
|
15
|
+
delay_s: int = 1,
|
|
16
|
+
) -> None:
|
|
18
17
|
"""
|
|
19
18
|
Wait until the notebook on disk contains the sentinel output.
|
|
20
19
|
|
|
@@ -37,28 +36,20 @@ def wait_for_notebook_save(
|
|
|
37
36
|
-------
|
|
38
37
|
None if the sentinel is found within the notebook outputs, otherwise raises a TimeoutError after the specified number of attempts.
|
|
39
38
|
"""
|
|
39
|
+
sentinel = sentinel or uuid4().hex
|
|
40
|
+
|
|
40
41
|
print(f"Waiting for notebook to save with sentinel '{sentinel}'...", flush=True)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
for cell in nb.cells:
|
|
47
|
-
if cell.cell_type == "code":
|
|
48
|
-
for output in cell.get("outputs", []):
|
|
49
|
-
text = ""
|
|
50
|
-
|
|
51
|
-
if output.output_type == "stream":
|
|
52
|
-
text = output.get("text", "")
|
|
53
|
-
elif output.output_type in ("execute_result", "display_data"):
|
|
54
|
-
text = str(output.get("data", ""))
|
|
55
|
-
if sentinel in text:
|
|
56
|
-
return
|
|
42
|
+
|
|
43
|
+
for _ in range(attempts):
|
|
44
|
+
text = notebook_path.read_text(encoding="utf-8")
|
|
45
|
+
if sentinel in text:
|
|
46
|
+
return
|
|
57
47
|
time.sleep(delay_s)
|
|
48
|
+
|
|
58
49
|
raise TimeoutError("Notebook did not save updated outputs in time")
|
|
59
50
|
|
|
60
51
|
|
|
61
|
-
def export_notebook_by_path(notebook_path) -> bytes:
|
|
52
|
+
def export_notebook_by_path(notebook_path: Path) -> bytes:
|
|
62
53
|
"""
|
|
63
54
|
Export the notebook at the given path to markdown format and return the resulting bytes.
|
|
64
55
|
|
|
@@ -66,10 +57,14 @@ def export_notebook_by_path(notebook_path) -> bytes:
|
|
|
66
57
|
----------
|
|
67
58
|
notebook_path
|
|
68
59
|
The path to the notebook file to export.
|
|
60
|
+
|
|
61
|
+
Returns
|
|
62
|
+
-------
|
|
63
|
+
The exported notebook in markdown format as bytes.
|
|
69
64
|
"""
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
notebook_contents = notebook_path.read_text(encoding="utf-8")
|
|
66
|
+
notebook = nbformat.reads(notebook_contents, as_version=nbformat.NO_CONVERT)
|
|
72
67
|
|
|
73
68
|
exporter = MarkdownExporter()
|
|
74
|
-
body, _ = exporter.from_notebook_node(
|
|
69
|
+
body, _ = exporter.from_notebook_node(notebook)
|
|
75
70
|
return body.encode("utf-8")
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"""Tests for the notebook_utils module"""
|
|
2
2
|
|
|
3
3
|
from pathlib import Path
|
|
4
|
+
from uuid import uuid4
|
|
4
5
|
|
|
5
6
|
import nbformat
|
|
6
7
|
import pytest
|
|
@@ -9,7 +10,6 @@ from nbformat.v4 import new_markdown_cell
|
|
|
9
10
|
from nbformat.v4 import new_notebook
|
|
10
11
|
from nbformat.v4 import new_output
|
|
11
12
|
|
|
12
|
-
from dkist_processing_core.notebook_utils import DEFAULT_EXPORT_SENTINEL
|
|
13
13
|
from dkist_processing_core.notebook_utils import export_notebook_by_path
|
|
14
14
|
from dkist_processing_core.notebook_utils import wait_for_notebook_save
|
|
15
15
|
|
|
@@ -28,7 +28,12 @@ def notebook_path_factory(tmp_path: Path):
|
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
@pytest.fixture
|
|
31
|
-
def
|
|
31
|
+
def notebook_sentinel() -> str:
|
|
32
|
+
return uuid4().hex
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@pytest.fixture
|
|
36
|
+
def notebook_with_sentinel_output(notebook_path_factory, notebook_sentinel) -> Path:
|
|
32
37
|
return notebook_path_factory(
|
|
33
38
|
cells=[
|
|
34
39
|
new_markdown_cell("# Title"),
|
|
@@ -38,7 +43,7 @@ def notebook_with_sentinel_output(notebook_path_factory) -> Path:
|
|
|
38
43
|
new_output(
|
|
39
44
|
output_type="stream",
|
|
40
45
|
name="stdout",
|
|
41
|
-
text=f"before {
|
|
46
|
+
text=f"before {notebook_sentinel} after",
|
|
42
47
|
)
|
|
43
48
|
],
|
|
44
49
|
),
|
|
@@ -65,10 +70,12 @@ def notebook_without_sentinel_output(notebook_path_factory) -> Path:
|
|
|
65
70
|
|
|
66
71
|
|
|
67
72
|
def test_wait_for_notebook_save_succeeds_when_sentinel_in_code_cell_output(
|
|
68
|
-
notebook_with_sentinel_output,
|
|
73
|
+
notebook_with_sentinel_output, notebook_sentinel
|
|
69
74
|
):
|
|
70
75
|
# no error raised
|
|
71
|
-
wait_for_notebook_save(
|
|
76
|
+
wait_for_notebook_save(
|
|
77
|
+
notebook_with_sentinel_output, sentinel=notebook_sentinel, attempts=1, delay_s=0
|
|
78
|
+
)
|
|
72
79
|
|
|
73
80
|
|
|
74
81
|
def test_wait_for_notebook_save_times_out_when_sentinel_missing(
|
|
@@ -78,7 +85,9 @@ def test_wait_for_notebook_save_times_out_when_sentinel_missing(
|
|
|
78
85
|
wait_for_notebook_save(notebook_without_sentinel_output, attempts=1, delay_s=0)
|
|
79
86
|
|
|
80
87
|
|
|
81
|
-
def test_export_notebook_by_path_returns_markdown_bytes(
|
|
88
|
+
def test_export_notebook_by_path_returns_markdown_bytes(
|
|
89
|
+
notebook_with_sentinel_output, notebook_sentinel
|
|
90
|
+
) -> None:
|
|
82
91
|
exported = export_notebook_by_path(notebook_with_sentinel_output)
|
|
83
92
|
|
|
84
93
|
assert isinstance(exported, bytes)
|
|
@@ -87,4 +96,4 @@ def test_export_notebook_by_path_returns_markdown_bytes(notebook_with_sentinel_o
|
|
|
87
96
|
|
|
88
97
|
assert "# Title" in output # markdown
|
|
89
98
|
assert "print('ready')" in output # code
|
|
90
|
-
assert
|
|
99
|
+
assert notebook_sentinel in output # output
|
{dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core/workflow.py
RENAMED
|
@@ -13,7 +13,7 @@ from dkist_processing_core.node import task_type_hint
|
|
|
13
13
|
from dkist_processing_core.node import upstreams_type_hint
|
|
14
14
|
from dkist_processing_core.resource_queue import ResourceQueue
|
|
15
15
|
|
|
16
|
-
__all__ = ["Workflow", "workflow_name_from_details"]
|
|
16
|
+
__all__ = ["Workflow", "workflow_name_from_details", "dag_name"]
|
|
17
17
|
|
|
18
18
|
MAXIMUM_ALLOWED_WORKFLOW_NAME_LENGTH = 100
|
|
19
19
|
|
|
@@ -226,7 +226,7 @@ class Workflow:
|
|
|
226
226
|
f.write("\n")
|
|
227
227
|
return workflow_py
|
|
228
228
|
|
|
229
|
-
def export_notebook(self, path: str | Path | None = None):
|
|
229
|
+
def export_notebook(self, path: str | Path | None = None) -> Path:
|
|
230
230
|
"""Render the workflow as a jupyter notebook."""
|
|
231
231
|
path = path or "notebooks/"
|
|
232
232
|
path = Path(path)
|
|
@@ -241,7 +241,7 @@ class Workflow:
|
|
|
241
241
|
nbf.write(nb, f)
|
|
242
242
|
return notebook_ipynb
|
|
243
243
|
|
|
244
|
-
def topological_sort(self) -> [Node]:
|
|
244
|
+
def topological_sort(self) -> list[Node]:
|
|
245
245
|
"""Use a topological sort to find a valid linear order for task execution."""
|
|
246
246
|
node_task_names = {node.task.__name__: node for node in self.nodes}
|
|
247
247
|
node_upstream_tasks = {node.task: node.upstreams for node in self.nodes}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/changelog/76.feature.1.rst
RENAMED
|
File without changes
|
{dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/changelog/76.feature.2.rst
RENAMED
|
File without changes
|
|
File without changes
|
{dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core/__init__.py
RENAMED
|
File without changes
|
{dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core/config.py
RENAMED
|
File without changes
|
|
File without changes
|
{dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core/node.py
RENAMED
|
File without changes
|
|
File without changes
|
{dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/dkist_processing_core/task.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dkist_processing_core-7.2.2rc1 → dkist_processing_core-7.2.2rc2}/docs/auto-proc-concept-model.png
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|