maybe dirty inter-com working

This commit is contained in:
Julius Unverfehrt 2022-02-17 09:31:36 +01:00
parent 2917fb940e
commit 9a32fc4e9d

View File

@ -18,15 +18,14 @@ from pyinfra.utils.file import dossier_id_and_file_id_to_compressed_storage_pdf_
def make_file_getter(storage): def make_file_getter(storage):
def get_file(payload): def get_file(payload, pdf_dir):
with tempfile.TemporaryDirectory() as pdf_compressed_dir: with tempfile.TemporaryDirectory() as pdf_compressed_dir:
with tempfile.TemporaryDirectory() as pdf_dir: dossier_id, file_id = itemgetter("dossierId", "fileId")(payload)
dossier_id, file_id = itemgetter("dossierId", "fileId")(payload) object_name = dossier_id_and_file_id_to_compressed_storage_pdf_object_name(dossier_id, file_id)
object_name = dossier_id_and_file_id_to_compressed_storage_pdf_object_name(dossier_id, file_id) downloaded_file_path = download(storage, object_name, pdf_compressed_dir)
downloaded_file_path = download(storage, object_name, pdf_compressed_dir) unzipped_file_path = unzip(downloaded_file_path, pdf_dir)
unzipped_file_path = unzip(downloaded_file_path, pdf_dir)
return unzipped_file_path return unzipped_file_path
return get_file return get_file
@ -48,8 +47,9 @@ def make_payload_processor(analysis_endpoint):
def process(payload: dict): def process(payload: dict):
logging.info(f"Processing {payload}...") logging.info(f"Processing {payload}...")
file_path = get_file(payload) with tempfile.TemporaryDirectory() as pdf_dir:
predictions = analyze_file(file_path) file_path = get_file(payload, pdf_dir)
predictions = analyze_file(file_path)
return predictions return predictions
return process return process