Merge pull request #9 from microsoft/feature/enhance_error_handling

Improved error handling of argparser
This commit is contained in:
Timm Walz 2022-01-19 15:35:14 +01:00 коммит произвёл GitHub
Родитель e96b31d834 6cec1f54a9
Коммит 645458fe32
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 8 добавлений и 4 удалений

Просмотреть файл

@ -40,7 +40,7 @@ pa.get_config()
logging.getLogger().setLevel(logging.INFO) logging.getLogger().setLevel(logging.INFO)
if __name__ == '__main__': if __name__ == '__main__':
logging.info('[INFO] - Starting GLUE - v0.2') logging.info('[INFO] - Starting GLUE - v0.2.2')
# Case Management # Case Management
if any([do_scoring, do_synthesize, do_transcribe, do_evaluate]): if any([do_scoring, do_synthesize, do_transcribe, do_evaluate]):

Просмотреть файл

@ -1,5 +1,6 @@
''' PARAMETER COLLECTOR ''' ''' PARAMETER COLLECTOR '''
import configparser import configparser
import logging
import sys import sys
def get_params(parser): def get_params(parser):
@ -50,8 +51,10 @@ def get_config(fname_config='config.ini'):
sys.path.append('./') sys.path.append('./')
config = configparser.ConfigParser() config = configparser.ConfigParser()
global output_folder, driver, luis_appid, luis_key, luis_region, luis_endpoint, luis_slot, luis_treshold, stt_key, stt_endpoint, stt_region, tts_key, tts_region, tts_resource_name, tts_language, tts_font global output_folder, driver, luis_appid, luis_key, luis_region, luis_endpoint, luis_slot, luis_treshold, stt_key, stt_endpoint, stt_region, tts_key, tts_region, tts_resource_name, tts_language, tts_font
config.read(fname_config)
# Read keys/values and assign it to variables
try: try:
config.read(fname_config)
output_folder = config['dir']['output_folder'] output_folder = config['dir']['output_folder']
stt_key = config['stt']['key'] stt_key = config['stt']['key']
stt_endpoint = config['stt']['endpoint'] stt_endpoint = config['stt']['endpoint']
@ -69,8 +72,9 @@ def get_config(fname_config='config.ini'):
luis_treshold = float(config['luis']['treshold']) luis_treshold = float(config['luis']['treshold'])
luis_treshold = 0 if luis_treshold == '' else luis_treshold luis_treshold = 0 if luis_treshold == '' else luis_treshold
driver = config['driver']['path'] driver = config['driver']['path']
except Exception as e: except KeyError as e:
sys.exit(f'[EXCEPT] - Config file could not be loaded -> {e}.') logging.error(f'[ERROR] - Exit with KeyError for {e}, please verify structure and existance of your config.ini file. You may use config.sample.ini as guidance.')
sys.exit()
def main(): def main():
return None return None