diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/populate.py b/SAS/TMSS/backend/src/tmss/tmssapp/populate.py index d9352294552550890cf404aaf40074803f83c6fb..7d875948fa4ec0ae81dfbd3c7c1e975d4a9a7b64 100644 --- a/SAS/TMSS/backend/src/tmss/tmssapp/populate.py +++ b/SAS/TMSS/backend/src/tmss/tmssapp/populate.py @@ -133,36 +133,158 @@ def populate_test_data(): def populate_cycles(apps, schema_editor): - for nr in range(0, 18): + # Cycle 0 deviates from any patterns + cycle = models.Cycle.objects.create(name="Cycle 00", + description="Lofar Cycle 0", + start=datetime(2013, 2, 11, 0, 0, 0, 0, tzinfo=timezone.utc), + stop=datetime(2013, 11, 14, 0, 0, 0, 0, tzinfo=timezone.utc)) + + models.CycleQuota.objects.bulk_create([models.CycleQuota(cycle=cycle, + resource_type=ResourceType.objects.get( + name="LOFAR Observing Time"), + value=0.8 * cycle.duration.total_seconds()), + # rough guess. 80% of total time available for observing + models.CycleQuota(cycle=cycle, + resource_type=ResourceType.objects.get( + name="CEP Processing Time"), + value=0.8 * cycle.duration.total_seconds()), + models.CycleQuota(cycle=cycle, + resource_type=ResourceType.objects.get(name="LTA Storage"), + value=0), # needs to be filled in by user (SOS) + models.CycleQuota(cycle=cycle, + resource_type=ResourceType.objects.get( + name="LOFAR Support Time"), + value=0), # needs to be filled in by user (SOS) + + models.CycleQuota(cycle=cycle, + resource_type=ResourceType.objects.get( + name="LOFAR Observing Time Commissioning"), + value=0.05 * cycle.duration.total_seconds()), + # rough guess. 5% of total time available for observing + models.CycleQuota(cycle=cycle, + resource_type=ResourceType.objects.get( + name="LOFAR Observing Time prio A"), + value=0), # needs to be filled in by user (SOS) + models.CycleQuota(cycle=cycle, + resource_type=ResourceType.objects.get( + name="LOFAR Observing Time prio B"), + value=0) # needs to be filled in by user (SOS) + ]) + + # Cycles 1-10 follow the same pattern + for nr in range(1, 11): cycle = models.Cycle.objects.create(name="Cycle %02d" % nr, description="Lofar Cycle %s" % nr, - start=datetime(2013+nr//2, 6 if nr%2==0 else 11, 1, 0, 0, 0, 0, tzinfo=timezone.utc), - stop=datetime(2013+(nr+1)//2, 6 if nr%2==1 else 11, 1, 0, 0, 0, 0, tzinfo=timezone.utc)) + start=datetime(2013+nr//2, 5 if nr%2==0 else 11, 15, 0, 0, 0, 0, tzinfo=timezone.utc), + stop=datetime(2013+(nr+1)//2, 5 if nr%2==1 else 11, 14, 0, 0, 0, 0, tzinfo=timezone.utc)) models.CycleQuota.objects.bulk_create([models.CycleQuota(cycle=cycle, - resource_type=ResourceType.objects.get(name="observing_time"), + resource_type=ResourceType.objects.get(name="LOFAR Observing Time"), value=0.8*cycle.duration.total_seconds()), # rough guess. 80% of total time available for observing models.CycleQuota(cycle=cycle, - resource_type=ResourceType.objects.get(name="cep_processing_time"), + resource_type=ResourceType.objects.get(name="CEP Processing Time"), value=0.8*cycle.duration.total_seconds()), models.CycleQuota(cycle=cycle, - resource_type=ResourceType.objects.get(name="lta_storage"), + resource_type=ResourceType.objects.get(name="LTA Storage"), value=0), # needs to be filled in by user (SOS) models.CycleQuota(cycle=cycle, - resource_type=ResourceType.objects.get(name="support_time"), + resource_type=ResourceType.objects.get(name="LOFAR Support Time"), value=0), # needs to be filled in by user (SOS) models.CycleQuota(cycle=cycle, - resource_type=ResourceType.objects.get(name="observing_time_commissioning"), + resource_type=ResourceType.objects.get(name="LOFAR Observing Time Commissioning"), value=0.05*cycle.duration.total_seconds()), # rough guess. 5% of total time available for observing models.CycleQuota(cycle=cycle, - resource_type=ResourceType.objects.get(name="observing_time_prio_a"), + resource_type=ResourceType.objects.get(name="LOFAR Observing Time prio A"), value=0), # needs to be filled in by user (SOS) models.CycleQuota(cycle=cycle, - resource_type=ResourceType.objects.get(name="observing_time_prio_b"), + resource_type=ResourceType.objects.get(name="LOFAR Observing Time prio B"), value=0) # needs to be filled in by user (SOS) ]) + # Cycle 11 deviates from any patterns + cycle = models.Cycle.objects.create(name="Cycle 11", + description="Lofar Cycle 11", + start=datetime(2018, 11, 15, 0, 0, 0, 0, tzinfo=timezone.utc), + stop=datetime(2019, 5, 31, 0, 0, 0, 0, tzinfo=timezone.utc)) + + models.CycleQuota.objects.bulk_create([models.CycleQuota(cycle=cycle, + resource_type=ResourceType.objects.get( + name="LOFAR Observing Time"), + value=0.8 * cycle.duration.total_seconds()), + # rough guess. 80% of total time available for observing + models.CycleQuota(cycle=cycle, + resource_type=ResourceType.objects.get( + name="CEP Processing Time"), + value=0.8 * cycle.duration.total_seconds()), + models.CycleQuota(cycle=cycle, + resource_type=ResourceType.objects.get( + name="LTA Storage"), + value=0), # needs to be filled in by user (SOS) + models.CycleQuota(cycle=cycle, + resource_type=ResourceType.objects.get( + name="LOFAR Support Time"), + value=0), # needs to be filled in by user (SOS) + + models.CycleQuota(cycle=cycle, + resource_type=ResourceType.objects.get( + name="LOFAR Observing Time Commissioning"), + value=0.05 * cycle.duration.total_seconds()), + # rough guess. 5% of total time available for observing + models.CycleQuota(cycle=cycle, + resource_type=ResourceType.objects.get( + name="LOFAR Observing Time prio A"), + value=0), # needs to be filled in by user (SOS) + models.CycleQuota(cycle=cycle, + resource_type=ResourceType.objects.get( + name="LOFAR Observing Time prio B"), + value=0) # needs to be filled in by user (SOS) + ]) + + # Cycles 12-19 follow the same pattern + for nr in range(12, 20): + cycle = models.Cycle.objects.create(name="Cycle %02d" % nr, + description="Lofar Cycle %s" % nr, + start=datetime(2013 + nr // 2, 6 if nr % 2 == 0 else 12, 1, 0, 0, 0, 0, + tzinfo=timezone.utc), + stop=datetime(2013 + (nr + 1) // 2, 5 if nr % 2 == 1 else 11, + 30 if nr % 2 == 0 else 31, 0, 0, + 0, 0, tzinfo=timezone.utc)) + + models.CycleQuota.objects.bulk_create([models.CycleQuota(cycle=cycle, + resource_type=ResourceType.objects.get( + name="LOFAR Observing Time"), + value=0.8 * cycle.duration.total_seconds()), + # rough guess. 80% of total time available for observing + models.CycleQuota(cycle=cycle, + resource_type=ResourceType.objects.get( + name="CEP Processing Time"), + value=0.8 * cycle.duration.total_seconds()), + models.CycleQuota(cycle=cycle, + resource_type=ResourceType.objects.get( + name="LTA Storage"), + value=0), # needs to be filled in by user (SOS) + models.CycleQuota(cycle=cycle, + resource_type=ResourceType.objects.get( + name="LOFAR Support Time"), + value=0), # needs to be filled in by user (SOS) + + models.CycleQuota(cycle=cycle, + resource_type=ResourceType.objects.get( + name="LOFAR Observing Time Commissioning"), + value=0.05 * cycle.duration.total_seconds()), + # rough guess. 5% of total time available for observing + models.CycleQuota(cycle=cycle, + resource_type=ResourceType.objects.get( + name="LOFAR Observing Time prio A"), + value=0), # needs to be filled in by user (SOS) + models.CycleQuota(cycle=cycle, + resource_type=ResourceType.objects.get( + name="LOFAR Observing Time prio B"), + value=0) # needs to be filled in by user (SOS) + ]) + + def populate_projects(apps, schema_editor): from lofar.sas.tmss.test.tmss_test_data_django_models import SchedulingSet_test_data @@ -181,7 +303,7 @@ def populate_projects(apps, schema_editor): # for convenience, create a schedulingset for each project models.SchedulingSet.objects.create(**SchedulingSet_test_data(name="Test Scheduling Set", project=tmss_project)) - project_quota = ProjectQuota.objects.create(project=tmss_project, value=1e12, resource_type=ResourceType.objects.get(name="lta_storage")) + project_quota = ProjectQuota.objects.create(project=tmss_project, value=1e12, resource_type=ResourceType.objects.get(name="LTA Storage")) sara_fs = Filesystem.objects.get(name="Lofar Storage (SARA)") models.ProjectQuotaArchiveLocation.objects.create(project_quota=project_quota, archive_location=sara_fs) @@ -191,18 +313,7 @@ def populate_resources(apps, schema_editor): time_q = Quantity.objects.get(value=Quantity.Choices.TIME.value) number_q = Quantity.objects.get(value=Quantity.Choices.NUMBER.value) - ResourceType.objects.bulk_create([ResourceType(name="lta_storage", description="Amount of storage in the LTA (in bytes)", quantity=bytes_q), - ResourceType(name="cep_storage", description="Amount of storage on the CEP processing cluster (in bytes)", quantity=bytes_q), - ResourceType(name="cep_processing_time", description="Processing time on the CEP processing cluster (in seconds)", quantity=time_q), - ResourceType(name="observing_time", description="Observing time (in seconds)", quantity=time_q), - ResourceType(name="observing_time_prio_a", description="Observing time with priority A (in seconds)", quantity=time_q), - ResourceType(name="observing_time_prio_b", description="Observing time with priority B (in seconds)", quantity=time_q), - ResourceType(name="observing_time_commissioning", description="Observing time for Commissioning/DDT (in seconds)", quantity=time_q), - ResourceType(name="support_time", description="Support time by human (in seconds)", quantity=time_q), - ResourceType(name="number_of_triggers", description="Number of trigger events (as integer)", quantity=number_q), - # TODO these duplicates have names that front-end expects. - # TODO We should not have doubles. - ResourceType(name="LTA Storage", description="Amount of storage in the LTA (in bytes)", quantity=bytes_q), + ResourceType.objects.bulk_create([ResourceType(name="LTA Storage", description="Amount of storage in the LTA (in bytes)", quantity=bytes_q), ResourceType(name="CEP Storage", description="Amount of storage on the CEP processing cluster (in bytes)", quantity=bytes_q), ResourceType(name="CEP Processing Time", description="Processing time on the CEP processing cluster (in seconds)", quantity=time_q), ResourceType(name="LOFAR Observing Time", description="Observing time (in seconds)", quantity=time_q), diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/serializers/specification.py b/SAS/TMSS/backend/src/tmss/tmssapp/serializers/specification.py index a7e0ba3e6ae954f213d11c19f6f80014e299f63b..d5643db21650bee2126de69c15884f2b26f9521f 100644 --- a/SAS/TMSS/backend/src/tmss/tmssapp/serializers/specification.py +++ b/SAS/TMSS/backend/src/tmss/tmssapp/serializers/specification.py @@ -171,6 +171,8 @@ class ProjectSerializer(DynamicRelationalHyperlinkedModelSerializer): class ProjectQuotaSerializer(DynamicRelationalHyperlinkedModelSerializer): + project_quota_archive_location = serializers.HyperlinkedRelatedField('projectquotaarchivelocation-detail', source='*', read_only=True) + class Meta: model = models.ProjectQuota fields = '__all__'