https://prefect.io logo
Title
d

Denis Sh

12/09/2022, 5:24 PM
Hi all, how do you guys check if Block exists inside a Flow? I tried wrapping with
storage_name = f"{self.account.name}-session"
try:
    self.session = JSON.load(storage_name)
except ValueError as e:
    self.logger.error(e)
    self.session = JSON(value={})
    self.session.save(name=storage_name)
    <http://self.logger.info|self.logger.info>(f"created session storage ({storage_name=})")
but flow keeps failing on this exception.. How to gracefully handle it? ADDED: seems the problem was capital letters in block name! otherwise code works as intended. fixed by modifying type in model definition for account.name to constr(to_lower=True)
1