From cac19b12abf8dccfd1b1f3c01b4b019cfdf76af3 Mon Sep 17 00:00:00 2001 From: Vishnu Jyothi Date: Tue, 25 Jun 2024 09:56:19 +0200 Subject: [PATCH 1/4] proper message while creating directory --- io_util.py | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/io_util.py b/io_util.py index 90cacd3..4cc37f2 100644 --- a/io_util.py +++ b/io_util.py @@ -39,19 +39,24 @@ def validate_data_dirs() -> bool: # TODO: perhaps add model dir return False # make sure the input and output dirs are there - try: - os.makedirs(i_dir, 0o755) - logger.info("created input dir: {}".format(i_dir)) - except FileExistsError as e: - logger.info(e) + input_dir_created = create_directory(i_dir) + output_dir_created = create_directory(o_dir) - try: - os.makedirs(o_dir, 0o755) - logger.info("created output dir: {}".format(o_dir)) - except FileExistsError as e: - logger.info(e) + return input_dir_created and output_dir_created + - return True +def create_directory(path: Path) -> bool: + """Create a directory if it doesn't exist.""" + if path.exists(): + logger.info(f"Directory already exists: {path}") + return True + try: + os.makedirs(path, mode=0o755) + logger.info(f"Created directory: {path}") + return True + except Exception as e: + logger.error(f"Failed to create directory {path}: {e}") + return False # for each OutputType a subdir is created inside the base output dir @@ -358,3 +363,5 @@ def check_pretrained_model_availability() -> bool: return True logger.error(f"'{cfg.WHISPER_ASR_SETTINGS.MODEL}' is not a valid pretrained model!") return False + + From 2958794c62ab98afdf55d0d15ef8a3ddf8a62331 Mon Sep 17 00:00:00 2001 From: Vishnu Jyothi Date: Tue, 25 Jun 2024 09:59:53 +0200 Subject: [PATCH 2/4] correction in device checking --- whisper.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/whisper.py b/whisper.py index 2997b64..bff3b29 100644 --- a/whisper.py +++ b/whisper.py @@ -40,10 +40,7 @@ def run_whisper( "Failed to apply model (WHISPER_ASR_SETTINGS.MODEL not configured correctly)", ) - if ( - cfg.WHISPER_ASR_SETTINGS.DEVICE != "cuda" - or cfg.WHISPER_ASR_SETTINGS.DEVICE != "cpu" - ): + if cfg.WHISPER_ASR_SETTINGS.DEVICE not in ["cuda", "cpu"]: return WhisperASROutput( 500, "Failed to apply model (WHISPER_ASR_SETTINGS.DEVICE not configured correctly)", From 85c9129f63d38ae3f3e97be65d307e728ad8399e Mon Sep 17 00:00:00 2001 From: Vishnu Jyothi Date: Tue, 25 Jun 2024 10:06:30 +0200 Subject: [PATCH 3/4] remove spaces --- io_util.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/io_util.py b/io_util.py index 4cc37f2..e881e81 100644 --- a/io_util.py +++ b/io_util.py @@ -363,5 +363,3 @@ def check_pretrained_model_availability() -> bool: return True logger.error(f"'{cfg.WHISPER_ASR_SETTINGS.MODEL}' is not a valid pretrained model!") return False - - From e9ab6a44e530924941a88192ddef34ab549a5172 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Drago=C8=99?= Date: Fri, 12 Jul 2024 16:17:45 +0200 Subject: [PATCH 4/4] Fix flake8 pipeline fail --- io_util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/io_util.py b/io_util.py index e881e81..d33d88a 100644 --- a/io_util.py +++ b/io_util.py @@ -43,7 +43,7 @@ def validate_data_dirs() -> bool: # TODO: perhaps add model dir output_dir_created = create_directory(o_dir) return input_dir_created and output_dir_created - + def create_directory(path: Path) -> bool: """Create a directory if it doesn't exist."""