Skip to content

Commit

Permalink
Simplify the teardown of a task.
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasraabe committed Nov 8, 2023
1 parent fe984d2 commit e8e602d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
1 change: 1 addition & 0 deletions docs/source/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ releases are available on [PyPI](https://pypi.org/project/pytask) and
It is delegated to the check during the execution.
- {pull}`481` improves coverage.
- {pull}`482` correctly handles names and signatures of {class}`~pytask.PythonNode`.
- {pull}`483` simplifies the teardown of a task.

## 0.4.1 - 2023-10-11

Expand Down
15 changes: 4 additions & 11 deletions src/_pytask/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,19 +196,12 @@ def pytask_execute_task(session: Session, task: PTask) -> bool:
@hookimpl
def pytask_execute_task_teardown(session: Session, task: PTask) -> None:
"""Check if :class:`_pytask.nodes.PathNode` are produced by a task."""
missing_nodes = []
for product in session.dag.successors(task.signature):
node = session.dag.nodes[product]["node"]
if not node.state():
missing_nodes.append(node)

missing_nodes = [node for node in tree_leaves(task.produces) if not node.state()] # type: ignore[attr-defined]
if missing_nodes:
paths = [
format_node_name(i, session.config["paths"]).plain for i in missing_nodes
]
paths = session.config["paths"]
files = [format_node_name(i, paths).plain for i in missing_nodes] # type: ignore[arg-type]
formatted = format_strings_as_flat_tree(
paths,
"The task did not produce the following files:\n",
files, "The task did not produce the following files:\n"
)
raise NodeNotFoundError(formatted)

Expand Down

0 comments on commit e8e602d

Please sign in to comment.