from .celery import celery_app from analyzer.models import UAVEstimator # Logging section from utils.logs.tools import get_child_logger_by_name logger = get_child_logger_by_name(__name__) @celery_app.task def dispatch_estimation(*args,**kwargs): logger.debug("Received the new estimation tasks. Parameters are:") logger.debug("Args: " + ",".join(args)) logger.debug("Kwargs: " + str(kwargs)) start_date = kwargs.get("start_date") end_date = kwargs.get("end_date") num_clusters = kwargs.get('num_clusters') method = kwargs.get("method") estimator = UAVEstimator(method) logger.info("Scheduling a new estimation task...") estimator.run_estimation(start_date, end_date, num_clusters, **kwargs)
from flask_cors import CORS from storage import MongoDBStorageAdapter from utils.tools import BSONClassEncoder from utils.normalizers import DefaultNormalizer from workers.tools.integrations import make_celery from workers.tasks import dispatch_estimation from workers.celery import connection_string from workers.tools.stats import get_active_tasks_list, get_registered_tasks_list, get_scheduled_tasks_list from datavisual import APP_NAME # Logging section from utils.logs.tools import get_child_logger_by_name logger = get_child_logger_by_name(APP_NAME) app = Flask(APP_NAME) app.config.update(CELERY_BROKER_URL=connection_string, CELERY_RESULT_BACKEND=connection_string) CORS(app) app.storage = MongoDBStorageAdapter() celery = make_celery(app) # Make it possible to parse datetime app.json_encoder = BSONClassEncoder @app.route("/messages/all", methods=["GET"]) def all_messages() -> dict: """