temp fix to sort out circular imports

This commit is contained in:
Leo Hemsted
2017-07-12 13:02:19 +01:00
parent 0e9e8955f7
commit 1a03248317
5 changed files with 15 additions and 9 deletions

View File

@@ -13,7 +13,6 @@ from notifications_utils.clients.redis.redis_client import RedisClient
from notifications_utils import logging, request_id
from werkzeug.local import LocalProxy
from app.celery.celery import NotifyCelery
from app.clients import Clients
from app.clients.email.aws_ses import AwsSesClient
from app.clients.sms.firetext import FiretextClient
@@ -26,6 +25,11 @@ DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%fZ"
DATE_FORMAT = "%Y-%m-%d"
db = SQLAlchemy()
# avoid circular import by importing after db
from app.celery.celery import NotifyCelery
ma = Marshmallow()
notify_celery = NotifyCelery()
firetext_client = FiretextClient()

View File

@@ -1,11 +1,11 @@
from datetime import timedelta
from app.celery import QueueNames
from celery import Celery
from celery.schedules import crontab
from kombu import Queue, Exchange
from app.config import QueueNames
from app.celery import QueueNames
class CeleryConfig:
def __init__(self, config):
@@ -83,13 +83,15 @@ class CeleryConfig:
'task': 'remove_csv_files',
'schedule': crontab(minute=0, hour=4),
'options': {'queue': QueueNames.PERIODIC},
'kwargs': {'job_types': [EMAIL_TYPE, SMS_TYPE]}
# TODO: Avoid duplication of keywords - ideally by moving definitions out of models.py
'kwargs': {'job_types': ['email', 'sms']}
},
'remove_letter_jobs': {
'task': 'remove_csv_files',
'schedule': crontab(minute=20, hour=4),
'options': {'queue': QueueNames.PERIODIC},
'kwargs': {'job_types': [LETTER_TYPE]}
# TODO: Avoid duplication of keywords - ideally by moving definitions out of models.py
'kwargs': {'job_types': ['letter']}
},
'remove_transformed_dvla_files': {
'task': 'remove_transformed_dvla_files',
@@ -122,7 +124,7 @@ class NotifyCelery(Celery):
Queue(queue, Exchange('default'), routing_key=queue)
)
self.config_from_object()
self.config_from_object(celery_config)
TaskBase = self.Task
class ContextTask(TaskBase):

View File

@@ -6,7 +6,7 @@ from notifications_utils.recipients import validate_and_format_phone_number
from app import statsd_client, firetext_client, mmg_client
from app.celery import tasks
from app.config import QueueNames
from app.celery import QueueNames
from app.dao.services_dao import dao_fetch_services_by_sms_sender
from app.dao.inbound_sms_dao import dao_create_inbound_sms
from app.models import InboundSms, INBOUND_SMS_TYPE, SMS_TYPE

View File

@@ -1,4 +1,4 @@
from app.config import QueueNames
from app.celery import QueueNames
from app.notifications.validators import (
check_service_over_daily_message_limit,
validate_and_format_recipient,

View File

@@ -5,7 +5,7 @@ import pytest
from notifications_utils.recipients import InvalidPhoneError
from app.v2.errors import BadRequestError, TooManyRequestsError
from app.config import QueueNames
from app.celery import QueueNames
from app.service.send_notification import send_one_off_notification
from app.models import KEY_TYPE_NORMAL, PRIORITY, SMS_TYPE