Prefect and Django #4163
Unanswered
abkfenris
asked this question in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I figured out how to get Prefect and Django to play together nicely after connecting a few threads between Slack discussions and issues.
The two most important bits:
django.setup()
before importing your models.stored_as_script=True
to make sure that thatdjango.setup()
is run.django.setup()
and importing your models within your tasks.Other hiccups that I encountered or solutions I found:
RUNNER
,TENANT
andUSER
tokens can do, and they aren't nested (aUSER
can't do everything aRUNNER
token can do, nor the other way around).TENANT
token (which can be exposed to your code as from thePREFECT__CLOUD__AUTH_TOKEN
environment variable).RUNNER
token (which can be exposed asPREFECT__CLOUD__AGENT__AUTH_TOKEN
)RUNNER
token for both, which actually let me register but then threw an error.python manage.py prefect --register --agent
and it will register the latest version of all my flows and start up an agent to run them.Here's a PR where I added Prefect to an existing Django project of mine. It also includes configuration changes for running the registration and agent command under docker-compose and Kubernetes.
Beta Was this translation helpful? Give feedback.
All reactions