hpcflow / hpcflow-new

Mozilla Public License 2.0
0 stars 5 forks source link

Test and fix nested loops #678

Open aplowman opened 6 months ago

aplowman commented 6 months ago

Nested loops need some work. They can be defined but don't seem to work at all. E.g. this workflow:

ts1 = hf.TaskSchema(
    objective="t1",
    inputs=[hf.SchemaInput("p1")],
    outputs=[hf.SchemaOutput("p1")],
    actions=[
        hf.Action(
            commands=[
                hf.Command(
                    "Write-Output (<<parameter:p1>> + 100)",
                    stdout="<<int(parameter:p1)>>",
                )
            ],
        ),
    ],
)

wk = hf.Workflow.from_template_data(
    template_name="test_loop",
    path=tmp_path,
    tasks=[hf.Task(schema=ts1, inputs={"p1": 101})],
    loops=[
        hf.Loop(name="outer_loop", tasks=[0], num_iterations=2),
        hf.Loop(name="inner_loop", tasks=[0], num_iterations=2),
    ]
)
wk.submit(wait=True, status=False)

...raises: ValueError: Parent loop 'outer_loop' must be specified in `parent_loop_indices`.

aplowman commented 5 months ago

Fixes for various nested-loop bugs are now merged into develop. I will keep this issue open until I add some basic loop docs, including limitations that I identified. Namely, we don't yet support loops of indeterminate length having parent loops.