Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 31, 2025
1 parent 3cc5232 commit d2ab96f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
9 changes: 7 additions & 2 deletions new-docs/source/tutorial/tst.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
from pydra.design import python, workflow
from pydra.engine.submitter import Submitter


@python.define
def Add(x: float, y: float) -> float:
return x + y


@python.define
def Subtract(x: float, y: float) -> float:
return x - y


@python.define
def Divide(x: float, y: float) -> float:
return x / y


@workflow.define
def UnsafeWorkflow(a: float, b: float, c: float) -> float:
add = workflow.add(Add(x=a, y=b))
divide = workflow.add(Divide(x=add.out, y=c))
subtract = workflow.add(Subtract(x=divide.out, y=b))
return subtract.out


# This workflow will fail because we are trying to divide by 0
failing_workflow = UnsafeWorkflow(a=10, b=5).split(c=[3, 2 ,0])
failing_workflow = UnsafeWorkflow(a=10, b=5).split(c=[3, 2, 0])

with Submitter() as sub:
result = sub(failing_workflow)
result = sub(failing_workflow)
2 changes: 1 addition & 1 deletion pydra/engine/lazy.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def get_value(
TypeParser,
) # pylint: disable=import-outside-toplevel
from pydra.engine.state import StateIndex

if state_index is None:
state_index = StateIndex()

Expand Down
2 changes: 1 addition & 1 deletion pydra/engine/specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def _resolve_lazy_inputs(
The task definition with all lazy fields resolved
"""
from pydra.engine.state import StateIndex

if state_index is None:
state_index = StateIndex()
resolved = {}
Expand Down
3 changes: 2 additions & 1 deletion pydra/engine/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class StateIndex:
indices : dict[str, int]
a dictionary of indices for each input field
"""

indices: OrderedDict[str, int]

def __init__(self, indices: dict[str, int] | None = None):
Expand All @@ -53,7 +54,7 @@ def __eq__(self, other):

def __str__(self):
return "__".join(f"{n}-{i}" for n, i in self.indices.items())

def __bool__(self):
return bool(self.indices)

Expand Down

0 comments on commit d2ab96f

Please sign in to comment.