https://prefect.io logo
Title
m

Matthew Scanlon

01/12/2023, 3:29 PM
Hi all, I am trying to register a custom block to prefect cloud via the cli tool, and seeing
Successfully registered 0 blocks
I have confirmed the file being registed is the intended python script. And worked up a minimal example that results in the same outcome. If i just do
class SampleBlock(Block):
    test: str
It still fails to register. Please help!
b

Bianca Hoch

01/12/2023, 3:38 PM
Hey Matthew, can you share what the cli command is looking like?
something like this?
$ prefect block register --file my_block.py
m

Matthew Scanlon

01/12/2023, 3:42 PM
That is correct. The file is at the top level of the directory. So i am just running
prefect block register --file blocks.py
Well this is awkard.... I am also import Block from the slack_sdk. So the class isnt being read as a prefect block. Gotta be careful with imports!
1
As a followup question. Is there a way to set one field as the unique key for a block? For instance if i have a block
MyBlock():
    Field 1
    Field 2
    Field 3
Is there a way I can tell prefect "Field 1 will always be unique, use this as the key" So i can load the block via MyBlock('foo') where field 1 == 'foo'
👀 1
b

Bianca Hoch

01/12/2023, 3:53 PM
Good question! I'll do some digging on my end, and raise to the team to see if they have any suggestions.
HI Matthew, at the current moment we don't have a solution for enforcing uniqueness for the field. I'd recommend opening a feature request in our github repo if you'd like. https://github.com/PrefectHQ/prefect/issues