Skip to content

Commit 3d937f8

Browse files
committed
Add data catalog name to nodes.
1 parent 5804f52 commit 3d937f8

File tree

7 files changed

+23
-12
lines changed

7 files changed

+23
-12
lines changed

Diff for: docs/source/how_to_guides/writing_custom_nodes.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ databases. [^kedro]
142142

143143
## References
144144

145-
[^structural-subtyping]: Structural subtyping is similar to ABCs an approach in Python to enforce interfaces, but
146-
it can be considered more pythonic since it is closer to duck typing. Hynek Schlawack
147-
wrote a comprehensive
145+
[^structural-subtyping]: Structural subtyping is similar to ABCs an approach in Python to enforce interfaces,
146+
but it can be considered more pythonic since it is closer to duck typing. Hynek
147+
Schlawack wrote a comprehensive
148148
[guide on subclassing](https://hynek.me/articles/python-subclassing-redux/) that
149149
features protocols under "Type 2". Glyph wrote an introduction to protocols called
150150
[I want a new duck](https://glyph.twistedmatrix.com/2020/07/new-duck.html).

Diff for: pyproject.toml

-6
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,6 @@ Tracker = "https://github.com/pytask-dev/pytask/issues"
8484
[project.scripts]
8585
pytask = "pytask:cli"
8686

87-
[tool.uv.sources]
88-
pytask-parallel = { workspace = true }
89-
90-
[tool.uv.workspace]
91-
members = ["packages/*"]
92-
9387
[tool.uv]
9488
dev-dependencies = [
9589
"tox-uv>=1.7.0", "pygraphviz"

Diff for: src/_pytask/console.py

+7
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from rich.theme import Theme
2525
from rich.tree import Tree
2626

27+
from _pytask.data_catalog_utils import DATA_CATALOG_NAME_FIELD
2728
from _pytask.node_protocols import PNode
2829
from _pytask.node_protocols import PPathNode
2930
from _pytask.node_protocols import PProvisionalNode
@@ -146,6 +147,12 @@ def format_node_name(
146147
"""Format the name of a node."""
147148
if isinstance(node, PPathNode):
148149
if node.name != node.path.as_posix():
150+
# Use getattr with default because on existing projects PNode.attribute does
151+
# not exist. Remove with v0.6.0.
152+
if data_catalog_name := getattr(node, "attributes", {}).get(
153+
DATA_CATALOG_NAME_FIELD
154+
):
155+
return Text(f"{data_catalog_name}::{node.name}")
149156
return Text(node.name)
150157
name = shorten_path(node.path, paths)
151158
return Text(name)

Diff for: src/_pytask/data_catalog.py

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from attrs import field
1818

1919
from _pytask.config_utils import find_project_root_and_config
20+
from _pytask.data_catalog_utils import DATA_CATALOG_NAME_FIELD
2021
from _pytask.exceptions import NodeNotCollectedError
2122
from _pytask.models import NodeInfo
2223
from _pytask.node_protocols import PNode
@@ -133,3 +134,4 @@ def add(self, name: str, node: PNode | PProvisionalNode | Any = None) -> None:
133134
msg = f"{node!r} cannot be parsed."
134135
raise NodeNotCollectedError(msg)
135136
self._entries[name] = collected_node
137+
self._entries[name].attributes[DATA_CATALOG_NAME_FIELD] = self.name

Diff for: src/_pytask/node_protocols.py

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class PNode(Protocol):
2121
"""Protocol for nodes."""
2222

2323
name: str
24+
attributes: dict[Any, Any]
2425

2526
@property
2627
def signature(self) -> str:
@@ -116,6 +117,7 @@ class PProvisionalNode(Protocol):
116117
"""
117118

118119
name: str
120+
attributes: dict[Any, Any]
119121

120122
@property
121123
def signature(self) -> str:

Diff for: src/_pytask/nodes.py

+4
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ class PathNode(PPathNode):
167167

168168
path: Path
169169
name: str = ""
170+
attributes: dict[Any, Any] = field(factory=dict)
170171

171172
@property
172173
def signature(self) -> str:
@@ -237,6 +238,7 @@ class PythonNode(PNode):
237238
value: Any | NoDefault = no_default
238239
hash: bool | Callable[[Any], bool] = False
239240
node_info: NodeInfo | None = None
241+
attributes: dict[Any, Any] = field(factory=dict)
240242

241243
@property
242244
def signature(self) -> str:
@@ -306,6 +308,7 @@ class PickleNode(PPathNode):
306308

307309
path: Path
308310
name: str = ""
311+
attributes: dict[Any, Any] = field(factory=dict)
309312

310313
@property
311314
def signature(self) -> str:
@@ -355,6 +358,7 @@ class DirectoryNode(PProvisionalNode):
355358
name: str = ""
356359
pattern: str = "*"
357360
root_dir: Path | None = None
361+
attributes: dict[Any, Any] = field(factory=dict)
358362

359363
@property
360364
def signature(self) -> str:

Diff for: uv.lock

+5-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)