Skip to content

Commit 3bc4bd0

Browse files
committed
fix.
1 parent 3d937f8 commit 3bc4bd0

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

src/_pytask/console.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,7 @@ def format_node_name(
147147
"""Format the name of a node."""
148148
if isinstance(node, PPathNode):
149149
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-
):
150+
if data_catalog_name := node.attributes.get(DATA_CATALOG_NAME_FIELD):
155151
return Text(f"{data_catalog_name}::{node.name}")
156152
return Text(node.name)
157153
name = shorten_path(node.path, paths)

src/_pytask/data_catalog.py

+5
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ def __attrs_post_init__(self) -> None:
9393
# Initialize the data catalog with persisted nodes from previous runs.
9494
for path in self.path.glob("*-node.pkl"):
9595
node = pickle.loads(path.read_bytes()) # noqa: S301
96+
97+
# To ease transition from nodes with and without attributes and it if it
98+
# does not exist. Necessary since #650. Remove in v0.6.0.
99+
if not hasattr(node, "attributes"):
100+
node.attributes = {DATA_CATALOG_NAME_FIELD: self.name}
96101
self._entries[node.name] = node
97102

98103
def __getitem__(self, name: str) -> PNode | PProvisionalNode:

src/_pytask/data_catalog_utils.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
"""Contains utilities for the data catalog."""
2+
3+
__all__ = ["DATA_CATALOG_NAME_FIELD"]
4+
5+
6+
DATA_CATALOG_NAME_FIELD = "catalog_name"

0 commit comments

Comments
 (0)