@flow decorator #416
Replies: 4 comments 8 replies
-
I am strongly in favor of this, in part because this is basically what many other workflow engines do (e.g. take Prefect, as an example). I think it is more intuitive to be able to use a |
Beta Was this translation helpful? Give feedback.
-
As a follow-up question to @davidwaroquiers: how would you handle dynamic flows with a |
Beta Was this translation helpful? Give feedback.
-
I like this idea. Although I think this will encourage people to shorten the code from: @flow
def make(a, b, maker):
j1 = maker.make(a)
j2 = maker.make(b)
add_job = AddMaker().make(j1.output, j2.output)
return add_job.output to @flow
def make(a, b, maker):
j1 = maker.make(a)
j2 = maker.make(b)
return AddMaker().make(j1.output, j2.output).output I.e., the |
Beta Was this translation helpful? Give feedback.
-
Ok I went back to this and tried to make it work. I think the current solution I had implemented (outside of jobflow) won't work except with quite some big uncertainties and/or vulnerabilities :/ |
Beta Was this translation helpful? Give feedback.
-
Hello everyone,
Just one idea that came up from presenting jobflow and giving trainings on it to several people, either from academy or from industry. In all cases, people were confused that the
make
method of a job maker needs to use an@job
decorator (actually, it is not mandatory, you can always return aJob
object directly but most of the time you'd use the decorator) while the make method of a flow maker does not have any. I think it would be nice to have something where we can put an@flow
decorator with some functionality. What I would see as useful is to be able to return the output directly (exactly the same as for jobs) and then the decorator creates itself the Flow, with the list of inner jobs/flows and the output set to the returned value. There might be other things that could be done by this decorator if needed/desired.Quick example usage:
In this example, the decorator means that the make method returns a Flow object equivalent to:
Flow([j1, j2], output={"result": j2.output, "random_info": 3.14})
I already discussed and exchanged a bit about this with @utf but I wanted to share the idea here so that other people can comment. As I already played a bit to make a proof-of concept implementation, I thought I'd just share it.
The proof-of-concept implementation only works within a single file (no time currently to try to fix it such that it can be importable from jobflow, but I can explain to whoever is interested what is the actual issue). Also if anyone has a better idea on how to implement this, do not hesitate to propose :)
Pinging @arosen93, @computron, @gpetretto as you all might be interested to give your opinions ;-)
POC implementation (in principle can be run directly if jobflow is installed):
Beta Was this translation helpful? Give feedback.
All reactions