Skip to content

Commit

Permalink
Merge pull request #9 from microsoft/feature/enhance_error_handling
Browse files Browse the repository at this point in the history
Improved error handling of argparser
  • Loading branch information
nonstoptimm authored Jan 19, 2022
2 parents e96b31d + 6cec1f5 commit 645458f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/glue.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
logging.getLogger().setLevel(logging.INFO)

if __name__ == '__main__':
logging.info('[INFO] - Starting GLUE - v0.2')
logging.info('[INFO] - Starting GLUE - v0.2.2')

# Case Management
if any([do_scoring, do_synthesize, do_transcribe, do_evaluate]):
Expand Down
10 changes: 7 additions & 3 deletions src/params.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
''' PARAMETER COLLECTOR '''
import configparser
import logging
import sys

def get_params(parser):
Expand Down Expand Up @@ -50,8 +51,10 @@ def get_config(fname_config='config.ini'):
sys.path.append('./')
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
config.read(fname_config)

# Read keys/values and assign it to variables
try:
config.read(fname_config)
output_folder = config['dir']['output_folder']
stt_key = config['stt']['key']
stt_endpoint = config['stt']['endpoint']
Expand All @@ -69,8 +72,9 @@ def get_config(fname_config='config.ini'):
luis_treshold = float(config['luis']['treshold'])
luis_treshold = 0 if luis_treshold == '' else luis_treshold
driver = config['driver']['path']
except Exception as e:
sys.exit(f'[EXCEPT] - Config file could not be loaded -> {e}.')
except KeyError as 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():
return None
Expand Down

0 comments on commit 645458f

Please sign in to comment.