@@ -71,16 +71,30 @@ def produces(objects: PyTree[Any]) -> PyTree[Any]:
7171 return objects
7272
7373
74- def parse_nodes (
75- session : Session , path : Path , name : str , obj : Any , parser : Callable [..., Any ]
74+ def parse_nodes ( # noqa: PLR0913
75+ session : Session ,
76+ task_path : Path ,
77+ task_name : str ,
78+ node_path : Path ,
79+ obj : Any ,
80+ parser : Callable [..., Any ],
7681) -> Any :
7782 """Parse nodes from object."""
7883 arg_name = parser .__name__
7984 objects = _extract_nodes_from_function_markers (obj , parser )
8085 nodes = _convert_objects_to_node_dictionary (objects , arg_name )
8186 return tree_map (
8287 lambda x : _collect_decorator_node (
83- session , path , name , NodeInfo (arg_name , (), x )
88+ session ,
89+ node_path ,
90+ task_name ,
91+ NodeInfo (
92+ arg_name = arg_name ,
93+ path = (),
94+ value = x ,
95+ task_path = task_path ,
96+ task_name = task_name ,
97+ ),
8498 ),
8599 nodes ,
86100 )
@@ -226,7 +240,7 @@ def _merge_dictionaries(list_of_dicts: list[dict[Any, Any]]) -> dict[Any, Any]:
226240
227241
228242def parse_dependencies_from_task_function (
229- session : Session , path : Path , name : str , obj : Any
243+ session : Session , task_path : Path , task_name : str , node_path : Path , obj : Any
230244) -> dict [str , Any ]:
231245 """Parse dependencies from task function."""
232246 has_depends_on_decorator = False
@@ -235,7 +249,7 @@ def parse_dependencies_from_task_function(
235249
236250 if has_mark (obj , "depends_on" ):
237251 has_depends_on_decorator = True
238- nodes = parse_nodes (session , path , name , obj , depends_on )
252+ nodes = parse_nodes (session , task_path , task_name , node_path , obj , depends_on )
239253 dependencies ["depends_on" ] = nodes
240254
241255 task_kwargs = obj .pytask_meta .kwargs if hasattr (obj , "pytask_meta" ) else {}
@@ -248,7 +262,16 @@ def parse_dependencies_from_task_function(
248262 has_depends_on_argument = True
249263 dependencies ["depends_on" ] = tree_map (
250264 lambda x : _collect_decorator_node (
251- session , path , name , NodeInfo (arg_name = "depends_on" , path = (), value = x )
265+ session ,
266+ node_path ,
267+ task_name ,
268+ NodeInfo (
269+ arg_name = "depends_on" ,
270+ path = (),
271+ value = x ,
272+ task_path = task_path ,
273+ task_name = task_name ,
274+ ),
252275 ),
253276 kwargs ["depends_on" ],
254277 )
@@ -284,9 +307,15 @@ def parse_dependencies_from_task_function(
284307 nodes = tree_map_with_path (
285308 lambda p , x : _collect_dependency (
286309 session ,
287- path ,
288- name ,
289- NodeInfo (parameter_name , p , x ), # noqa: B023
310+ node_path ,
311+ task_name ,
312+ NodeInfo (
313+ arg_name = parameter_name , # noqa: B023
314+ path = p ,
315+ value = x ,
316+ task_path = task_path ,
317+ task_name = task_name ,
318+ ),
290319 ),
291320 value ,
292321 )
@@ -297,7 +326,10 @@ def parse_dependencies_from_task_function(
297326 isinstance (x , PythonNode ) and not x .hash for x in tree_leaves (nodes )
298327 )
299328 if not isinstance (nodes , PNode ) and are_all_nodes_python_nodes_without_hash :
300- dependencies [parameter_name ] = PythonNode (value = value , name = parameter_name )
329+ prefix = task_path .as_posix () + "::" + task_name if task_path else task_name
330+ node_name = prefix + "::" + parameter_name
331+
332+ dependencies [parameter_name ] = PythonNode (value = value , name = node_name )
301333 else :
302334 dependencies [parameter_name ] = nodes
303335 return dependencies
@@ -352,7 +384,7 @@ def task_example(produces: Annotated[..., Product]):
352384
353385
354386def parse_products_from_task_function (
355- session : Session , path : Path , name : str , obj : Any
387+ session : Session , task_path : Path , task_name : str , node_path : Path , obj : Any
356388) -> dict [str , Any ]:
357389 """Parse products from task function.
358390
@@ -372,7 +404,7 @@ def parse_products_from_task_function(
372404 # Parse products from decorators.
373405 if has_mark (obj , "produces" ):
374406 has_produces_decorator = True
375- nodes = parse_nodes (session , path , name , obj , produces )
407+ nodes = parse_nodes (session , task_path , task_name , node_path , obj , produces )
376408 out = {"produces" : nodes }
377409
378410 task_kwargs = obj .pytask_meta .kwargs if hasattr (obj , "pytask_meta" ) else {}
@@ -388,9 +420,15 @@ def parse_products_from_task_function(
388420 collected_products = tree_map_with_path (
389421 lambda p , x : _collect_product (
390422 session ,
391- path ,
392- name ,
393- NodeInfo (arg_name = "produces" , path = p , value = x ),
423+ node_path ,
424+ task_name ,
425+ NodeInfo (
426+ arg_name = "produces" ,
427+ path = p ,
428+ value = x ,
429+ task_path = task_path ,
430+ task_name = task_name ,
431+ ),
394432 is_string_allowed = True ,
395433 ),
396434 kwargs ["produces" ],
@@ -412,8 +450,8 @@ def parse_products_from_task_function(
412450 and parameter_name in parameters_with_node_annot
413451 ):
414452 msg = (
415- f"The value for the parameter { name !r} is defined twice in "
416- "'@pytask.mark.task(kwargs=...)' and in the type annotation. "
453+ f"The value for the parameter { parameter_name !r} is defined twice "
454+ "in '@pytask.mark.task(kwargs=...)' and in the type annotation. "
417455 "Choose only one option."
418456 )
419457 raise ValueError (msg )
@@ -425,9 +463,15 @@ def parse_products_from_task_function(
425463 collected_products = tree_map_with_path (
426464 lambda p , x : _collect_product (
427465 session ,
428- path ,
429- name ,
430- NodeInfo (parameter_name , p , x ), # noqa: B023
466+ node_path ,
467+ task_name ,
468+ NodeInfo (
469+ arg_name = parameter_name , # noqa: B023
470+ path = p ,
471+ value = x ,
472+ task_path = task_path ,
473+ task_name = task_name ,
474+ ),
431475 is_string_allowed = False ,
432476 ),
433477 value ,
@@ -439,9 +483,15 @@ def parse_products_from_task_function(
439483 collected_products = tree_map_with_path (
440484 lambda p , x : _collect_product (
441485 session ,
442- path ,
443- name ,
444- NodeInfo ("return" , p , x ),
486+ node_path ,
487+ task_name ,
488+ NodeInfo (
489+ arg_name = "return" ,
490+ path = p ,
491+ value = x ,
492+ task_path = task_path ,
493+ task_name = task_name ,
494+ ),
445495 is_string_allowed = False ,
446496 ),
447497 parameters_with_node_annot ["return" ],
@@ -454,9 +504,15 @@ def parse_products_from_task_function(
454504 collected_products = tree_map_with_path (
455505 lambda p , x : _collect_product (
456506 session ,
457- path ,
458- name ,
459- NodeInfo ("return" , p , x ),
507+ node_path ,
508+ task_name ,
509+ NodeInfo (
510+ arg_name = "return" ,
511+ path = p ,
512+ value = x ,
513+ task_path = task_path ,
514+ task_name = task_name ,
515+ ),
460516 is_string_allowed = False ,
461517 ),
462518 task_produces ,
0 commit comments