forked from hotosm/fAIr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6c1929c
commit b6e1643
Showing
5 changed files
with
62 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# This will make sure the app is always imported when | ||
# Django starts so that shared_task will use this app. | ||
from .celery import app as celery_app | ||
|
||
__all__ = ("celery_app",) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
""" | ||
https://docs.celeryq.dev/en/stable/django/first-steps-with-django.html | ||
""" | ||
import os | ||
|
||
from celery import Celery | ||
from django.conf import settings | ||
|
||
# this code copied from manage.py | ||
# set the default Django settings module for the 'celery' app. | ||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "aiproject.settings") | ||
|
||
# app name | ||
app = Celery("aiproject") | ||
|
||
# read config from Django settings, the CELERY namespace would make celery | ||
# config keys has `CELERY` prefix | ||
app.config_from_object("django.conf:settings", namespace="CELERY") | ||
|
||
# discover and load tasks.py from from all registered Django apps | ||
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS) | ||
|
||
|
||
@app.task | ||
def train_model(x, y): | ||
import time | ||
|
||
time.sleep(5) | ||
return x / y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters