-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG: task.execute returns None despite the function returning a value #547
Comments
Hi @Ostheer, thanks for taking the time to file the issue. Your reproducible example may not be complete because I can run it. I slightly changed it since I do not know about the module import pytask
from pathlib import Path
for id_ in ("unique_id", "another_one"):
def some_fun(some_data):
assert isinstance(some_data, str)
print(some_data)
return some_data
pytask.task(
id=id_,
produces=Path(f"{id_}.txt"),
kwargs={"some_data": "stuff"}
)(some_fun) You are entirely correct about the type hints. They should be |
Hey @tobiasraabe, Thank you for your response. Your edit to the example code does not affect the nature of the symptom. The bandgetouw module is irrelevant here and just supplied my build directory. Have you been able to reproduce the issue with your modified code? |
Sorry if I was unclear. If I run the adapted code, the two files are produced. Everything works. This is why I asked whether something else is happening with your problem that is not reflected in your reproducible example. Have you run the adapted example? Does it throw an error on your side? |
It did throw the same error indeed. Because of the None type hint I started to doubt if I was even correct in expecting the function there to return anything. I just created a new virtual environment and that somehow solved the issue (despite having already upgraded pytask and all its deps). In any case, it works now. My only suggestion then is that type hint :). Thanks for checking in and keep up the good work! |
I am glad it is working now for you. #548 fixes the issue you mentioned. Thank you! |
main
branch of pytask.Code Sample, a copy-pastable example
Problem description
This is the output when I run
pytask -s
:Expected Output
The tasks should succeed and the
PathNode
should've save"stuff"
to the two output files.Instead,
PathNode.save
fails because it cannot save theNoneType
.I've traced back the problem to the
execute
method of theTask
class in_pytask.nodes
:There, the function (in this case
some_fun
) is called:return self.function(**kwargs)
.I inspected the return value of
self.function(**kwargs))
, and it is indeedNone
. Obviously, I was expecting that value to be the string fromsome_fun
.In my particular case, my function is a simple lambda wrapper around a function (related to this issue) defined elsewhere called
xrn_task
. I have been able to work around this issue with the following hack in the Task class:Additionally, I'm not sure why the return type hint of the execute method is
None
.The text was updated successfully, but these errors were encountered: