How can I extend a block class?

I’ve tried to make something like this to the Azure block:

class GzippedAzure(Azure):
    ...

It seems to work just fine, but I get this warning during runtime and it got me wondering if this is the right way to do this:

/lib/python3.10/site-packages/prefect/utilities/dispatch.py:162: UserWarning: Type ‘GzippedAzure’ at ./blocks/gzipped_azure.py:8 has key ‘azure’ that matches existing registered type ‘Azure’ from /home/ivarec/.local/lib/python3.10/site-packages/prefect/filesystems.py:585. The existing type will be overridden.

So, what’s the right way to do this?

It’s a fair warning clarifying that the type will be changed which sounds legit since you seem to be changing it to gzip

It might be because _block_type_name attribute on the new block is the same.

2 Likes

Worked perfectly. The only caveat is that I had to delete my block instance of Azure and recreate it as GzippedAzure via UI.

2 Likes

Note: if you are doing something similar, don’t forget to add the @sync_compatible decorator to your async method overrides.

2 Likes