@@ -1125,12 +1125,27 @@ def ensure_dataset_refresh_schedule(self, dataset_id, schedules: list):
11251125 try :
11261126 existing_schedules = self .get_dataset_refresh_schedules (dataset_id )
11271127 except CidError as exc :
1128- logger .debug (f'List refresh schedule throws: { exc } ' )
1129- logger .warning (
1130- f'Cannot read dataset schedules for dataset = { dataset_id } . { str (exc )} . Skipping schedule management.'
1131- ' Please make sure scheduled refresh is configured manually.'
1132- )
1133- return
1128+ # We cannot access schedules, but let's check if there are scheduled ingestions.
1129+ ingestions_exist = False
1130+ try :
1131+ ingestions_exist = list (
1132+ self .client .get_paginator ('list_ingestions' ).paginate (
1133+ DataSetId = dataset_id ,
1134+ AwsAccountId = self .account_id
1135+ ).search ("Ingestions[?RequestSource=='SCHEDULED']" )
1136+ )
1137+ except Exception :
1138+ logger .debug (f'List refresh schedule throws: { exc } ' )
1139+ logger .warning (
1140+ f'Cannot read dataset schedules for dataset = { dataset_id } . { str (exc )} . Skipping schedule management.'
1141+ ' Please make sure scheduled refresh is configured manually.'
1142+ )
1143+ return
1144+ if ingestions_exist :
1145+ logger .debug (f'We cannot read schedules but there are ingestions. Skipping creation of schedule.' )
1146+ return
1147+ logger .debug (f'We cannot read schedules but there no ingestions. Continue to creation of schedule.' )
1148+ existing_schedules = []
11341149
11351150 if schedules :
11361151 if exec_env ()['terminal' ] in ('lambda' ):
@@ -1198,6 +1213,8 @@ def ensure_dataset_refresh_schedule(self, dataset_id, schedules: list):
11981213 logger .error (f'Unable to create refresh schedule with id { schedule ["ScheduleId" ]} . Dataset { dataset_id } does not exist.' )
11991214 except self .client .exceptions .AccessDeniedException :
12001215 logger .error (f'Unable to create refresh schedule with id { schedule ["ScheduleId" ]} . Please add quicksight:CreateDataSet permission.' )
1216+ except self .client .exceptions .ResourceExistsException :
1217+ logger .info (f'Schedule with id { schedule ["ScheduleId" ]} exists. But can have other settings. You better check.' )
12011218 except Exception as exc :
12021219 logger .error (f'Unable to create refresh schedule with id { schedule ["ScheduleId" ]} for dataset "{ dataset_id } ": { str (exc )} ' )
12031220 else :
0 commit comments