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

Add tests for models in the core app #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,7 @@ trainings/*
backend/.env
backend/config.txt
backend/postgres-data

# virtualenvs
.venv/
.env/
26 changes: 25 additions & 1 deletion backend/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class DatasetStatus(models.IntegerChoices):
default=-1, choices=DatasetStatus.choices
) # 0 for active , 1 for archieved

def __str__(self):
return self.name


class AOI(models.Model):
class DownloadStatus(models.IntegerChoices):
Expand All @@ -36,6 +39,9 @@ class DownloadStatus(models.IntegerChoices):
created_at = models.DateTimeField(auto_now_add=True)
last_modified = models.DateTimeField(auto_now=True)

def __str__(self):
return f"{self.dataset.name} - {self.geom}"


class Label(models.Model):
aoi = models.ForeignKey(AOI, to_field="id", on_delete=models.CASCADE)
Expand All @@ -44,6 +50,9 @@ class Label(models.Model):
tags = models.JSONField(null=True, blank=True)
created_at = models.DateTimeField(auto_now_add=True)

def __str__(self):
return f"{self.aoi} - {self.geom}"


class Model(models.Model):
class ModelStatus(models.IntegerChoices):
Expand All @@ -57,7 +66,10 @@ class ModelStatus(models.IntegerChoices):
last_modified = models.DateTimeField(auto_now=True)
created_by = models.ForeignKey(OsmUser, to_field="osm_id", on_delete=models.CASCADE)
published_training = models.PositiveIntegerField(null=True, blank=True)
status = models.IntegerField(default=-1, choices=ModelStatus.choices) #
status = models.IntegerField(default=-1, choices=ModelStatus.choices)

def __str__(self):
return self.name


class Training(models.Model):
Expand Down Expand Up @@ -87,6 +99,9 @@ class Training(models.Model):
batch_size = models.PositiveIntegerField()
freeze_layers = models.BooleanField(default=False)

def __str__(self):
return self.model.name


class Feedback(models.Model):
FEEDBACK_TYPE = (
Expand All @@ -106,6 +121,9 @@ class Feedback(models.Model):
user = models.ForeignKey(OsmUser, to_field="osm_id", on_delete=models.CASCADE)
source_imagery = models.URLField()

def __str__(self):
return f"{self.user} - {self.training} - {self.feedback_type}"


class FeedbackAOI(models.Model):
class DownloadStatus(models.IntegerChoices):
Expand All @@ -122,6 +140,9 @@ class DownloadStatus(models.IntegerChoices):
source_imagery = models.URLField()
user = models.ForeignKey(OsmUser, to_field="osm_id", on_delete=models.CASCADE)

def __str__(self):
return f"{self.user} - {self.training} - {self.source_imagery}"


class FeedbackLabel(models.Model):
osm_id = models.BigIntegerField(null=True, blank=True)
Expand All @@ -132,3 +153,6 @@ class FeedbackLabel(models.Model):

geom = geomodels.PolygonField(srid=4326)
created_at = models.DateTimeField(auto_now_add=True)

def __str__(self):
return f"{self.osm_id} - {self.feedback_aoi} - {self.tags}"
3 changes: 2 additions & 1 deletion backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ geojson2osm==0.0.1
osmconflator
orthogonalizer
fairpredictor==0.0.26
tflite-runtime==2.14.0
tflite-runtime==2.14.0
model-bakery==1.17.0 # for testing
Loading