Skip to content
Snippets Groups Projects
Commit 13ac5e99 authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

TMSS-435: processed review comments. Use constant DEFAULT_INTER_OBSERVATION_GAP

parent eec8022b
No related branches found
No related tags found
1 merge request!252Resolve TMSS-190
......@@ -39,6 +39,9 @@ from threading import Thread, Event
from lofar.sas.tmss.services.scheduling.constraints import *
# LOFAR needs to have a gap in between observations to (re)initialize hardware.
DEFAULT_INTER_OBSERVATION_GAP = timedelta(seconds=60)
def get_schedulable_scheduling_units() -> [models.SchedulingUnitBlueprint]:
'''get a list of all schedulable scheduling_units'''
defined_independend_subtasks = models.Subtask.independent_subtasks().filter(state__value='defined')
......@@ -104,7 +107,7 @@ def schedule_next_scheduling_unit() -> models.SchedulingUnitBlueprint:
schedulable_units = get_schedulable_scheduling_units()
# estimate the lower_bound_start_time
lower_bound_start_time = get_min_earliest_possible_start_time(schedulable_units, datetime.utcnow() + timedelta(seconds=90))
lower_bound_start_time = get_min_earliest_possible_start_time(schedulable_units, datetime.utcnow() + DEFAULT_INTER_OBSERVATION_GAP)
# estimate the upper_bound_stop_time, which may give us a small timewindow before any next scheduled unit, or a default window of a day
try:
......@@ -189,8 +192,8 @@ def assign_start_stop_times_to_schedulable_scheduling_units(lower_bound_start_ti
logger.info("mid-term schedule: next scheduling unit id=%s '%s' start_time=%s", scheduling_unit.id, scheduling_unit.name, start_time)
update_subtasks_start_times_for_scheduling_unit(scheduling_unit, start_time)
# keep track of the previous
lower_bound_start_time = scheduling_unit.stop_time
# keep track of the lower_bound_start_time based on last sub.stoptime and gap
lower_bound_start_time = scheduling_unit.stop_time + DEFAULT_INTER_OBSERVATION_GAP
scheduling_units.remove(scheduling_unit)
else:
......@@ -251,7 +254,7 @@ class TMSSSchedulingUnitBlueprintDynamicSchedulingMessageHandler(TMSSEventMessag
try:
logger.info("Updating dynamic schedule....")
scheduled_unit = schedule_next_scheduling_unit()
assign_start_stop_times_to_schedulable_scheduling_units(lower_bound_start_time=scheduled_unit.stop_time if scheduled_unit else None)
assign_start_stop_times_to_schedulable_scheduling_units(lower_bound_start_time=scheduled_unit.stop_time+DEFAULT_INTER_OBSERVATION_GAP if scheduled_unit else None)
logger.info("Updating dynamic schedule.... finished")
except Exception as e:
logger.exception(str(e))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment