aiidateam / aiida-workgraph

Efficiently design and manage flexible workflows with AiiDA, featuring an interactive GUI, checkpoints, provenance tracking, and remote execution capabilities.
https://aiida-workgraph.readthedocs.io/en/latest/
MIT License
10 stars 5 forks source link

Can not set the input socket manually for the kwargs #263

Closed superstar54 closed 3 months ago

superstar54 commented 3 months ago
from aiida_workgraph import WorkGraph, task
from aiida import load_profile

load_profile()

@task.calcfunction()
def add(x, y):
    return x +y

@task.calcfunction(inputs=[{"name": "data", "link_limit": 1000}])
def sum(**data):
    return sum(data.values())

wg = WorkGraph()
sum1 = wg.add_task(sum, name="sum1")
# sum1.inputs["data"].link_limit = 2

wg.add_task(add, name="add1", x=1, y=2)
wg.add_task(add, name="add2", x=3, y=4)
wg.add_link(wg.tasks["add1"].outputs["result"], wg.tasks["sum1"].inputs["data"])
wg.add_link(wg.tasks["add2"].outputs["result"], wg.tasks["sum1"].inputs["data"])
wg.run()
print("result: ", sum1.outputs["result"].value)

This will raise an error that the data socket already exists.