Skip to content
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

Blocks in Prefect 2 can hold data not matching their schema #15619

Open
tharwan opened this issue Oct 9, 2024 · 0 comments
Open

Blocks in Prefect 2 can hold data not matching their schema #15619

tharwan opened this issue Oct 9, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@tharwan
Copy link

tharwan commented Oct 9, 2024

Bug summary

from prefect.blocks.core import Block
from prefect.testing.utilities import prefect_test_harness

with prefect_test_harness():
    class MyBlock(Block):
        setting_1: str = "foo"

    blk1 = MyBlock(setting_1 = "bar")
    blk1.save("a-block")
   

    # redefining the block with a new schema
    class MyBlock(Block):
        setting_2: float = 1


    blk2 = MyBlock(setting_2=0.5)
    blk2.save("a-block", overwrite=True)

    blk3 = MyBlock.load("a-block")
    print(blk3.setting_1) # old data still accessible
    print(blk3.setting_2)

when running the above code to simulate an update of a blocks schema, I can still access the old data from the previous schema after "migration". This is quite unexpected.

our current workaround is to delete the old block entirely before creating the new one.

Version info (prefect version output)

Version:             2.18.3
API version:         0.8.4
Python version:      3.11.6
Git commit:          c449aee8
Built:               Thu, May 2, 2024 5:47 PM
OS/Arch:             darwin/arm64
Profile:             default
Server type:         ephemeral
Server:
  Database:          sqlite
  SQLite version:    3.43.2

Additional context

No response

@tharwan tharwan added the bug Something isn't working label Oct 9, 2024
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

1 participant