https://prefect.io logo
#prefect-community
Title
# prefect-community
m

merlin

10/03/2022, 11:58 PM
Noob question Sorry to post this here, but since its part of the Prefect docs it seems appropriate. I'm doing this tutorial from the blog Workflow without DAGs, a little confused by an error from the first code snippet
p102-13.py
If I leave
.result()
in the code, it fails with error:
Copy code
letter = get_letter().result()
AttributeError: 'str' object has no attribute 'result'
But remove the
.result()
bit and I get success:
Copy code
poetry run python src/quickstart/p102-13.py
16:48:31.385 | INFO    | prefect.engine - Created flow run 'jasper-uakari' for flow 'Result Flow'
16:48:31.454 | INFO    | Flow run 'jasper-uakari' - Created task run 'Get a letter-c414aff6-0' for task 'Get a letter'
16:48:31.454 | INFO    | Flow run 'jasper-uakari' - Executing 'Get a letter-c414aff6-0' immediately...
16:48:31.468 | INFO    | Task run 'Get a letter-c414aff6-0' - A
16:48:31.478 | INFO    | Task run 'Get a letter-c414aff6-0' - Finished in state Completed()
16:48:31.478 | INFO    | Flow run 'jasper-uakari' - You got: A
16:48:31.488 | INFO    | Flow run 'jasper-uakari' - Finished in state Completed('All states completed.')
The poetry environment is:
Copy code
[tool.poetry.dependencies]
 python = "^3.10"
 prefect = "^2.4.5"
 greenlet = "^1.1.3"
❤️ 1
1
m

Matt Conger

10/04/2022, 12:35 AM
Hey Merlin, results are now directly returned when calling a flow or task. This means that the .result() is no longer needed with the newest versions of Prefect 2. I've included some documentation explaining below. https://docs.prefect.io/concepts/results/?h=result
upvote 1
❤️ 1
m

merlin

10/04/2022, 12:49 AM
ohhhh, thats great!! I was going to complain about having to do .result. Thanks for keeping Prefect out of the way, its great!
🙌 1
j

Jeff Hale

10/04/2022, 2:18 PM
Just note that that tutorial is for a 2.0 beta version and 2.4.5 is the latest version, so there have been a number of changes. 🙂
🙌 1
3 Views