Skip to content

Commit 9b2d93e

Browse files
authored
Rename Node back to MetaNode. (#371)
1 parent 5595ac5 commit 9b2d93e

11 files changed

Lines changed: 47 additions & 49 deletions

File tree

docs/source/reference_guides/api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,10 @@ The remaining exceptions convey specific errors.
266266
## Nodes
267267

268268
Nodes are the interface for different kinds of dependencies or products. They inherit
269-
from {class}`pytask.Node`.
269+
from {class}`pytask.MetaNode`.
270270

271271
```{eval-rst}
272-
.. autoclass:: pytask.Node
272+
.. autoclass:: pytask.MetaNode
273273
```
274274

275275
Then, different kinds of nodes can be implemented.

pyproject.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,14 @@ extend-ignore = [
7575

7676
[tool.ruff.pydocstyle]
7777
convention = "numpy"
78+
79+
80+
[tool.pytest.ini_options]
81+
testpaths = ["src", "tests"]
82+
markers = [
83+
"wip: Tests that are work-in-progress.",
84+
"unit: Flag for unit tests which target mainly a single function.",
85+
"integration: Flag for integration tests which may comprise of multiple unit tests.",
86+
"end_to_end: Flag for tests that cover the whole program.",
87+
]
88+
norecursedirs = [".idea", ".tox"]

src/_pytask/collect_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
if TYPE_CHECKING:
2222
from _pytask.session import Session
23-
from _pytask.nodes import Node
23+
from _pytask.nodes import MetaNode
2424

2525

2626
__all__ = ["depends_on", "parse_nodes", "produces"]
@@ -196,7 +196,7 @@ def _merge_dictionaries(list_of_dicts: list[dict[Any, Any]]) -> dict[Any, Any]:
196196

197197
def _collect_node(
198198
session: Session, path: Path, name: str, node: str | Path
199-
) -> dict[str, Node]:
199+
) -> dict[str, MetaNode]:
200200
"""Collect nodes for a task.
201201
202202
Parameters

src/_pytask/dag.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from _pytask.mark_utils import get_marks
2323
from _pytask.mark_utils import has_mark
2424
from _pytask.nodes import FilePathNode
25-
from _pytask.nodes import Node
25+
from _pytask.nodes import MetaNode
2626
from _pytask.nodes import Task
2727
from _pytask.path import find_common_ancestor_of_nodes
2828
from _pytask.report import DagReport
@@ -128,7 +128,7 @@ def _have_task_or_neighbors_changed(
128128

129129
@orm.db_session
130130
@hookimpl(trylast=True)
131-
def pytask_dag_has_node_changed(node: Node, task_name: str) -> bool:
131+
def pytask_dag_has_node_changed(node: MetaNode, task_name: str) -> bool:
132132
"""Indicate whether a single dependency or product has changed."""
133133
if isinstance(node, (FilePathNode, Task)):
134134
# If node does not exist, we receive None.
@@ -236,7 +236,7 @@ def _check_if_root_nodes_are_available(dag: nx.DiGraph) -> None:
236236

237237

238238
def _check_if_tasks_are_skipped(
239-
node: Node, dag: nx.DiGraph, is_task_skipped: dict[str, bool]
239+
node: MetaNode, dag: nx.DiGraph, is_task_skipped: dict[str, bool]
240240
) -> tuple[bool, dict[str, bool]]:
241241
"""Check for a given node whether it is only used by skipped tasks."""
242242
are_all_tasks_skipped = []

src/_pytask/hookspecs.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
if TYPE_CHECKING:
2020
from _pytask.session import Session
21-
from _pytask.nodes import Node
21+
from _pytask.nodes import MetaNode
2222
from _pytask.nodes import Task
2323
from _pytask.outcomes import CollectionOutcome
2424
from _pytask.outcomes import TaskOutcome
@@ -195,8 +195,8 @@ def pytask_collect_task_teardown(session: Session, task: Task) -> None:
195195

196196
@hookspec(firstresult=True)
197197
def pytask_collect_node(
198-
session: Session, path: pathlib.Path, node: Node
199-
) -> Node | None:
198+
session: Session, path: pathlib.Path, node: MetaNode
199+
) -> MetaNode | None:
200200
"""Collect a node which is a dependency or a product of a task."""
201201

202202

@@ -287,7 +287,7 @@ def pytask_dag_select_execution_dag(session: Session, dag: networkx.DiGraph) ->
287287

288288
@hookspec(firstresult=True)
289289
def pytask_dag_has_node_changed(
290-
session: Session, dag: networkx.DiGraph, node: Node, task_name: str
290+
session: Session, dag: networkx.DiGraph, node: MetaNode, task_name: str
291291
) -> None:
292292
"""Select the subgraph which needs to be executed.
293293

src/_pytask/nodes.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
from _pytask.mark import Mark
1818

1919

20-
__all__ = ["FilePathNode", "Node", "Task"]
20+
__all__ = ["FilePathNode", "MetaNode", "Task"]
2121

2222

23-
class Node(metaclass=ABCMeta):
23+
class MetaNode(metaclass=ABCMeta):
2424
"""Meta class for nodes."""
2525

2626
name: str
@@ -32,7 +32,7 @@ def state(self) -> Any:
3232

3333

3434
@define(kw_only=True)
35-
class Task(Node):
35+
class Task(MetaNode):
3636
"""The class for tasks which are Python functions."""
3737

3838
base_name: str
@@ -45,9 +45,9 @@ class Task(Node):
4545
"""The name of the task."""
4646
short_name: str | None = field(default=None, init=False)
4747
"""The shortest uniquely identifiable name for task for display."""
48-
depends_on: dict[str, Node] = field(factory=dict)
48+
depends_on: dict[str, MetaNode] = field(factory=dict)
4949
"""A list of dependencies of task."""
50-
produces: dict[str, Node] = field(factory=dict)
50+
produces: dict[str, MetaNode] = field(factory=dict)
5151
"""A list of products of task."""
5252
markers: list[Mark] = field(factory=list)
5353
"""A list of markers attached to the task function."""
@@ -82,7 +82,7 @@ def add_report_section(self, when: str, key: str, content: str) -> None:
8282

8383

8484
@define(kw_only=True)
85-
class FilePathNode(Node):
85+
class FilePathNode(MetaNode):
8686
"""The class for a node which is a path."""
8787

8888
name: str

src/_pytask/report.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616

1717
if TYPE_CHECKING:
18-
from _pytask.nodes import Node
18+
from _pytask.nodes import MetaNode
1919
from _pytask.nodes import Task
2020

2121

@@ -27,15 +27,15 @@ class CollectionReport:
2727
"""A collection report for a task."""
2828

2929
outcome: CollectionOutcome
30-
node: Node | None = None
30+
node: MetaNode | None = None
3131
exc_info: ExceptionInfo | None = None
3232

3333
@classmethod
3434
def from_exception(
3535
cls: type[CollectionReport],
3636
outcome: CollectionOutcome,
3737
exc_info: ExceptionInfo,
38-
node: Node | None = None,
38+
node: MetaNode | None = None,
3939
) -> CollectionReport:
4040
exc_info = remove_internal_traceback_frames_from_exc_info(exc_info)
4141
return cls(outcome=outcome, node=node, exc_info=exc_info)

src/_pytask/shared.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import networkx as nx
1212
from _pytask.console import format_task_id
1313
from _pytask.nodes import FilePathNode
14-
from _pytask.nodes import Node
14+
from _pytask.nodes import MetaNode
1515
from _pytask.nodes import Task
1616
from _pytask.path import find_closest_ancestor
1717
from _pytask.path import find_common_ancestor
@@ -57,7 +57,7 @@ def parse_paths(x: Any | None) -> list[Path] | None:
5757
return out
5858

5959

60-
def reduce_node_name(node: Node, paths: Sequence[str | Path]) -> str:
60+
def reduce_node_name(node: MetaNode, paths: Sequence[str | Path]) -> str:
6161
"""Reduce the node name.
6262
6363
The whole name of the node - which includes the drive letter - can be very long
@@ -75,7 +75,7 @@ def reduce_node_name(node: Node, paths: Sequence[str | Path]) -> str:
7575
except ValueError:
7676
ancestor = node.path.parents[-1]
7777

78-
if isinstance(node, Node):
78+
if isinstance(node, MetaNode):
7979
name = relative_to(node.path, ancestor).as_posix()
8080
else:
8181
raise TypeError(f"Unknown node {node} with type {type(node)!r}.")
@@ -95,7 +95,7 @@ def reduce_names_of_multiple_nodes(
9595
short_name = format_task_id(
9696
node, editor_url_scheme="no_link", short_name=True
9797
)
98-
elif isinstance(node, Node):
98+
elif isinstance(node, MetaNode):
9999
short_name = reduce_node_name(node, paths)
100100
else:
101101
raise TypeError(f"Requires 'Task' or 'Node' and not {type(node)!r}.")

src/pytask/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
from _pytask.mark_utils import set_marks
3434
from _pytask.models import CollectionMetadata
3535
from _pytask.nodes import FilePathNode
36-
from _pytask.nodes import Node
36+
from _pytask.nodes import MetaNode
3737
from _pytask.nodes import Task
3838
from _pytask.outcomes import CollectionOutcome
3939
from _pytask.outcomes import count_outcomes
@@ -78,7 +78,7 @@
7878
"Mark",
7979
"MarkDecorator",
8080
"MarkGenerator",
81-
"Node",
81+
"MetaNode",
8282
"NodeNotCollectedError",
8383
"NodeNotFoundError",
8484
"Persisted",

tests/test_collect_command.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from attrs import define
1111
from pytask import cli
1212
from pytask import ExitCode
13-
from pytask import Node
13+
from pytask import MetaNode
1414
from pytask import Task
1515

1616

@@ -304,7 +304,7 @@ def task_example_2():
304304

305305

306306
@define
307-
class Node(Node):
307+
class MetaNode(MetaNode):
308308
path: Path
309309

310310
def state(self):
@@ -323,8 +323,8 @@ def test_print_collected_tasks_without_nodes(capsys):
323323
base_name="function",
324324
path=Path("task_path.py"),
325325
function=function,
326-
depends_on={0: Node("in.txt")},
327-
produces={0: Node("out.txt")},
326+
depends_on={0: MetaNode("in.txt")},
327+
produces={0: MetaNode("out.txt")},
328328
)
329329
]
330330
}
@@ -346,8 +346,8 @@ def test_print_collected_tasks_with_nodes(capsys):
346346
base_name="function",
347347
path=Path("task_path.py"),
348348
function=function,
349-
depends_on={0: Node("in.txt")},
350-
produces={0: Node("out.txt")},
349+
depends_on={0: MetaNode("in.txt")},
350+
produces={0: MetaNode("out.txt")},
351351
)
352352
]
353353
}
@@ -370,8 +370,10 @@ def test_find_common_ancestor_of_all_nodes(show_nodes, expected_add):
370370
base_name="function",
371371
path=Path.cwd() / "src" / "task_path.py",
372372
function=function,
373-
depends_on={0: Node(Path.cwd() / "src" / "in.txt")},
374-
produces={0: Node(Path.cwd().joinpath("..", "bld", "out.txt").resolve())},
373+
depends_on={0: MetaNode(Path.cwd() / "src" / "in.txt")},
374+
produces={
375+
0: MetaNode(Path.cwd().joinpath("..", "bld", "out.txt").resolve())
376+
},
375377
)
376378
]
377379

0 commit comments

Comments
 (0)