Skip to content

Commit 9dbe193

Browse files
authored
Merge branch 'main' into publish-nodeloaderror
2 parents 9f8c8e7 + fe79ce7 commit 9dbe193

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

docs/source/changes.md

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ releases are available on [PyPI](https://pypi.org/project/pytask) and
3636
- {pull}`591` invalidates the cache of fsspec when checking whether a remote file
3737
exists. Otherwise, a remote file might be reported as missing although it was just
3838
created. See https://github.com/fsspec/s3fs/issues/851 for more info.
39+
- {pull}`593` recreate `PythonNode`s every run since they carry the `_NoDefault` enum as
40+
the value whose state is `None`.
3941
- {pull}`594` publishes `NodeLoadError`.
4042

4143
## 0.4.7 - 2024-03-19

src/_pytask/nodes.py

+2
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ def state(self) -> str | None:
280280
{meth}`object.__hash__` for more information.
281281
282282
"""
283+
if self.value is no_default:
284+
return None
283285
if self.hash:
284286
value = self.load()
285287
if callable(self.hash):

tests/test_execute.py

+12-15
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,12 @@ def task_example() -> Annotated[Dict[str, str], PythonNode(name="result")]:
519519
tmp_path.joinpath("task_module.py").write_text(textwrap.dedent(source))
520520
result = runner.invoke(cli, [tmp_path.as_posix()])
521521
assert result.exit_code == ExitCode.OK
522+
assert "1 Succeeded" in result.output
523+
524+
# Test that python nodes are recreated every run.
525+
result = runner.invoke(cli, [tmp_path.as_posix()])
526+
assert result.exit_code == ExitCode.OK
527+
assert "1 Succeeded" in result.output
522528

523529

524530
@pytest.mark.end_to_end()
@@ -544,10 +550,6 @@ def task_example() -> Annotated[Dict[str, str], nodes]:
544550
assert result.exit_code == ExitCode.OK
545551
assert "1 Succeeded" in result.output
546552

547-
result = runner.invoke(cli, [tmp_path.as_posix()])
548-
assert result.exit_code == ExitCode.OK
549-
assert "1 Skipped" in result.output
550-
551553

552554
@pytest.mark.end_to_end()
553555
def test_more_nested_pytree_and_python_node_as_return(runner, tmp_path):
@@ -568,15 +570,10 @@ def task_example() -> Annotated[Dict[str, str], nodes]:
568570
assert result.exit_code == ExitCode.OK
569571
assert "1 Succeeded" in result.output
570572

571-
result = runner.invoke(cli, [tmp_path.as_posix()])
572-
assert result.exit_code == ExitCode.OK
573-
assert "1 Skipped" in result.output
574-
575573

576574
@pytest.mark.end_to_end()
577575
def test_execute_tasks_and_pass_values_only_by_python_nodes(runner, tmp_path):
578576
source = """
579-
from pytask import PathNode
580577
from pytask import PythonNode
581578
from typing_extensions import Annotated
582579
from pathlib import Path
@@ -586,9 +583,9 @@ def test_execute_tasks_and_pass_values_only_by_python_nodes(runner, tmp_path):
586583
def task_create_text() -> Annotated[int, node_text]:
587584
return "This is the text."
588585
589-
node_file = PathNode(path=Path("file.txt"))
590-
591-
def task_create_file(text: Annotated[int, node_text]) -> Annotated[str, node_file]:
586+
def task_create_file(
587+
text: Annotated[int, node_text]
588+
) -> Annotated[str, Path("file.txt")]:
592589
return text
593590
"""
594591
tmp_path.joinpath("task_module.py").write_text(textwrap.dedent(source))
@@ -611,9 +608,9 @@ def test_execute_tasks_via_functional_api(tmp_path):
611608
def create_text() -> Annotated[int, node_text]:
612609
return "This is the text."
613610
614-
node_file = PathNode(path=Path("file.txt"))
615-
616-
def create_file(content: Annotated[str, node_text]) -> Annotated[str, node_file]:
611+
def create_file(
612+
content: Annotated[str, node_text]
613+
) -> Annotated[str, Path("file.txt")]:
617614
return content
618615
619616
if __name__ == "__main__":

0 commit comments

Comments
 (0)