mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-21 07:51:13 -05:00
temp fix to sort out circular imports
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user