Dataclasses are just callables, and for a given dataclass one can straightforwardly construct an unambiguous atomic recipe to transform individual inputs -> dataclass instance outputs. Thus, it would be nice to be able to parse workflows like:
import dataclasses
import flowrep as fr
@fr.dataclass
class Payload:
item: str
multiple: int
def order(payload: Payload):
to_buy = f"Please buy {payload.multiple} {payload.item}s"
@fr.workflow
def shopping_for_two(item, n):
p = Payload(item, n)
to_buy = order(p)
return to_buy
I think if @fr.dataclass attaches a .flowrep_recipe: AtomicRecipe, and a partial function for that recipe to reference, this should work out-of-the-box. Compiling it might be slightly more of a headache, but I think it's just bookkeeping and not any fundamental obstacle.
I've already done something similar in pyiron_workflow to overload dataclasses.dataclass with workflow power-ups, so I know it's very doable and should be able to mostly just port parts of that solution here.
Dataclasses are just callables, and for a given dataclass one can straightforwardly construct an unambiguous atomic recipe to transform individual inputs -> dataclass instance outputs. Thus, it would be nice to be able to parse workflows like:
I think if
@fr.dataclassattaches a.flowrep_recipe: AtomicRecipe, and a partial function for that recipe to reference, this should work out-of-the-box. Compiling it might be slightly more of a headache, but I think it's just bookkeeping and not any fundamental obstacle.I've already done something similar in
pyiron_workflowto overloaddataclasses.dataclasswith workflow power-ups, so I know it's very doable and should be able to mostly just port parts of that solution here.