Skip to content
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

Merged
merged 25 commits into from
Aug 3, 2023
Merged

Devel validation #103

merged 25 commits into from
Aug 3, 2023

Conversation

dalonsoa
Copy link
Collaborator

@dalonsoa dalonsoa commented Jun 9, 2023

Simply to monitor the evolution of changes when updating the validation tooling.

Copy link
Collaborator Author

@dalonsoa dalonsoa left a 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.

Copy link
Collaborator Author

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 Show resolved Hide resolved
daily/models.py Outdated
abstract = True


def create_Dai_model(digits=14, decimals=6, fields=("Average")) -> Type[TimescaleModel]:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

daily/models.py Show resolved Hide resolved
@@ -0,0 +1,32 @@
from django_filters import rest_framework as filters

from station.models import Station
Copy link
Collaborator Author

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

Comment on lines +281 to +299
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"]),
]
Copy link
Collaborator Author

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."""
Copy link
Collaborator Author

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?

Copy link
Collaborator Author

@dalonsoa dalonsoa left a 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(
Copy link
Collaborator Author

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.

Suggested change
def create_Dai_model(
def create_day_model(

attrs.update(_fields)

return type(
f"_Dai{num}",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
f"_Dai{num}",
f"_Day{num}",

Comment on lines +38 to +49
# 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 = []

Copy link
Collaborator Author

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"
Copy link
Collaborator Author

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?

Suggested change
app_name = "hourly"
app_name = "daily"

Comment on lines +274 to +277
########################################################################################
# TODO: Revisit theses specialised views that use level_function_table() and create
# Django Rest Framework equivalents.
########################################################################################
Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import not needed here.

Comment on lines +6 to +24
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):
Copy link
Collaborator Author

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:

  1. Create utilities/filters.py and put all this filters within JournalFilter and JournalFilterDepth classes.
  2. 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
Copy link
Collaborator Author

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.

@dalonsoa dalonsoa marked this pull request as ready for review July 21, 2023 13:59
from django.urls import reverse
from timescale.db.models.models import TimescaleModel

from station.models import Station
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
from station.models import Station

@dalonsoa dalonsoa merged commit 8c2e2b8 into develop Aug 3, 2023
4 of 5 checks passed
@dalonsoa dalonsoa deleted the devel-validation branch August 3, 2023 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants