-
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.
Adds a system check for validating the Celery entrypoint (#254)
* Adds system check for validating the Celery entrypoint * Docstring updates.
- Loading branch information
1 parent
693ba78
commit 24b37a3
Showing
2 changed files
with
54 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
"""Application configuration and initialization logic. | ||
Subclasses of the Django `AppConfig` class are automatically loaded by Django | ||
and used to initialize the parent application. This includes encapsulating | ||
startup tasks and configuring how the application integrates with the framework. | ||
""" | ||
|
||
from django.apps import AppConfig | ||
from django.core.checks import register | ||
|
||
from .checks import * | ||
|
||
|
||
class SchedulerConfig(AppConfig): | ||
"""Configure the parent application""" | ||
|
||
name = 'apps.scheduler' | ||
|
||
def ready(self): | ||
"""Executed as soon as the Django application registry is fully populated.""" | ||
|
||
register(check_celery_is_importable) |
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,32 @@ | ||
"""System checks for verifying proper application configuration. | ||
System checks are used to report configuration errors in the parent | ||
application. See the `apps.py` file for their registration with the | ||
Django System Checks framework. | ||
""" | ||
|
||
from django.core.checks import Error | ||
|
||
import keystone_api | ||
|
||
__all__ = ['check_celery_is_importable'] | ||
|
||
|
||
def check_celery_is_importable(app_configs, **kwargs): | ||
"""Check the `` variable is importable from the top level package""" | ||
|
||
errors = [] | ||
try: | ||
from keystone_api import celery_app | ||
|
||
except ImportError: | ||
errors.append( | ||
Error( | ||
"missing `celery_app` variable", | ||
hint="Make sure the `celery_app` variable is importable from the top level package.", | ||
id="apps.scheduler.E001", | ||
obj=keystone_api | ||
) | ||
) | ||
|
||
return errors |