24
24
from rich .theme import Theme
25
25
from rich .tree import Tree
26
26
27
+ from _pytask .data_catalog_utils import DATA_CATALOG_NAME_FIELD
27
28
from _pytask .node_protocols import PNode
28
29
from _pytask .node_protocols import PPathNode
29
30
from _pytask .node_protocols import PProvisionalNode
42
43
43
44
__all__ = [
44
45
"console" ,
46
+ "create_panel_title" ,
45
47
"create_summary_panel" ,
46
48
"create_url_style_for_path" ,
47
49
"create_url_style_for_task" ,
@@ -146,6 +148,11 @@ def format_node_name(
146
148
"""Format the name of a node."""
147
149
if isinstance (node , PPathNode ):
148
150
if node .name != node .path .as_posix ():
151
+ # For example, any node added to a data catalog has its name set to the key.
152
+ if data_catalog_name := getattr (node , "attributes" , {}).get (
153
+ DATA_CATALOG_NAME_FIELD
154
+ ):
155
+ return Text (f"{ data_catalog_name } ::{ node .name } " )
149
156
return Text (node .name )
150
157
name = shorten_path (node .path , paths )
151
158
return Text (name )
@@ -156,6 +163,11 @@ def format_node_name(
156
163
reduced_name = shorten_path (Path (path ), paths )
157
164
return Text (f"{ reduced_name } ::{ rest } " )
158
165
166
+ # Python or other custom nodes that are not PathNodes.
167
+ if data_catalog_name := getattr (node , "attributes" , {}).get (
168
+ DATA_CATALOG_NAME_FIELD
169
+ ):
170
+ return Text (f"{ data_catalog_name } ::{ node .name } " )
159
171
return Text (node .name )
160
172
161
173
@@ -293,10 +305,15 @@ def create_summary_panel(
293
305
294
306
return Panel (
295
307
grid ,
296
- title = "[bold #f2f2f2] Summary[/]" ,
308
+ title = create_panel_title ( " Summary" ) ,
297
309
expand = False ,
298
310
style = "none" ,
299
311
border_style = outcome_enum .FAIL .style
300
312
if counts [outcome_enum .FAIL ]
301
313
else outcome_enum .SUCCESS .style ,
302
314
)
315
+
316
+
317
+ def create_panel_title (title : str ) -> Text :
318
+ """Create a title for a panel."""
319
+ return Text (title , style = "bold #f2f2f2" )
0 commit comments