From b79098731dff49b706c3d58c6d733f0e55adbfcd Mon Sep 17 00:00:00 2001 From: Johnathan Rodriguez Date: Wed, 12 Jul 2023 14:06:11 -0400 Subject: [PATCH 1/2] Simplified the logic for handling log variables --- fivetran_blueprints/check_sync_status.py | 25 ++++++++++++------------ 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/fivetran_blueprints/check_sync_status.py b/fivetran_blueprints/check_sync_status.py index f25fd9b..1d55c16 100644 --- a/fivetran_blueprints/check_sync_status.py +++ b/fivetran_blueprints/check_sync_status.py @@ -89,29 +89,30 @@ def determine_sync_status(connector_details_response, execution_time): return exit_code - def main(): args = get_args() api_key = args.api_key api_secret = args.api_secret auth_header = requests.auth._basic_auth_str(api_key, api_secret) headers = {'Authorization': auth_header} - execution_time = None base_folder_name = shipyard_utils.logs.determine_base_artifact_folder( 'fivetran') artifact_subfolder_paths = shipyard_utils.logs.determine_artifact_subfolders( base_folder_name) shipyard_utils.logs.create_artifacts_folders(artifact_subfolder_paths) - - - if args.connector_id and args.connector_id !='': - connector_id = args.connector_id - else: + + try: connector_id = shipyard_utils.logs.read_pickle_file( - artifact_subfolder_paths, 'connector_id') - execution_time= shipyard_utils.logs.read_pickle_file( - artifact_subfolder_paths, 'execution_time') + artifact_subfolder_paths, 'connector_id') + execution_time = shipyard_utils.logs.read_pickle_file( + artifact_subfolder_paths, 'execution_time') + except Exception as error: + print(f'Error reading upstream logs: {error}') + sys.exit(1) + if args.connector_id and args.connector_id != '' and connector_id != args.connector_id: + print(f'Connector ID {args.connector_id} does not match the connector ID {connector_id} stored in the logs.' + f'Continuing with the connector ID detected upstream {connector_id}') connector_details_response = get_connector_details( connector_id, @@ -120,7 +121,6 @@ def main(): file_name=f'connector_{connector_id}_response.json') if connector_details_response['code'] == 'Success': - sys.exit(determine_sync_status( connector_details_response, execution_time)) else: @@ -128,6 +128,5 @@ def main(): sys.exit(1) - if __name__ == '__main__': - main() \ No newline at end of file + main() From bdff8eec3c2ba32dd6dba2a389361617d0423946 Mon Sep 17 00:00:00 2001 From: Johnathan Rodriguez Date: Wed, 12 Jul 2023 15:02:43 -0400 Subject: [PATCH 2/2] Improve error message --- fivetran_blueprints/check_sync_status.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fivetran_blueprints/check_sync_status.py b/fivetran_blueprints/check_sync_status.py index 1d55c16..7bad11b 100644 --- a/fivetran_blueprints/check_sync_status.py +++ b/fivetran_blueprints/check_sync_status.py @@ -108,7 +108,9 @@ def main(): execution_time = shipyard_utils.logs.read_pickle_file( artifact_subfolder_paths, 'execution_time') except Exception as error: - print(f'Error reading upstream logs: {error}') + print(f"Oops! There's a problem reading the upstream logs." + f"Before running this blueprint, you be sure to use the Fivetran - Execute Sync blueprint first." + f"\n Error Details: {error}") sys.exit(1) if args.connector_id and args.connector_id != '' and connector_id != args.connector_id: print(f'Connector ID {args.connector_id} does not match the connector ID {connector_id} stored in the logs.'