Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def make_reservation(self):
"""Perform a reservation of the required number of nodes."""
logger.info('Performing reservation')
now = int(time.time() + timedelta_to_seconds(datetime.timedelta(minutes=1)))
starttime = now
endtime = int(starttime + timedelta_to_seconds(datetime.timedelta(days=3,
minutes=1)))
startdate, n_nodes = self._get_nodes(starttime, endtime)
search_time = 3 * 24 * 60 * 60 # 3 days
walltime_seconds = get_seconds(self.options.walltime)
iteration = 0
while not n_nodes:
iteration += 1
logger.info('Not enough nodes found between %s and %s, ' +
'increasing time window',
format_date(starttime), format_date(endtime))
starttime = max(now, now + iteration * search_time - walltime_seconds)
endtime = int(now + (iteration + 1) * search_time)
startdate, n_nodes = self._get_nodes(starttime, endtime)
if starttime > int(time.time() + timedelta_to_seconds(
datetime.timedelta(weeks=6))):
logger.error('There are not enough nodes on %s for your ' +
'experiments, abort ...', self.cluster)
exit()