Closed Andrew-S-Rosen closed 1 year ago
In your 2nd example, in make_more, val is an int:
return [val] * [3]
but this sort of thing doesn't work in Python:
>>> [3] * [3]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can't multiply sequence by non-int of type 'list'
That's the very last error in the stack trace you pasted.
Ooops... you're absolutely right. Okay, closing this because that was a silly error on my part.
I'm trying to create a minimal working example of a more complex error but haven't quite gotten it yet. Apologies for this one!
There are some other problems in your second example:
a join app should return a list of futures, and that list is a list of ints (because add
returns ints in the 2nd example)
you should not call .result() inside an app because that will block the worker until its result is ready - join_apps are specifically meant to make it so you don't need to call .result
inside an app, but you might need to structure your functions a bit differently to do so.
eg like this:
def workflow(a, b, c, f=add):
f_app = python_app(add)
future1 = f_app(a, b)
future2 = make_more(future1)
end = add_all(future2, c, f_app=f_app)
return end
@join_app
def add_all(many, c, f_app):
return [f_app(val, c) for val in many]
The workflow function doesn't need to be a @join_app, but can instead be a regular Python function that returns a Future - because it doesn't have any need to wait on dependencies.
The block of code that waits for result2
to be completed is the bit of code that should be a join app, because that bit of code needs to wait for some earlier future (result2) to complete.
Ah, perfect!! Thank you for reading my mind. The bit about how to not call .result()
in the app was something I was trying to sort out. This makes a lot more sense now and will probably resolve some of my other issues I've been running into.
Describe the bug Different behavior is observed when I pass a function or
PythonApp
as a kwarg to aJoinApp
versus when it is obtained from scope.Disclaimer: I understand that it is highly likely that I'm the problem, not Parsl, but I just haven't figure out how yet.
To Reproduce
To set the stage, note that the following works perfectly fine.
However, if I change the way the
add
function gets called, I get different behavior.The traceback is returned:
The same error occurs if I pass in
python_app(add)
as a kwarg directly.Expected behavior The same behavior should occur in both circumstances.
Environment
Distributed Environment