fix(prediction): correct dataset mapping

This commit is contained in:
gili8420 2026-08-04 13:42:10 +09:00
parent 7f70ebdd96
commit a53adc4585
3 changed files with 107 additions and 3 deletions

View file

@ -5,6 +5,7 @@ from django.contrib.auth.password_validation import validate_password
from django.core.validators import validate_email
from django.core.exceptions import ValidationError as DjangoValidationError
from django.contrib.auth import get_user_model
from .services.tawhiri import LATEST_DATASET_KEYWORD
from .validators import (
validate_custom_curve, rate_clip,
_rfc3339_to_timestamp, base64_to_curve
@ -21,13 +22,23 @@ PROFILE_STANDARD = "standard_profile"
PROFILE_FLOAT = "float_profile"
PROFILE_REVERSE = "reverse_profile"
PROFILE_CUSTOM = "custom_profile"
LATEST_DATASET_KEYWORD = "latest"
SUPPORTED_PROFILES = [PROFILE_STANDARD, PROFILE_FLOAT, PROFILE_REVERSE, PROFILE_CUSTOM]
class PredictionRequestSerializer(serializers.Serializer):
launch_latitude = serializers.FloatField(min_value=-90, max_value=90)
launch_longitude = serializers.FloatField(min_value=0, max_value=360)
# Deliberately unbounded. Longitude is on a circle, so every real number names
# a real meridian and any interval here is a policy about typos, not places —
# and that policy belongs to the one service that owns the wind grid. The
# endpoint this calls, GET /api/v1/prediction, applies no longitude bound: it
# normalises and lets the grid refuse what it cannot use.
#
# This field was min_value=0, narrower than that endpoint, which refused every
# launch west of Greenwich — Canada, Greenland, Alaska. Two layers each
# guessing at the range is what produced that, so this one no longer guesses.
# FloatField still refuses anything that is not a number; NaN and infinity get
# through here and are rejected by the predictor's request decoder.
launch_longitude = serializers.FloatField()
launch_datetime = serializers.DateTimeField()
launch_altitude = serializers.FloatField(required=False)
format = serializers.CharField(default="json")