From 5889566848afbe53730618637870927e41126707 Mon Sep 17 00:00:00 2001 From: LanderOtto Date: Sun, 1 Feb 2026 14:49:39 +0100 Subject: [PATCH] feat --- streamflow/cwl/main.py | 1 + streamflow/cwl/runner.py | 1 + streamflow/cwl/translator.py | 11 ++++++++++- streamflow/parser.py | 5 +++++ tests/test_translator.py | 1 + 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/streamflow/cwl/main.py b/streamflow/cwl/main.py index 6b2d5171d..a4da2f772 100644 --- a/streamflow/cwl/main.py +++ b/streamflow/cwl/main.py @@ -74,6 +74,7 @@ async def main( context=context, name=args.name, output_directory=args.outdir, + hierarchical_output=args.hierarchical, cwl_definition=cwl_definition, cwl_inputs=cwl_inputs, cwl_inputs_path=cwl_args[1] if len(cwl_args) == 2 else None, diff --git a/streamflow/cwl/runner.py b/streamflow/cwl/runner.py index adca1b931..4561f4e66 100644 --- a/streamflow/cwl/runner.py +++ b/streamflow/cwl/runner.py @@ -87,6 +87,7 @@ async def _async_main(args: argparse.Namespace) -> None: streamflow_config["path"] = ( args.streamflow_file if args.streamflow_file is not None else os.getcwd() ) + args.hierarchical = False workflow_config = WorkflowConfig(workflow_name, streamflow_config) context = build_context(streamflow_config) try: diff --git a/streamflow/cwl/translator.py b/streamflow/cwl/translator.py index 4f70e8fdb..f912e0414 100644 --- a/streamflow/cwl/translator.py +++ b/streamflow/cwl/translator.py @@ -1589,6 +1589,7 @@ def __init__( context: StreamFlowContext, name: str, output_directory: str, + hierarchical_output: bool, cwl_definition: ( cwl_utils.parser.CommandLineTool | cwl_utils.parser.ExpressionTool @@ -1601,6 +1602,7 @@ def __init__( self.context: StreamFlowContext = context self.name: str = name self.output_directory: str = output_directory + self.hierarchical_output: bool = hierarchical_output self.cwl_definition: ( cwl_utils.parser.CommandLineTool | cwl_utils.parser.ExpressionTool @@ -3143,7 +3145,14 @@ def translate(self) -> Workflow: connector_ports={ target.deployment.name: deploy_step.get_output_port() }, - input_directory=self.output_directory, + input_directory=( + os.path.join( + self.output_directory, + output_name.lstrip(posixpath.sep), + ) + if self.hierarchical_output + else self.output_directory + ), binding_config=BindingConfig(targets=[target]), ) # Add the port as an input of the schedule step diff --git a/streamflow/parser.py b/streamflow/parser.py index 1bd236d63..71fe820eb 100644 --- a/streamflow/parser.py +++ b/streamflow/parser.py @@ -248,6 +248,11 @@ def __call__( type=str, help="Output directory in which to store final results of the workflow (default: current directory)", ) +run_parser.add_argument( + "--hierarchical", + action="store_true", + help="Preserve the output port structure (default: collapse all files into outdir)", +) run_parser.add_argument( "--quiet", action="store_true", help="Only prints results, warnings and errors" ) diff --git a/tests/test_translator.py b/tests/test_translator.py index c128913a8..dab8b3fa9 100644 --- a/tests/test_translator.py +++ b/tests/test_translator.py @@ -194,6 +194,7 @@ async def test_inject_remote_input( context=context, name=utils.random_name(), output_directory=tempfile.gettempdir(), + hierarchical_output=True, cwl_definition=None, # CWL object cwl_inputs=cwl_inputs, cwl_inputs_path=None,