Skip to content

Commit

Permalink
Merge pull request #4 from shipyardapp/bug-fix/fix-handling-of-execut…
Browse files Browse the repository at this point in the history
…ion-time

merged into main
  • Loading branch information
johnathan-rodriguez authored Jul 12, 2023
2 parents 9133bcf + bdff8ee commit 6f26dd4
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions fivetran_blueprints/check_sync_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,29 +89,32 @@ 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"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.'
f'Continuing with the connector ID detected upstream {connector_id}')

connector_details_response = get_connector_details(
connector_id,
Expand All @@ -120,14 +123,12 @@ 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:
print(connector_details_response['message'])
sys.exit(1)



if __name__ == '__main__':
main()
main()

0 comments on commit 6f26dd4

Please sign in to comment.