File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11release : ./manage.py migrate
22web : gunicorn --bind 0.0.0.0:$PORT miqa.wsgi
3- worker : REMAP_SIGTERM=SIGQUIT celery --app miqa.celery worker --loglevel INFO --without-heartbeat
3+ # never use more than one worker; duplicate schedulers will result in duplicate tasks
4+ worker : REMAP_SIGTERM=SIGQUIT celery --app miqa.celery worker --loglevel INFO --without-heartbeat -B
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ services:
44 build :
55 context : .
66 dockerfile : ./dev/django.Dockerfile
7- command : ["./manage.py", "runserver", "0.0.0.0:8000"]
7+ command : [ "./manage.py", "runserver", "0.0.0.0:8000" ]
88 # Log printing via Rich is enhanced by a TTY
99 tty : true
1010 env_file : ./dev/.env.docker-compose
@@ -30,13 +30,17 @@ services:
3030 build :
3131 context : .
3232 dockerfile : ./dev/django.Dockerfile
33- command : [
34- " celery" ,
35- " --app" , "miqa.celery",
36- " worker" ,
37- " --loglevel" , "INFO",
38- " --without-heartbeat"
39- ]
33+ command :
34+ [
35+ " celery" ,
36+ " -A" ,
37+ " miqa.celery" ,
38+ " worker" ,
39+ " --loglevel" ,
40+ " INFO" ,
41+ " --without-heartbeat" ,
42+ " -B" # add celery beat worker to schedule automatic tasks
43+ ]
4044 # Docker Compose does not set the TTY width, which causes Celery errors
4145 tty : false
4246 env_file : ./dev/.env.docker-compose
@@ -50,7 +54,7 @@ services:
5054
5155 npm :
5256 image : node:latest
53- command : ["npm", "run", "serve"]
57+ command : [ "npm", "run", "serve" ]
5458 working_dir : /opt/client
5559 environment :
5660 # Fixes https://github.com/OpenImaging/miqa/issues/298
Original file line number Diff line number Diff line change @@ -49,6 +49,16 @@ def _download_from_s3(path: str, public: bool) -> bytes:
4949 return buf .getvalue ()
5050
5151
52+ @shared_task
53+ def reset_demo ():
54+ demo_project = Project .objects .get (name = 'Demo Project' )
55+ demo_project .import_path = 's3://miqa-storage/miqa.csv'
56+ demo_project .export_path = 'samples/demo.json'
57+ demo_project .save ()
58+ import_data (demo_project .id )
59+ Project .objects .exclude (id = demo_project .id ).delete ()
60+
61+
5262@shared_task
5363def evaluate_frame_content (frame_id ):
5464 from miqa .learning .evaluation_models import available_evaluation_models
Original file line number Diff line number Diff line change 1616)
1717from composed_configuration ._configuration import _BaseConfiguration
1818from configurations import values
19+ from celery .schedules import crontab
1920
2021
2122class MiqaMixin (ConfigMixin ):
@@ -45,6 +46,9 @@ class MiqaMixin(ConfigMixin):
4546 # Override default signup sheet to ask new users for first and last name
4647 ACCOUNT_FORMS = {'signup' : 'miqa.core.rest.accounts.AccountSignupForm' }
4748
49+ CELERY_BEAT_SCHEDULE = {}
50+
51+
4852 @staticmethod
4953 def before_binding (configuration : ComposedConfiguration ) -> None :
5054 # Install local apps first, to ensure any overridden resources are found first
@@ -85,6 +89,14 @@ def before_binding(configuration: ComposedConfiguration) -> None:
8589 'EXCEPTION_HANDLER'
8690 ] = 'miqa.core.rest.exceptions.custom_exception_handler'
8791
92+ if configuration .DEMO_MODE :
93+ configuration .CELERY_BEAT_SCHEDULE .update ({
94+ 'reset-demo' : {
95+ 'task' : 'miqa.core.tasks.reset_demo' ,
96+ 'schedule' : crontab (minute = 0 , hour = 0 ), # daily at midnight
97+ }
98+ })
99+
88100
89101class DevelopmentConfiguration (MiqaMixin , DevelopmentBaseConfiguration ):
90102 HOMEPAGE_REDIRECT_URL = values .Value (environ = True , default = 'http://localhost:8081' )
You can’t perform that action at this time.
0 commit comments