2424from rich .theme import Theme
2525from rich .tree import Tree
2626
27+ from _pytask .data_catalog_utils import DATA_CATALOG_NAME_FIELD
2728from _pytask .node_protocols import PNode
2829from _pytask .node_protocols import PPathNode
2930from _pytask .node_protocols import PProvisionalNode
4243
4344__all__ = [
4445 "console" ,
46+ "create_panel_title" ,
4547 "create_summary_panel" ,
4648 "create_url_style_for_path" ,
4749 "create_url_style_for_task" ,
@@ -146,6 +148,11 @@ def format_node_name(
146148 """Format the name of a node."""
147149 if isinstance (node , PPathNode ):
148150 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 } " )
149156 return Text (node .name )
150157 name = shorten_path (node .path , paths )
151158 return Text (name )
@@ -156,6 +163,11 @@ def format_node_name(
156163 reduced_name = shorten_path (Path (path ), paths )
157164 return Text (f"{ reduced_name } ::{ rest } " )
158165
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 } " )
159171 return Text (node .name )
160172
161173
@@ -293,10 +305,15 @@ def create_summary_panel(
293305
294306 return Panel (
295307 grid ,
296- title = "[bold #f2f2f2] Summary[/]" ,
308+ title = create_panel_title ( " Summary" ) ,
297309 expand = False ,
298310 style = "none" ,
299311 border_style = outcome_enum .FAIL .style
300312 if counts [outcome_enum .FAIL ]
301313 else outcome_enum .SUCCESS .style ,
302314 )
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