From eb2686b027395d1ed6c5e1eef96c511eaf4e9953 Mon Sep 17 00:00:00 2001 From: Matthias Bisping Date: Thu, 17 Feb 2022 16:44:17 +0100 Subject: [PATCH] resolved mutually import --- pyinfra/core.py | 6 +----- src/serve.py | 7 +++++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/pyinfra/core.py b/pyinfra/core.py index d356630..4056af8 100644 --- a/pyinfra/core.py +++ b/pyinfra/core.py @@ -7,7 +7,6 @@ import requests from pyinfra.callback import json_wrap from pyinfra.exceptions import DataLoadingFailure, AnalysisFailure, ProcessingFailure from pyinfra.utils.file import dossier_id_and_file_id_to_compressed_storage_pdf_object_name -from src.serve import get_storage def make_storage_data_loader(storage): @@ -50,10 +49,7 @@ def make_analyzer(analysis_endpoint): return analyze -def make_payload_processor(analysis_endpoint): - - load_data = make_storage_data_loader(get_storage()) - analyze_file = make_analyzer(analysis_endpoint) +def make_payload_processor(load_data, analyze_file): @json_wrap def process(payload: dict): diff --git a/src/serve.py b/src/serve.py index 0c3dffb..5c3d3c1 100644 --- a/src/serve.py +++ b/src/serve.py @@ -12,7 +12,7 @@ from pyinfra.callback import ( ) from pyinfra.config import CONFIG from pyinfra.consume import consume, ConsumerError -from pyinfra.core import make_payload_processor +from pyinfra.core import make_payload_processor, make_storage_data_loader, make_analyzer from pyinfra.exceptions import UnknownStorageBackend from pyinfra.storage.azure_blob_storage import AzureBlobStorageHandle from pyinfra.storage.minio import MinioHandle @@ -65,7 +65,10 @@ def republish(channel, body, n_current_attempts): def make_callback(): - json_wrapped_body_processor = make_payload_processor(CONFIG.service.analysis_endpoint) + load_data = make_storage_data_loader(get_storage()) + analyze_file = make_analyzer(CONFIG.service.analysis_endpoint) + + json_wrapped_body_processor = make_payload_processor(load_data, analyze_file) if CONFIG.rabbitmq.retry.enabled: retry_callback = make_retry_callback(republish, max_attempts=CONFIG.rabbitmq.retry.max_attempts)