From 4ad1b371427ded9b4e71039ed73d1cd51a208db8 Mon Sep 17 00:00:00 2001 From: Benjamin Simon Date: Wed, 24 Jul 2024 18:05:51 +0200 Subject: [PATCH 01/10] skip test_transcribe_happy_path (flaky) --- tests/aws/services/transcribe/test_transcribe.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/aws/services/transcribe/test_transcribe.py b/tests/aws/services/transcribe/test_transcribe.py index 1ab7b1b16bf4f..892ec5e006cc2 100644 --- a/tests/aws/services/transcribe/test_transcribe.py +++ b/tests/aws/services/transcribe/test_transcribe.py @@ -49,6 +49,7 @@ def is_transcription_done(): "$..Error..Code", ] ) + @pytest.mark.skip(reason="flaky") def test_transcribe_happy_path(self, transcribe_create_job, snapshot, aws_client): file_path = os.path.join(BASEDIR, "../../files/en-gb.wav") job_name = transcribe_create_job(audio_file=file_path) From 4bcf04d31356454a7aa361ec8eeb2f8629c74711 Mon Sep 17 00:00:00 2001 From: Benjamin Simon Date: Thu, 25 Jul 2024 20:53:04 +0200 Subject: [PATCH 02/10] fix pre-installation of vosk and ffmpeg --- tests/aws/conftest.py | 10 ++++- .../services/transcribe/test_transcribe.py | 40 ++++++++++++++++++- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/tests/aws/conftest.py b/tests/aws/conftest.py index 7d9669340fc0d..d8a9ace182578 100644 --- a/tests/aws/conftest.py +++ b/tests/aws/conftest.py @@ -45,11 +45,19 @@ def pytest_runtestloop(session): ) test_init_functions.add(opensearch_install_async) - if any(opensearch_test in parent_name for opensearch_test in ["test_es", "firehose"]): + + if any(es_test in parent_name for es_test in ["elasticsearch", "firehose"]): from tests.aws.services.es.test_es import install_async as es_install_async test_init_functions.add(es_install_async) + if "transcribe" in parent_name: + from tests.aws.services.transcribe.test_transcribe import ( + install_async as transcribe_install_async, + ) + + test_init_functions.add(transcribe_install_async) + # add init functions for certain tests that download/install things for test_class in test_classes: # set flag that terraform will be used diff --git a/tests/aws/services/transcribe/test_transcribe.py b/tests/aws/services/transcribe/test_transcribe.py index 892ec5e006cc2..d41a6c0401073 100644 --- a/tests/aws/services/transcribe/test_transcribe.py +++ b/tests/aws/services/transcribe/test_transcribe.py @@ -1,5 +1,6 @@ import logging import os +import threading from urllib.parse import urlparse import pytest @@ -7,15 +8,45 @@ from localstack.aws.api.transcribe import BadRequestException, ConflictException, NotFoundException from localstack.aws.connect import ServiceLevelClientFactory +from localstack.packages.ffmpeg import ffmpeg_package +from localstack.services.transcribe.packages import vosk_package from localstack.testing.pytest import markers from localstack.utils.files import new_tmp_file from localstack.utils.strings import short_uid, to_str from localstack.utils.sync import poll_condition, retry +from localstack.utils.threads import start_worker_thread BASEDIR = os.path.abspath(os.path.dirname(__file__)) LOG = logging.getLogger(__name__) +# Lock and event to ensure that the installation is executed before the tests +INIT_LOCK = threading.Lock() +installed = threading.Event() + + +def install_async(): + """ + Installs the default opensearch version in a worker thread. Used by conftest.py to make + sure Vosk and ffmpeg are downloaded once the tests arrive here. + """ + if installed.is_set(): + return + + def run_install(*args): + with INIT_LOCK: + if installed.is_set(): + return + LOG.info("installing Vosk default version") + vosk_package.install() + LOG.info("done installing Vosk default version") + LOG.info("installing ffmpeg default version") + ffmpeg_package.install() + LOG.info("done ffmpeg default version") + installed.set() + + start_worker_thread(run_install) + @pytest.fixture(autouse=True) def transcribe_snapshot_transformer(snapshot): @@ -23,6 +54,14 @@ def transcribe_snapshot_transformer(snapshot): class TestTranscribe: + @pytest.fixture(scope="class", autouse=True) + def pre_install_vosk(self): + if not installed.is_set(): + install_async() + + assert installed.wait(timeout=3 * 60), "gave up waiting for Vosk to install" + yield + @staticmethod def _wait_transcription_job( transcribe_client: ServiceLevelClientFactory, transcribe_job_name: str @@ -49,7 +88,6 @@ def is_transcription_done(): "$..Error..Code", ] ) - @pytest.mark.skip(reason="flaky") def test_transcribe_happy_path(self, transcribe_create_job, snapshot, aws_client): file_path = os.path.join(BASEDIR, "../../files/en-gb.wav") job_name = transcribe_create_job(audio_file=file_path) From 6c626ddffcd5344ef1570f5d24704592d6b3ed0b Mon Sep 17 00:00:00 2001 From: Benjamin Simon Date: Thu, 25 Jul 2024 21:59:31 +0200 Subject: [PATCH 03/10] pre-download language models as well --- tests/aws/services/transcribe/test_transcribe.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/aws/services/transcribe/test_transcribe.py b/tests/aws/services/transcribe/test_transcribe.py index d41a6c0401073..b3d273f238522 100644 --- a/tests/aws/services/transcribe/test_transcribe.py +++ b/tests/aws/services/transcribe/test_transcribe.py @@ -10,6 +10,7 @@ from localstack.aws.connect import ServiceLevelClientFactory from localstack.packages.ffmpeg import ffmpeg_package from localstack.services.transcribe.packages import vosk_package +from localstack.services.transcribe.provider import TranscribeProvider from localstack.testing.pytest import markers from localstack.utils.files import new_tmp_file from localstack.utils.strings import short_uid, to_str @@ -24,6 +25,8 @@ INIT_LOCK = threading.Lock() installed = threading.Event() +PRE_DOWNLOAD_LANGUAGE_CODE_MODELS = ["en-GB"] + def install_async(): """ @@ -43,6 +46,10 @@ def run_install(*args): LOG.info("installing ffmpeg default version") ffmpeg_package.install() LOG.info("done ffmpeg default version") + for language_code in PRE_DOWNLOAD_LANGUAGE_CODE_MODELS: + LOG.info("installing Vosk models used in test") + TranscribeProvider.download_model(language_code) + LOG.info("done installing Vosk models used in test") installed.set() start_worker_thread(run_install) From d772ddd319333d4647e3b8d603aef37e559cbde5 Mon Sep 17 00:00:00 2001 From: Benjamin Simon Date: Fri, 26 Jul 2024 01:32:25 +0200 Subject: [PATCH 04/10] try: remove conftest modification --- .../localstack/services/transcribe/provider.py | 2 +- tests/aws/conftest.py | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/localstack-core/localstack/services/transcribe/provider.py b/localstack-core/localstack/services/transcribe/provider.py index b24f960d8e867..e26705386abb1 100644 --- a/localstack-core/localstack/services/transcribe/provider.py +++ b/localstack-core/localstack/services/transcribe/provider.py @@ -226,7 +226,7 @@ def download_model(name: str): model_path = LANGUAGE_MODEL_DIR / name with _DL_LOCK: - if (model_path).exists(): + if model_path.exists(): return else: model_path.mkdir(parents=True) diff --git a/tests/aws/conftest.py b/tests/aws/conftest.py index d8a9ace182578..3939b31f70476 100644 --- a/tests/aws/conftest.py +++ b/tests/aws/conftest.py @@ -46,18 +46,11 @@ def pytest_runtestloop(session): test_init_functions.add(opensearch_install_async) - if any(es_test in parent_name for es_test in ["elasticsearch", "firehose"]): + if any(opensearch_test in parent_name for opensearch_test in ["test_es", "firehose"]): from tests.aws.services.es.test_es import install_async as es_install_async test_init_functions.add(es_install_async) - if "transcribe" in parent_name: - from tests.aws.services.transcribe.test_transcribe import ( - install_async as transcribe_install_async, - ) - - test_init_functions.add(transcribe_install_async) - # add init functions for certain tests that download/install things for test_class in test_classes: # set flag that terraform will be used From 24992f17e352c0bce685799090b975523986b7d8 Mon Sep 17 00:00:00 2001 From: Benjamin Simon Date: Fri, 26 Jul 2024 01:46:25 +0200 Subject: [PATCH 05/10] better error, early out --- tests/aws/conftest.py | 1 - .../services/transcribe/test_transcribe.py | 41 ++++++++++++------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/tests/aws/conftest.py b/tests/aws/conftest.py index 3939b31f70476..7d9669340fc0d 100644 --- a/tests/aws/conftest.py +++ b/tests/aws/conftest.py @@ -45,7 +45,6 @@ def pytest_runtestloop(session): ) test_init_functions.add(opensearch_install_async) - if any(opensearch_test in parent_name for opensearch_test in ["test_es", "firehose"]): from tests.aws.services.es.test_es import install_async as es_install_async diff --git a/tests/aws/services/transcribe/test_transcribe.py b/tests/aws/services/transcribe/test_transcribe.py index b3d273f238522..a1d2bb21ffbd6 100644 --- a/tests/aws/services/transcribe/test_transcribe.py +++ b/tests/aws/services/transcribe/test_transcribe.py @@ -24,6 +24,7 @@ # Lock and event to ensure that the installation is executed before the tests INIT_LOCK = threading.Lock() installed = threading.Event() +installation_errored = threading.Event() PRE_DOWNLOAD_LANGUAGE_CODE_MODELS = ["en-GB"] @@ -40,19 +41,27 @@ def run_install(*args): with INIT_LOCK: if installed.is_set(): return - LOG.info("installing Vosk default version") - vosk_package.install() - LOG.info("done installing Vosk default version") - LOG.info("installing ffmpeg default version") - ffmpeg_package.install() - LOG.info("done ffmpeg default version") - for language_code in PRE_DOWNLOAD_LANGUAGE_CODE_MODELS: - LOG.info("installing Vosk models used in test") - TranscribeProvider.download_model(language_code) - LOG.info("done installing Vosk models used in test") - installed.set() - - start_worker_thread(run_install) + try: + LOG.info("installing Vosk default version") + vosk_package.install() + LOG.info("done installing Vosk default version") + LOG.info("installing ffmpeg default version") + ffmpeg_package.install() + LOG.info("done ffmpeg default version") + LOG.info( + "downloading Vosk models used in test: %s", PRE_DOWNLOAD_LANGUAGE_CODE_MODELS + ) + for language_code in PRE_DOWNLOAD_LANGUAGE_CODE_MODELS: + TranscribeProvider.download_model(language_code) + LOG.info("done downloading Vosk model '%s'", language_code) + LOG.info("done downloading all Vosk models used in test") + except Exception: + LOG.exception("Error during installation of Transcribe dependencies") + installation_errored.set() + finally: + installed.set() + + start_worker_thread(run_install, name="transcribe-install-async") @pytest.fixture(autouse=True) @@ -62,11 +71,13 @@ def transcribe_snapshot_transformer(snapshot): class TestTranscribe: @pytest.fixture(scope="class", autouse=True) - def pre_install_vosk(self): + def pre_install_dependencies(self): if not installed.is_set(): install_async() - assert installed.wait(timeout=3 * 60), "gave up waiting for Vosk to install" + assert installed.wait(timeout=3 * 60), "gave up waiting for Vosk/ffmpeg to install" + + assert not installation_errored.is_set(), "installation of transcribe dependencies failed" yield @staticmethod From 3209e35b236955c9d70f2b3f5809ee4e26b34a10 Mon Sep 17 00:00:00 2001 From: Benjamin Simon Date: Fri, 26 Jul 2024 01:57:59 +0200 Subject: [PATCH 06/10] fix model name mapping --- tests/aws/services/transcribe/test_transcribe.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/aws/services/transcribe/test_transcribe.py b/tests/aws/services/transcribe/test_transcribe.py index a1d2bb21ffbd6..ec7af90939531 100644 --- a/tests/aws/services/transcribe/test_transcribe.py +++ b/tests/aws/services/transcribe/test_transcribe.py @@ -10,7 +10,7 @@ from localstack.aws.connect import ServiceLevelClientFactory from localstack.packages.ffmpeg import ffmpeg_package from localstack.services.transcribe.packages import vosk_package -from localstack.services.transcribe.provider import TranscribeProvider +from localstack.services.transcribe.provider import LANGUAGE_MODELS, TranscribeProvider from localstack.testing.pytest import markers from localstack.utils.files import new_tmp_file from localstack.utils.strings import short_uid, to_str @@ -52,8 +52,13 @@ def run_install(*args): "downloading Vosk models used in test: %s", PRE_DOWNLOAD_LANGUAGE_CODE_MODELS ) for language_code in PRE_DOWNLOAD_LANGUAGE_CODE_MODELS: - TranscribeProvider.download_model(language_code) - LOG.info("done downloading Vosk model '%s'", language_code) + model_name = LANGUAGE_MODELS[language_code] + TranscribeProvider.download_model(model_name) + LOG.info( + "done downloading Vosk model '%s' for language code '%s'", + model_name, + language_code, + ) LOG.info("done downloading all Vosk models used in test") except Exception: LOG.exception("Error during installation of Transcribe dependencies") From 613d1f17402329925f5a4258df69fe5dfb66deb8 Mon Sep 17 00:00:00 2001 From: Benjamin Simon Date: Fri, 26 Jul 2024 02:14:31 +0200 Subject: [PATCH 07/10] augment timeout for download --- tests/aws/services/transcribe/test_transcribe.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/aws/services/transcribe/test_transcribe.py b/tests/aws/services/transcribe/test_transcribe.py index ec7af90939531..3850e403001fe 100644 --- a/tests/aws/services/transcribe/test_transcribe.py +++ b/tests/aws/services/transcribe/test_transcribe.py @@ -53,6 +53,7 @@ def run_install(*args): ) for language_code in PRE_DOWNLOAD_LANGUAGE_CODE_MODELS: model_name = LANGUAGE_MODELS[language_code] + # downloading the model takes quite a while sometimes TranscribeProvider.download_model(model_name) LOG.info( "done downloading Vosk model '%s' for language code '%s'", @@ -80,7 +81,7 @@ def pre_install_dependencies(self): if not installed.is_set(): install_async() - assert installed.wait(timeout=3 * 60), "gave up waiting for Vosk/ffmpeg to install" + assert installed.wait(timeout=5 * 60), "gave up waiting for Vosk/ffmpeg to install" assert not installation_errored.is_set(), "installation of transcribe dependencies failed" yield From e8a12def2f8ea165e2d8014e2e42aefe4e761bf0 Mon Sep 17 00:00:00 2001 From: Benjamin Simon Date: Fri, 26 Jul 2024 02:41:05 +0200 Subject: [PATCH 08/10] parallelize installation of vosk and ffmpeg --- .../services/transcribe/test_transcribe.py | 61 ++++++++++++++----- 1 file changed, 45 insertions(+), 16 deletions(-) diff --git a/tests/aws/services/transcribe/test_transcribe.py b/tests/aws/services/transcribe/test_transcribe.py index 3850e403001fe..b938f73fd7cfe 100644 --- a/tests/aws/services/transcribe/test_transcribe.py +++ b/tests/aws/services/transcribe/test_transcribe.py @@ -1,6 +1,7 @@ import logging import os import threading +import time from urllib.parse import urlparse import pytest @@ -22,32 +23,31 @@ LOG = logging.getLogger(__name__) # Lock and event to ensure that the installation is executed before the tests -INIT_LOCK = threading.Lock() -installed = threading.Event() +INIT_VOSK_LOCK = threading.Lock() +INIT_FFMPEG_LOCK = threading.Lock() +vosk_installed = threading.Event() +ffmpeg_installed = threading.Event() installation_errored = threading.Event() +INSTALLATION_TIMEOUT = 4 * 60 PRE_DOWNLOAD_LANGUAGE_CODE_MODELS = ["en-GB"] def install_async(): """ - Installs the default opensearch version in a worker thread. Used by conftest.py to make - sure Vosk and ffmpeg are downloaded once the tests arrive here. + Installs the default ffmpeg and vosk versions in a worker thread. """ - if installed.is_set(): + if vosk_installed.is_set() and ffmpeg_installed.is_set(): return - def run_install(*args): - with INIT_LOCK: - if installed.is_set(): + def install_vosk(*args): + with INIT_VOSK_LOCK: + if vosk_installed.is_set(): return try: LOG.info("installing Vosk default version") vosk_package.install() LOG.info("done installing Vosk default version") - LOG.info("installing ffmpeg default version") - ffmpeg_package.install() - LOG.info("done ffmpeg default version") LOG.info( "downloading Vosk models used in test: %s", PRE_DOWNLOAD_LANGUAGE_CODE_MODELS ) @@ -62,12 +62,33 @@ def run_install(*args): ) LOG.info("done downloading all Vosk models used in test") except Exception: - LOG.exception("Error during installation of Transcribe dependencies") + LOG.exception("Error during installation of Vosk dependencies") + installation_errored.set() + # we also set the other event to quickly stop the polling + ffmpeg_installed.set() + finally: + vosk_installed.set() + + def install_ffmpeg(*args): + with INIT_FFMPEG_LOCK: + if ffmpeg_installed.is_set(): + return + try: + LOG.info("installing ffmpeg default version") + ffmpeg_package.install() + LOG.info("done ffmpeg default version") + except Exception: + LOG.exception("Error during installation of Vosk dependencies") installation_errored.set() + # we also set the other event to quickly stop the polling + vosk_installed.set() finally: - installed.set() + ffmpeg_installed.set() - start_worker_thread(run_install, name="transcribe-install-async") + # we parallelize the installation of the dependencies + # TODO: we could maybe use a ThreadPoolExecutor to use Future instead of manually checking + start_worker_thread(install_vosk, name="vosk-install-async") + start_worker_thread(install_ffmpeg, name="ffmpeg-install-async") @pytest.fixture(autouse=True) @@ -78,10 +99,18 @@ def transcribe_snapshot_transformer(snapshot): class TestTranscribe: @pytest.fixture(scope="class", autouse=True) def pre_install_dependencies(self): - if not installed.is_set(): + if not ffmpeg_installed.is_set() or vosk_installed.is_set(): install_async() - assert installed.wait(timeout=5 * 60), "gave up waiting for Vosk/ffmpeg to install" + start = int(time.time()) + assert vosk_installed.wait( + timeout=INSTALLATION_TIMEOUT + ), "gave up waiting for Vosk to install" + elapsed = int(time.time() - start) + assert ffmpeg_installed.wait( + timeout=INSTALLATION_TIMEOUT - elapsed + ), "gave up waiting for ffmpeg to install" + LOG.info("Spent %s seconds downloading transcribe dependencies", int(time.time() - start)) assert not installation_errored.is_set(), "installation of transcribe dependencies failed" yield From 39417c07f2ede7715d1830576a7ca50b0ea4cb16 Mon Sep 17 00:00:00 2001 From: Benjamin Simon Date: Fri, 26 Jul 2024 10:44:35 +0200 Subject: [PATCH 09/10] re-instate conftest pre-install & add timeout --- tests/aws/conftest.py | 10 +++++++++- tests/aws/services/transcribe/test_transcribe.py | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/aws/conftest.py b/tests/aws/conftest.py index 7d9669340fc0d..d8a9ace182578 100644 --- a/tests/aws/conftest.py +++ b/tests/aws/conftest.py @@ -45,11 +45,19 @@ def pytest_runtestloop(session): ) test_init_functions.add(opensearch_install_async) - if any(opensearch_test in parent_name for opensearch_test in ["test_es", "firehose"]): + + if any(es_test in parent_name for es_test in ["elasticsearch", "firehose"]): from tests.aws.services.es.test_es import install_async as es_install_async test_init_functions.add(es_install_async) + if "transcribe" in parent_name: + from tests.aws.services.transcribe.test_transcribe import ( + install_async as transcribe_install_async, + ) + + test_init_functions.add(transcribe_install_async) + # add init functions for certain tests that download/install things for test_class in test_classes: # set flag that terraform will be used diff --git a/tests/aws/services/transcribe/test_transcribe.py b/tests/aws/services/transcribe/test_transcribe.py index b938f73fd7cfe..4fab449182618 100644 --- a/tests/aws/services/transcribe/test_transcribe.py +++ b/tests/aws/services/transcribe/test_transcribe.py @@ -29,7 +29,7 @@ ffmpeg_installed = threading.Event() installation_errored = threading.Event() -INSTALLATION_TIMEOUT = 4 * 60 +INSTALLATION_TIMEOUT = 5 * 60 PRE_DOWNLOAD_LANGUAGE_CODE_MODELS = ["en-GB"] @@ -99,7 +99,7 @@ def transcribe_snapshot_transformer(snapshot): class TestTranscribe: @pytest.fixture(scope="class", autouse=True) def pre_install_dependencies(self): - if not ffmpeg_installed.is_set() or vosk_installed.is_set(): + if not ffmpeg_installed.is_set() or not vosk_installed.is_set(): install_async() start = int(time.time()) From 7a7857a0a452e05e5186a7ebc8fd5fe746f64c6e Mon Sep 17 00:00:00 2001 From: Benjamin Simon Date: Fri, 26 Jul 2024 13:36:22 +0200 Subject: [PATCH 10/10] remove locks --- .../services/transcribe/test_transcribe.py | 76 +++++++++---------- 1 file changed, 35 insertions(+), 41 deletions(-) diff --git a/tests/aws/services/transcribe/test_transcribe.py b/tests/aws/services/transcribe/test_transcribe.py index 4fab449182618..9ba22484369f7 100644 --- a/tests/aws/services/transcribe/test_transcribe.py +++ b/tests/aws/services/transcribe/test_transcribe.py @@ -23,8 +23,6 @@ LOG = logging.getLogger(__name__) # Lock and event to ensure that the installation is executed before the tests -INIT_VOSK_LOCK = threading.Lock() -INIT_FFMPEG_LOCK = threading.Lock() vosk_installed = threading.Event() ffmpeg_installed = threading.Event() installation_errored = threading.Event() @@ -41,49 +39,45 @@ def install_async(): return def install_vosk(*args): - with INIT_VOSK_LOCK: - if vosk_installed.is_set(): - return - try: - LOG.info("installing Vosk default version") - vosk_package.install() - LOG.info("done installing Vosk default version") + if vosk_installed.is_set(): + return + try: + LOG.info("installing Vosk default version") + vosk_package.install() + LOG.info("done installing Vosk default version") + LOG.info("downloading Vosk models used in test: %s", PRE_DOWNLOAD_LANGUAGE_CODE_MODELS) + for language_code in PRE_DOWNLOAD_LANGUAGE_CODE_MODELS: + model_name = LANGUAGE_MODELS[language_code] + # downloading the model takes quite a while sometimes + TranscribeProvider.download_model(model_name) LOG.info( - "downloading Vosk models used in test: %s", PRE_DOWNLOAD_LANGUAGE_CODE_MODELS + "done downloading Vosk model '%s' for language code '%s'", + model_name, + language_code, ) - for language_code in PRE_DOWNLOAD_LANGUAGE_CODE_MODELS: - model_name = LANGUAGE_MODELS[language_code] - # downloading the model takes quite a while sometimes - TranscribeProvider.download_model(model_name) - LOG.info( - "done downloading Vosk model '%s' for language code '%s'", - model_name, - language_code, - ) - LOG.info("done downloading all Vosk models used in test") - except Exception: - LOG.exception("Error during installation of Vosk dependencies") - installation_errored.set() - # we also set the other event to quickly stop the polling - ffmpeg_installed.set() - finally: - vosk_installed.set() + LOG.info("done downloading all Vosk models used in test") + except Exception: + LOG.exception("Error during installation of Vosk dependencies") + installation_errored.set() + # we also set the other event to quickly stop the polling + ffmpeg_installed.set() + finally: + vosk_installed.set() def install_ffmpeg(*args): - with INIT_FFMPEG_LOCK: - if ffmpeg_installed.is_set(): - return - try: - LOG.info("installing ffmpeg default version") - ffmpeg_package.install() - LOG.info("done ffmpeg default version") - except Exception: - LOG.exception("Error during installation of Vosk dependencies") - installation_errored.set() - # we also set the other event to quickly stop the polling - vosk_installed.set() - finally: - ffmpeg_installed.set() + if ffmpeg_installed.is_set(): + return + try: + LOG.info("installing ffmpeg default version") + ffmpeg_package.install() + LOG.info("done ffmpeg default version") + except Exception: + LOG.exception("Error during installation of Vosk dependencies") + installation_errored.set() + # we also set the other event to quickly stop the polling + vosk_installed.set() + finally: + ffmpeg_installed.set() # we parallelize the installation of the dependencies # TODO: we could maybe use a ThreadPoolExecutor to use Future instead of manually checking