Skip to content

Commit

Permalink
added more logging to the observation serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon committed Sep 6, 2019
1 parent d8459a7 commit 31fa6b6
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions observation_portal/observations/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
from observation_portal.requestgroups.models import RequestGroup, AcquisitionConfig, GuidingConfig, Target
from observation_portal.proposals.models import Proposal

import logging
logger = logging.getLogger()


class SummarySerializer(serializers.ModelSerializer):
class Meta:
Expand Down Expand Up @@ -286,6 +289,9 @@ def validate(self, data):

# Validate that the start and end times are in one of the requests windows
in_a_window = False
logger.warn("Validating the observation is within a window: request {}, start {}, end {}".format(
data['request'].id, data['start'], data['end']
))
for window in data['request'].windows.all():
if data['start'] >= window.start.replace(microsecond=0) and data['end'] <= window.end:
in_a_window = True
Expand All @@ -294,6 +300,10 @@ def validate(self, data):
if not in_a_window:
raise serializers.ValidationError(_('The start {} and end {} times do not fall within any window of the request'.format(data['start'].isoformat(), data['end'].isoformat())))

logger.warn("Validating the observation location is valid: request {}, site {}, enc {}, tel {}".format(
data['request'].id, data['site'], data['enclosure'], data['telescope']
))

# Validate that the site, enclosure, and telescope match the location of the request
if (
data['request'].location.site and data['request'].location.site != data['site'] or
Expand All @@ -306,6 +316,12 @@ def validate(self, data):
)))

# Validate that the site, enclosure, telescope has the appropriate instrument

logger.warn("Validating the instrument is available: request {}, instrument type {}, instrument name {}".format(
data['request'].id, data['request'].configurations.first().instrument_type,
data['configuration_statuses'][0]['instrument_name']
))

available_instruments = configdb.get_instruments_at_location(
data['site'], data['enclosure'], data['telescope'], only_schedulable=False
)
Expand Down

0 comments on commit 31fa6b6

Please sign in to comment.