https://prefect.io logo
a

Artem Vysotsky

05/08/2022, 3:44 PM
hey community, i’m switching to Prefect 2.0 cloud now and trying to programmatically register a deployment in the cloud. I have a webhook that when called need to register a deployment in the deployment cloud. What do I need to do to achieve this? Right now I have a very simple piece of code that fails because it calls into sqlite3 which is unexpected. I thought that Prefect will just call api cloud w/o any databases. How do I configure the process so that it starts calling the cloud api?
Copy code
import flow
from prefect.deployments import DeploymentSpec
from prefect.orion.schemas.schedules import CronSchedule


def create_deployment(name: str,
                      user_id: str,
                      job_id: str,
                      schedule: str):
    d = DeploymentSpec(
        flow=flow.flow,
        name=name,
        schedule=CronSchedule(
            cron=schedule
        ),
        parameters={
            user_id: user_id,
            job_id: job_id
        }
    )

    d.create_deployment()
k

Kevin Kho

05/08/2022, 4:31 PM
You need to set the environment variable to point to cloud. There are docs here for that. The place that you run this from should point to Cloud
a

Artem Vysotsky

05/08/2022, 4:47 PM
yes, thanks. works!
12 Views