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

TMSS-190: prepare some nice scheduling units for projects with different priorities

parent 8c5cdc69
Branches
Tags
1 merge request!252Resolve TMSS-190
...@@ -62,33 +62,34 @@ def populate_test_data(): ...@@ -62,33 +62,34 @@ def populate_test_data():
strategy_template = models.SchedulingUnitObservingStrategyTemplate.objects.get(name="UC1 CTC+pipelines") strategy_template = models.SchedulingUnitObservingStrategyTemplate.objects.get(name="UC1 CTC+pipelines")
tmss_projects = models.Project.objects.filter(name__startswith="TMSS-Commissioning").order_by('priority_rank').all() tmss_projects = models.Project.objects.filter(name__startswith="TMSS-").order_by('priority_rank').all()
for project_nr, tmss_project in enumerate(tmss_projects): for project_nr, tmss_project in enumerate(tmss_projects):
for set_nr in range(1): project_prio_string = tmss_project.name.replace("TMSS-", "")
# create a Test Scheduling Set UC1 under project TMSS-Commissioning
project_prio_name = tmss_project.name.replace("TMSS-Commissioning ", "") for set_nr in range(2):
scheduling_set_data = SchedulingSet_test_data(name="Test Scheduling Set UC1 example %s (%s)" % (set_nr, project_prio_name), project=tmss_project) scheduling_set_data = SchedulingSet_test_data(name="Scheduling Set UC1 example %s (%s)" % (set_nr, project_prio_string), project=tmss_project)
scheduling_set = models.SchedulingSet.objects.create(**scheduling_set_data) scheduling_set = models.SchedulingSet.objects.create(**scheduling_set_data)
scheduling_set.tags = ["TEST", "UC1"]
scheduling_set.save()
logger.info('created test scheduling_set: %s', scheduling_set.name) logger.info('created test scheduling_set: %s', scheduling_set.name)
for unit_nr in range(3 if 'normal' in project_prio_name else 2): for unit_nr in range(2):
# the 'template' in the strategy_template is a predefined json-data blob which validates against the given scheduling_unit_template # the 'template' in the strategy_template is a predefined json-data blob which validates against the given scheduling_unit_template
# a user might 'upload' a partial json-data blob, so add all the known defaults # a user might 'upload' a partial json-data blob, so add all the known defaults
scheduling_unit_spec = add_defaults_to_json_object_for_schema(strategy_template.template, strategy_template.scheduling_unit_template.schema) scheduling_unit_spec = add_defaults_to_json_object_for_schema(strategy_template.template, strategy_template.scheduling_unit_template.schema)
# TODO: TMSS-244 apply and implement daily constraints
# constraints_spec['daily']['require_day'] = unit_nr%2==0
# constraints_spec['daily']['require_night'] = unit_nr%2==1
# add the scheduling_unit_doc to a new SchedulingUnitDraft instance, and were ready to use it! # add the scheduling_unit_doc to a new SchedulingUnitDraft instance, and were ready to use it!
scheduling_unit_draft = models.SchedulingUnitDraft.objects.create(name="UC1 p_%s.%s.%s" % (project_prio_name, set_nr+1, unit_nr+1), scheduling_unit_draft = models.SchedulingUnitDraft.objects.create(name="UC1 %s.%s.%s" % ('day' if constraints_spec['daily']['require_day'] else 'night' if constraints_spec['daily']['require_night'] else 'anytime',
set_nr+1, unit_nr+1),
scheduling_set=scheduling_set, scheduling_set=scheduling_set,
requirements_template=strategy_template.scheduling_unit_template, requirements_template=strategy_template.scheduling_unit_template,
requirements_doc=scheduling_unit_spec, requirements_doc=scheduling_unit_spec,
observation_strategy_template=strategy_template, observation_strategy_template=strategy_template,
scheduling_constraints_doc=constraints_spec, scheduling_constraints_doc=constraints_spec,
scheduling_constraints_template=constraints_template) scheduling_constraints_template=constraints_template)
scheduling_unit_draft.tags = ["TEST", "UC1"]
scheduling_unit_draft.save()
logger.info('created test scheduling_unit_draft: %s', scheduling_unit_draft.name) logger.info('created test scheduling_unit_draft: %s', scheduling_unit_draft.name)
...@@ -130,8 +131,8 @@ def populate_cycles(apps, schema_editor): ...@@ -130,8 +131,8 @@ def populate_cycles(apps, schema_editor):
def populate_projects(apps, schema_editor): def populate_projects(apps, schema_editor):
for suffix, rank in (("high priority", 3), ("normal priority", 2), ("low priority", 1)): for suffix, rank in (("high", 3), ("normal", 2), ("low", 1)):
tmss_project = models.Project.objects.create(name="TMSS-Commissioning " + suffix, tmss_project = models.Project.objects.create(name="TMSS-" + suffix,
description="Project for all TMSS tests and commissioning (%s)" % (suffix,), description="Project for all TMSS tests and commissioning (%s)" % (suffix,),
priority_rank=rank, priority_rank=rank,
can_trigger=False, can_trigger=False,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment