Prefect and Django #4163
abkfenris
started this conversation 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
Uh oh!
There was an error while loading. Please reload this page.
-
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=Trueto 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,TENANTandUSERtokens can do, and they aren't nested (aUSERcan't do everything aRUNNERtoken can do, nor the other way around).TENANTtoken (which can be exposed to your code as from thePREFECT__CLOUD__AUTH_TOKENenvironment variable).RUNNERtoken (which can be exposed asPREFECT__CLOUD__AGENT__AUTH_TOKEN)RUNNERtoken for both, which actually let me register but then threw an error.python manage.py prefect --register --agentand 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