Skip to content

Can't load block value in Jupyter notebook #17877

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

Open
bnaul opened this issue Apr 21, 2025 · 1 comment
Open

Can't load block value in Jupyter notebook #17877

bnaul opened this issue Apr 21, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@bnaul
Copy link
Contributor

bnaul commented Apr 21, 2025

Bug summary

from prefect.blocks.core import Block

Block.load("secret/psql-host").get()

Works in a regular shell but fails in Jupyter with

AttributeError                            Traceback (most recent call last)
Input In [8], in <cell line: 3>()
      1 from prefect.blocks.core import Block
----> 3 Block.load("secret[/psql-host](http://localhost:8888/psql-host)").get()

AttributeError: 'coroutine' object has no attribute 'get'

Presumably something from #16341 that's getting tripped up by the Jupyter runtime environment (a little weird though that it doesn't happen in IPython).

Version info

Version:             3.3.5
API version:         0.8.4
Python version:      3.10.16
Git commit:          db4b7a33
Built:               Thu, Apr 17, 2025 09:25 PM
OS/Arch:             darwin/arm64
Profile:             default
Server type:         cloud
Pydantic version:    2.9.2
Integrations:
  prefect-dask:      0.3.3
  prefect-gcp:       0.6.4
  prefect-kubernetes: 0.5.8

Additional context

No response

@bnaul bnaul added the bug Something isn't working label Apr 21, 2025
@desertaxle
Copy link
Member

It looks like the .load() method is dispatching to the async implementation because there's an event loop available in the Jupyter notebook.

This will be fixed once #15008 is complete, but until then you can add _sync=True to prevent the automatic dispatch:

from prefect.blocks.core import Block

Block.load("secret/psql-host", _sync=True).get()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants