<@ULVA73B9P> I have done `prefect block register -...
# ask-marvin
k
@Marvin I have done
prefect block register --file register_blocks.py
but the new class is not showing on my UI. Is there anything i am missing?
m
It appears that there are some documented issues related to UI components not functioning as expected in Prefect, but they may not directly address your concern. These issues are primarily about certain UI errors when blocks with complex fields are defined and input fields for Pydantic model parameters not displaying as intended, particularly with "code" type inputs and runtime defaults. For your specific problem regarding a new block class not showing in the UI, I would recommend checking a few things: 1. Ensure that the block registration script (
register_blocks.py
) has been executed successfully without errors. 2. Verify that the block registration script is correctly formatted and defining the blocks as per Prefect standards. 3. Make sure that the Prefect API is reachable and functional. Issues with network or API connectivity can sometimes prevent updates from being properly reflected in the UI. 4. Check for any logs or error messages that could provide more details on why the block is not being registered or displayed. This might involve looking into the server or API logs if possible. 5. Double-check that your Prefect version is up to date and that there are no known issues with block registration in your Prefect version. 6. If you're using Prefect Cloud, make sure that you're looking at the correct workspace and that there aren't any permission issues preventing the new blocks from being displayed. If after these checks the issue persists, it's possible that this might be an undocumented bug or an environmental issue specific to your setup. If you suspect a bug, consider reaching out to Prefect Support or filing an issue on Prefect's GitHub repository with detailed reproduction steps.
n
are you pointing at the server / workspace you expect?
e.g.
prefect config view
k
yes. I pointed it my server via env var
PREFECT_API_URL
👍 1
Should i be using something else?
n
nope, using
PREFECT_API_URL
in your profile is the normal way to tell prefect that commands should be run against a certain workspace / server what output do you get after the
prefect block register
command?
k
It's successful after i run it.
Copy code
Successfully registered 3 blocks
but i don't see any changes on the UI under blocks 😕
n
can you run
prefect block type ls
and maybe grep for a small part of your new block type slug?
also, sharing your block class implementation might be helpful
k
Copy code
class TestEnvVarsBlock(Block):
    def set_env_vars(self):
        for key, value in self.dict().items():
            # ignore slimey slugs - internal prefect stuff
            if value is not None and key != "block_type_slug":
                os.environ[key.upper()] = (
                    value.get_secret_value()
                    if isinstance(value, SecretStr)
                    else str(value)
                )


class TestCredentials(TestEnvVarsBlock):
    xxx_api_key: SecretStr  # Api key for prod
    xxx_api_key_dev: SecretStr  # Api key for dev
    xxx_api_key_preprod: SecretStr  # Api key for preprod
    github_token: SecretStr
    wandb_api_key: SecretStr
This is the class implementation
n
hm
your blocks register for me
k
Ah I think I am missing another step. The block type is there but I want to update what I have currently to add another value...
I thought block register would do the trick..
n
hmm yeah it should overwrite the existing schema for the block if you re-register 🧐
k
Sorry that was confusing
Do I need to recreate the block?
n
so what will for sure work, is to delete and recreate the block type with your new implementation
k
Is there a way to simply add the new value to existing block? I see the block type has been updated just not my existing block
n
but what should work is to just re-register, and we should overwrite the schema
ah
k
Hmmmm
so unfortunately its sort of tricky to automatically infer how block documents that were created with older / different schemas should be mapped onto a new arbitrary schema, so updating block documents to new schemas is more on the manual side for now
by schema i mean the shape of the class in your block implementation (Blocks are just fancy
BaseModel
)
k
Ah ok. I need to migrate them manually
Probably easier to just recreate then haha
n
yeah or just recreate
yep
k
Amazing, thank you!!
n
catjam
🙌 1