@@ -754,6 +754,32 @@ def my_represent_none(
754754 )
755755
756756
757+ def inherit_reqshints (tool : Process , parent : Process ) -> None :
758+ """Copy down requirements and hints from ancestors of a given process."""
759+ for parent_req in parent .requirements :
760+ found = False
761+ for tool_req in tool .requirements :
762+ if parent_req ["class" ] == tool_req ["class" ]:
763+ found = True
764+ break
765+ if not found :
766+ tool .requirements .append (parent_req )
767+ for parent_hint in parent .hints :
768+ found = False
769+ for tool_req in tool .requirements :
770+ if parent_hint ["class" ] == tool_req ["class" ]:
771+ found = True
772+ break
773+ if not found :
774+ for tool_hint in tool .hints :
775+ if parent_hint ["class" ] == tool_hint ["class" ]:
776+ found = True
777+ break
778+ if not found :
779+ tool .hints .append (parent_req )
780+ # TODO: get the parent of the parent and recurse
781+
782+
757783def choose_target (
758784 args : argparse .Namespace ,
759785 tool : Process ,
@@ -826,36 +852,33 @@ def choose_process(
826852 tool : Process ,
827853 loadingContext : LoadingContext ,
828854) -> Optional [Process ]:
829- """Walk the given Workflow and extract just args.single_step ."""
855+ """Walk the given Workflow and extract just args.single_process ."""
830856 if loadingContext .loader is None :
831857 raise Exception ("loadingContext.loader cannot be None" )
832858
833859 if isinstance (tool , Workflow ):
834860 url = urllib .parse .urlparse (tool .tool ["id" ])
835861 if url .fragment :
836- extracted = get_process (
837- tool ,
838- tool .tool ["id" ] + "/" + args .single_process ,
839- loadingContext .loader .idx ,
840- )
862+ step_id = tool .tool ["id" ] + "/" + args .single_process
841863 else :
842- extracted = get_process (
843- tool ,
844- loadingContext .loader .fetcher .urljoin (
845- tool .tool ["id" ], "#" + args .single_process
846- ),
847- loadingContext .loader .idx ,
864+ step_id = loadingContext .loader .fetcher .urljoin (
865+ tool .tool ["id" ], "#" + args .single_process
848866 )
867+ extracted , step_pos = get_process (
868+ tool ,
869+ step_id ,
870+ loadingContext .loader .idx ,
871+ )
849872 else :
850873 _logger .error ("Can only use --single-process on Workflows" )
851874 return None
852875 if isinstance (loadingContext .loader .idx , MutableMapping ):
853876 loadingContext .loader .idx [extracted ["id" ]] = extracted
854- tool = make_tool (extracted ["id" ], loadingContext )
877+ new_tool = make_tool (extracted ["id" ], loadingContext )
855878 else :
856879 raise Exception ("Missing loadingContext.loader.idx!" )
857-
858- return tool
880+ inherit_reqshints ( new_tool , tool . steps [ step_pos ])
881+ return new_tool
859882
860883
861884def check_working_directories (
0 commit comments