Merge in RR/cv-analysis from RED-6273-multi-tenant-storage to master
Squashed commit of the following:
commit ed07dc26b0323bf1f0a5b336e4075c8cc3d20d29
Author: Julius Unverfehrt <julius.unverfehrt@iqser.com>
Date: Tue Mar 28 18:03:16 2023 +0200
update pyinfra version with removed falsy dependencies from pyinfra
commit 202ce84419465ddcbe3e263e58917cc92b2639a6
Author: Julius Unverfehrt <julius.unverfehrt@iqser.com>
Date: Tue Mar 28 17:27:44 2023 +0200
update pyinfra for bugfix
commit 87122ffb965c016383bfd49e2eaaa6ab3b5d7101
Author: Julius Unverfehrt <julius.unverfehrt@iqser.com>
Date: Tue Mar 28 15:50:29 2023 +0200
Update pyinfra for multi-tenancy support
Update serve script with PayloadProcessor from pyinfra
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
import logging
|
|
|
|
from cv_analysis.config import get_config
|
|
from cv_analysis.server.pipeline import get_analysis_pipeline
|
|
from pyinfra import config as pyinfra_config
|
|
from pyinfra.payload_processing import make_payload_processor
|
|
from pyinfra.queue.queue_manager import QueueManager
|
|
|
|
PYINFRA_CONFIG = pyinfra_config.get_config()
|
|
CV_CONFIG = get_config()
|
|
|
|
logger = logging.getLogger()
|
|
logger.setLevel(PYINFRA_CONFIG.logging_level_root)
|
|
|
|
|
|
def make_dispatched_data_analysis(config):
|
|
skip_pages_without_images = config.table_parsing_skip_pages_without_images
|
|
|
|
def inner(data: bytes, operation) -> list:
|
|
analyse = get_analysis_pipeline(operation, skip_pages_without_images)
|
|
return list(analyse(data))
|
|
|
|
return inner
|
|
|
|
|
|
def main():
|
|
logger.info("Application is starting")
|
|
|
|
process_data = make_dispatched_data_analysis(config=CV_CONFIG)
|
|
process_payload = make_payload_processor(process_data, config=PYINFRA_CONFIG)
|
|
|
|
queue_manager = QueueManager(PYINFRA_CONFIG)
|
|
queue_manager.start_consuming(process_payload)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|