https://prefect.io logo
Title
j

Jhonatan Sossa

04/27/2023, 7:56 PM
Hello everyone, I am creating a deployment whit this code:
def build_and_register_flow(schedule_time, flow_name):
    """Build the prefect flow."""
    response = run_deployment(
        name=flow_name,
        scheduled_time=schedule_time,
        idempotency_key=schedule_time.strftime("%Y-%m-%d %H:%M:%S"),
        timeout=0
        )
    print(response)
But I am getting:
<coroutine object run_deployment at 0x7fc5082b9f40>
And the deployment is not set. Does anyone know what is going on?
1
n

nicholas

04/27/2023, 7:59 PM
Hi @Jhonatan Sossa - that’s an async operation so you’ll need to await it; when you say the deployment is not set, what do you mean?
j

Jhonatan Sossa

04/27/2023, 8:03 PM
I am trying to shedule a deployment run to a specific time and i doesn't work. I tried to add the await to the run_deployment but i got ''await' outside async function'
d

Deceivious

04/27/2023, 8:08 PM
import asyncio asyncio.run(deploymentcodehere)
Another solution is to keep adding async to all the methods up till the call 😄
😛 1
n

nicholas

04/27/2023, 8:15 PM
Either of those methods would work @Jhonatan Sossa - if your run isn’t showing up in the UI it’s possible you’re passing the name or schedule incorrectly, which the
response
should let you know
j

Jhonatan Sossa

04/27/2023, 8:57 PM
Thank you guys
👍 1