Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions pydra/compose/tests/test_workflow_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import typing as ty
import attr
from pathlib import Path
from fileformats.generic import File
from pydra.engine.tests.utils import (
Add2,
Add2Wait,
Expand Down Expand Up @@ -4606,3 +4607,18 @@ def Worky(x: int, y: ty.List[int]):
outputs = Worky(x=10, y=[1, 2, 3, 4])(cache_root=tmp_path)
assert outputs.sum == 100
assert outputs.products == [10, 20, 30, 40]


def test_wf_lzin_passthrough(tmp_path: Path) -> None:
@workflow.define
def IdentityWorkflow(x: int) -> int:
return x

@workflow.define
def OuterWorkflow(x: int) -> int:
ident = workflow.add(IdentityWorkflow(x=x))
add2 = workflow.add(Add2(x=ident.out))
return add2.out

wf = OuterWorkflow(x=1)
assert wf(cache_root=tmp_path).out == 3
7 changes: 5 additions & 2 deletions pydra/compose/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
extract_fields_from_class,
)
from pydra.utils.general import attrs_values
from pydra.utils.typing import StateArray
from pydra.utils.typing import StateArray, is_lazy

if ty.TYPE_CHECKING:
from pydra.engine.workflow import Workflow
Expand Down Expand Up @@ -334,7 +334,10 @@ def _from_job(cls, job: "Job[WorkflowTask]") -> ty.Self:
values = {}
lazy_field: LazyOutField
for name, lazy_field in attrs_values(workflow.outputs).items():
val_out = lazy_field._get_value(workflow=workflow, graph=exec_graph)
if is_lazy(lazy_field):
val_out = lazy_field._get_value(workflow=workflow, graph=exec_graph)
else:
val_out = lazy_field # handle non-lazy inputs that are passed through
if isinstance(val_out, StateArray):
val_out = list(val_out) # implicitly combine state arrays
values[name] = val_out
Expand Down
3 changes: 2 additions & 1 deletion pydra/engine/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ def construct(
)
for outpt, outpt_lf in zip(output_fields, output_lazy_fields):
# Automatically combine any uncombined state arrays into a single lists
outpt_lf._type = State.combine_state_arrays(outpt_lf._type)
if isinstance(outpt_lf, LazyOutField):
outpt_lf._type = State.combine_state_arrays(outpt_lf._type)
setattr(outputs, outpt.name, outpt_lf)
else:
if unset_outputs := [
Expand Down
Loading