-
Notifications
You must be signed in to change notification settings - Fork 7
Closed
Description
Related to aiidateam/aiida-workgraph#486, if you manually set an input for a task that is linked to a graph input or previous task, it will be "set", but unused. For example:
from aiida import load_profile
from aiida_workgraph import task
load_profile()
@task
def add(x, y):
return x + y
@task
def multiply(x, y):
return x * y
from aiida_workgraph import WorkGraph, spec
from typing import Any
with WorkGraph('AddMultiplyContextManager', inputs=spec.namespace(x=Any, y=Any, z=Any)) as wg:
the_sum = add(
x=wg.inputs.x,
y=wg.inputs.y,
).result
the_product = multiply(
x=the_sum,
y=wg.inputs.z,
).result
wg.outputs.result = the_product
wg.inputs = {"x": 2, "y": 3, "z": 4}
wg.tasks.multiply.inputs.y = 6
wg.run()
print(wg.tasks.add.inputs.x)
print(wg.tasks.add.inputs.y)
print(wg.tasks.multiply.inputs.x)
print(wg.tasks.multiply.inputs.y)
print(wg.outputs.result.value)
This returns
SocketAny(name='x', value=None)
SocketAny(name='y', value=None)
SocketAny(name='x', value=None)
SocketAny(name='y', value=6)
uuid: 07f3c705-b112-4fba-97fe-155c2a14b763 (pk: 29100) value: 20
This should raise an error, as discussed with @superstar54, as the y input is not actually used.
It would also be nice if we could somehow see something more akin to print(wg.tasks.add.inputs.x._links) when viewing the values that are None, but this is probably a different issue.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels