-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Devel validation #103
Devel validation #103
Conversation
…). 2) Cleaning up code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pxjacomex , I've left here a few comments for you to check.
We really need to work with small chunks of work - having to review over 100 files is just impracticable for an efficient development process.
daily/__init__.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pxjacomex , describe here in a docstring what the purpose of this app is, so it is easier to understand its contents.
daily/models.py
Outdated
abstract = True | ||
|
||
|
||
def create_Dai_model(digits=14, decimals=6, fields=("Average")) -> Type[TimescaleModel]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def create_Dai_model(digits=14, decimals=6, fields=("Average")) -> Type[TimescaleModel]: | |
def create_day_model(digits=14, decimals=6, fields=("Average")) -> Type[TimescaleModel]: |
You will need to update everywhere this function is used.
@@ -0,0 +1,32 @@ | |||
from django_filters import rest_framework as filters | |||
|
|||
from station.models import Station |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This import is not needed here
class PercentageOxygenConcentrationDepth( | ||
create_Dai_model( | ||
digits=6, | ||
decimals=2, | ||
), | ||
): | ||
"""Percentage oxygen concentration (mg/l) at a depth in cm. | ||
|
||
HELPWANTED: Is this wrong? It's teh same as above, perhaps units should | ||
be %? --> DIEGO: Looks identical to the previous one to me. It might be an error. | ||
""" | ||
|
||
depth = models.PositiveSmallIntegerField("Depth") | ||
|
||
class Meta: | ||
default_permissions = () | ||
indexes = [ | ||
models.Index(fields=["station_id", "depth", "time"]), | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you comment on this one? It looks identical to the previous class.
decimals=2, | ||
), | ||
): | ||
"""Phycocyanin (?) at a depth in cm.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the units for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more comments from my side.
abstract = True | ||
|
||
|
||
def create_Dai_model( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dai
does not mean anything in english. Make the following change and change wherever is used.
def create_Dai_model( | |
def create_day_model( |
attrs.update(_fields) | ||
|
||
return type( | ||
f"_Dai{num}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f"_Dai{num}", | |
f"_Day{num}", |
# TODO Confirm if DischargeCurveSerializer is not needed in Validated Models | ||
# class DischargeCurveSerializer(serializers.ModelSerializer): | ||
# class Meta: | ||
# model = DischargeCurve | ||
# exclude = [] | ||
|
||
|
||
# class LevelFunctionSerializer(serializers.ModelSerializer): | ||
# class Meta: | ||
# model = LevelFunction | ||
# exclude = [] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Who needs to confirm this?
|
||
from . import views | ||
|
||
app_name = "hourly" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the Daily
app, right?
app_name = "hourly" | |
app_name = "daily" |
######################################################################################## | ||
# TODO: Revisit theses specialised views that use level_function_table() and create | ||
# Django Rest Framework equivalents. | ||
######################################################################################## |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than leaving this in the code commented, remove all of these code and open an issue about it, giving also some context about why it needs to be revisited.
djangomain/renderers.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this empty file needed? Remove if not needed.
formatting/serializers.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this empty file needed? Remove if not needed.
@@ -0,0 +1,32 @@ | |||
from django_filters import rest_framework as filters | |||
|
|||
from station.models import Station |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import not needed here.
class HourlyFilter(filters.FilterSet): | ||
""" | ||
Filter class for hourlys that are not Polar Wind, Discharge Curve, or Level Function | ||
and that have no depth information. | ||
""" | ||
|
||
time = filters.DateTimeFilter(field_name="time", lookup_expr="exact") | ||
min_time = filters.DateTimeFilter(field_name="time", lookup_expr="gte") | ||
max_time = filters.DateTimeFilter(field_name="time", lookup_expr="lte") | ||
value = filters.NumberFilter(field_name="value", lookup_expr="exact") | ||
min_value = filters.NumberFilter(field_name="value", lookup_expr="gte") | ||
max_value = filters.NumberFilter(field_name="value", lookup_expr="lte") | ||
station_id = filters.NumberFilter(field_name="station_id", lookup_expr="exact") | ||
used_for_hourly = filters.BooleanFilter( | ||
fieldname="used_for_hourly", lookup_expr="exact" | ||
) | ||
|
||
|
||
class HourlyFilterDepth(HourlyFilter): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These filters are identical to the daily filters and the monthly filters. If they need to be defined on an app basis, I would suggest to:
- Create
utilities/filters.py
and put all this filters withinJournalFilter
andJournalFilterDepth
classes. - In this file and the corresponding ones in the daily and monthly apps, subclass them:
from utilities.filters import JournalFilter, JournalFilterDepth
class HourlyFilter(JournalFilter):
"""
Filter class for hourlys that are not Polar Wind, Discharge Curve, or Level Function
and that have no depth information.
"""
class HourlyFilterDepth(JournalFilterDepth):
"""
Filter class for hourlys that are not Polar Wind, Discharge Curve, or Level Function
and that have depth information.
"""
However, if they do not need to be defined on an app basis, just skip step 2 altogether and directly import the JournalFilter
and JournalFilterDepth
where relevant. The more code we write, the harder it is to maintain, so let's keep it to a minimum.
"""Available hourly variables.""" | ||
|
||
|
||
# TODO check if PolarWind is needed in HOurly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To check with whom? If unsure, just delete these code and open an issue with it.
…d from grand parent class to parent)
…ge, sum and value
from django.urls import reverse | ||
from timescale.db.models.models import TimescaleModel | ||
|
||
from station.models import Station |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from station.models import Station |
Simply to monitor the evolution of changes when updating the validation tooling.