Thread
#prefect-community
    Tony Yun

    Tony Yun

    11 months ago
    Hi! I see a very weird issue, where I can fetch the Secret locally fine, but when I register the flow, it failed for the Secret not exist in local error:
    ValueError: Local Secret "CRITEO_SECRET_KEEPS" was not found.
    But running locally is totally fine:
    >>> prefect.client.Secret('CRITEO_SECRET_KEEPS').get()
    '1stxxxxg'
    Is there any possible reasons? I clearly defined the secret in local config file.
    I also have the secret defined on Cloud as well btw.
    Kevin Kho

    Kevin Kho

    11 months ago
    Can you try setting
    "PREFECT__CLOUD__USE_LOCAL_SECRETS" = "true"
    ?
    Oh wait this is different one sec
    Ok I tried it with a Docker Storage
    from prefect import Flow, task
    from prefect.client.secrets import Secret
    from prefect.storage import Docker
    
    storage = Docker(base_image="prefecthq/prefect:0.15.5-python3.8")
    
    x = Secret("TEST").get()
    
    @task
    def abc():
        x = Secret("TEST").get()
        return x
    
    with Flow("test", storage=storage) as flow:
        abc(x)
    
    flow.register("dsdc")
    and it’s working fine. I think at this point, I might need a reproducible example (or you can share you code with me privately if you are comfortable and I can try to re-create the structure)
    Tony Yun

    Tony Yun

    11 months ago
    ok! I’ll try get you a reproducible code when I have
    As a note of record, I solved this issue by moving this line from the parent level of the .py file into a function and then it worked:
    CRIETO_SECRET_KEEPS = get_secret('CRITEO_SECRET_KEEPS')
    ^this doesn’t work if in the parent level of a module somehow