Hello! Does anyone know if there is a way to hide ...
# ask-community
b
Hello! Does anyone know if there is a way to hide Parameters on subflows from showing up in the Prefect Logs/UI?
1
k
Where are you seeing parameters currently where you'd like them not to be visible?
b
I am running a subflow here.
k
Subflow runs are displayed in the UI like any other flow run. Is the reason for not wanting to display parameters because sensitive data is being passed from parent flow to subflow?
b
Yes, sensitive data is being passed down. Would converting that task to another flow be the best option?
k
One option you have is to use
Secret
pydantic types, like
SecretStr
.
Copy code
from prefect import flow
from pydantic import SecretStr

@flow(log_prints=True)
def my_flow(name: str):
    secretName = SecretStr(name)
    my_subflow(secretName)

@flow(log_prints=True)
def my_subflow(secretName: SecretStr):
    name = secretName.get_secret_value()
    print(f"Hi {name} from the subflow!")

if __name__=="__main__":
    my_flow("Kevin")
Running that results in an obfuscated value in the UI.
🙌 3
m
I get this error using
SecretStr
type:
Copy code
RuntimeError: no validator found for <class 'pydantic.types.SecretStr'>, see `arbitrary_types_allowed` in Config
My code worked fine before upgrading to Prefect 2.13.7 which is begin of Pydantic V2 support.
k
I think the example I posted was on 2.14.2
m
Same differences, the Pydantic errors are popping up because of the dependency migration to V2. I suppose I can find the proper handling of SecretStr in the prefect source code, thats where I learned how to use SecretStr for custom credential blocks in the first place.
For poetry users having Pydantic problems: I was able to update prefect to latest version (2.14.3) by creating explicit dependency reference in my poetry-managed package:
Copy code
poetry add pydantic="^1.10"
Upgrading to pydantic V2 across a package can be a chore, so I'm just putting that off.