https://prefect.io logo
Title
s

Stephen Herron

08/02/2022, 1:28 AM
Hi there - does this look right?
import asyncio
from prefect_snowflake import SnowflakeCredentials

from prefect import flow
creds = SnowflakeCredentials.load("credentials")

from prefect_snowflake.database import snowflake_query


@flow(name="Snowflake Query")
async def select_something():

    result = await snowflake_query(
        "select 1 as test",
        creds,
    )

if __name__ == "__main__":
    asyncio.run(select_something())
Seems to work locally but when I try to run ad-hoc via a deployment I get the error:
...
prefect_snowflake/database.py", line 69, in snowflake_query
    with snowflake_credentials.get_connection(**connect_params) as connection:
AttributeError: 'coroutine' object has no attribute 'get_connection'
a

alex

08/02/2022, 1:33 AM
Hey @Stephen Herron! That looks good for a local script, but in a deployment you'll need to
await
your
.load()
call and move the call inside your flow. We have some code that makes
.load()
sync compatible, but it isn't currently working in deployments.
s

Stephen Herron

08/02/2022, 11:16 AM
Hi @alex this game about from converting a “flow of flows” in prefect 1, where the flows would have been non-blocking, to subflows, where they would not run in parallel, if I’m understanding it correctly? seems to work now though after your suggestion of putting the creds in the flow with await :)