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

Site Observation Editor #244

Merged
merged 20 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ jobs:
ports:
- 9000:9000
steps:
- name: Update Package References
run: sudo apt-get update
- name: Install system dependencies
run: apt-fast install --no-install-recommends --yes
libgdal30
Expand Down
10 changes: 10 additions & 0 deletions django/src/rdwatch/api.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
from ninja import NinjaAPI
from ninja.errors import ValidationError

from .views.model_run import router as model_run_router
from .views.performer import router as performer_router
from .views.region import router as region_router
from .views.site_evaluation import router as site_evaluation_router
from .views.site_image import router as images_router
from .views.site_observation import router as site_observation_router

api = NinjaAPI()

api.add_router('/evaluations/', site_evaluation_router)
api.add_router('/observations/', site_observation_router)
api.add_router('/model-runs/', model_run_router)
api.add_router('/performers/', performer_router)
api.add_router('/evaluations/images/', images_router)
api.add_router('/regions/', region_router)


# useful for getting information back about validation errors
@api.exception_handler(ValidationError)
def custom_validation_errors(request, exc):
print(exc.errors) # <--------------------- !!!!
return api.create_response(request, {'detail': exc.errors}, status=422)
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
# Generated by Django 4.1.9 on 2023-08-22 08:14

import django.contrib.gis.db.models.fields
import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
('rdwatch', '0011_siteimage_aws_location_siteimage_image_bbox_and_more'),
]

operations = [
migrations.AddField(
model_name='hyperparameters',
name='ground_truth',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='hyperparameters',
name='proposal',
field=models.CharField(
blank=True,
choices=[('PROPOSAL', 'Proposal'), ('APPROVED', 'Approved')],
help_text='Fetching Status',
max_length=255,
null=True,
),
),
migrations.AddField(
model_name='siteevaluation',
name='cache_commit_hash',
field=models.CharField(
blank=True,
help_text='Hash of the file for proposals',
max_length=2048,
null=True,
),
),
migrations.AddField(
model_name='siteevaluation',
name='cache_originator_file',
field=models.CharField(
blank=True,
help_text='Name of source file for proposals',
max_length=2048,
null=True,
),
),
migrations.AddField(
model_name='siteevaluation',
name='cache_timestamp',
field=models.DateTimeField(
help_text='Cache timestamp for proposals', null=True
),
),
migrations.AddField(
model_name='siteevaluation',
name='end_date',
field=models.DateTimeField(help_text='end date in geoJSON', null=True),
),
migrations.AddField(
model_name='siteevaluation',
name='notes',
field=models.TextField(blank=True, null=True),
),
migrations.AddField(
model_name='siteevaluation',
name='start_date',
field=models.DateTimeField(help_text='Start date in geoJSON', null=True),
),
migrations.AddField(
model_name='siteevaluation',
name='status',
field=models.CharField(
blank=True,
choices=[
('PROPOSAL', 'Proposal'),
('APPROVED', 'Approved'),
('REJECTED', 'Rejected'),
],
help_text='Fetching Status',
max_length=255,
null=True,
),
),
migrations.AddField(
model_name='siteevaluation',
name='validated',
field=models.BooleanField(blank=True, null=True),
),
migrations.AddField(
model_name='siteobservation',
name='notes',
field=models.TextField(blank=True, null=True),
),
migrations.AlterField(
model_name='siteevaluation',
name='number',
field=models.IntegerField(db_index=True, help_text='The site number'),
),
migrations.AlterField(
model_name='siteobservation',
name='timestamp',
field=models.DateTimeField(
help_text="The source image's timestamp", null=True
),
),
migrations.CreateModel(
name='SiteObservationTracking',
fields=[
(
'id',
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name='ID',
),
),
('edited', models.DateTimeField()),
('score', models.FloatField(help_text='Evaluation accuracy')),
(
'geom',
django.contrib.gis.db.models.fields.PolygonField(
help_text='Footprint of site observation', srid=3857
),
),
('notes', models.TextField(blank=True, null=True)),
(
'label',
models.ForeignKey(
on_delete=django.db.models.deletion.PROTECT,
to='rdwatch.observationlabel',
),
),
(
'observation',
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name='base_site_observation',
to='rdwatch.siteobservation',
),
),
(
'siteeval',
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to='rdwatch.siteevaluation',
),
),
],
),
migrations.CreateModel(
name='SiteEvaluationTracking',
fields=[
(
'id',
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name='ID',
),
),
('edited', models.DateTimeField()),
(
'start_date',
models.DateTimeField(help_text='Start date in geoJSON', null=True),
),
(
'end_date',
models.DateTimeField(help_text='end date in geoJSON', null=True),
),
('score', models.FloatField(help_text='Score of site footprint')),
('notes', models.TextField(blank=True, null=True)),
(
'evaluation',
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to='rdwatch.siteevaluation',
),
),
(
'label',
models.ForeignKey(
help_text='Site feature classification label',
on_delete=django.db.models.deletion.PROTECT,
to='rdwatch.observationlabel',
),
),
],
),
migrations.CreateModel(
name='AnnotationExport',
fields=[
(
'id',
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name='ID',
),
),
('export_file', models.FileField(blank=True, null=True, upload_to='')),
(
'created',
models.DateTimeField(
help_text='The zip file export, deleted 1 hour after creation'
),
),
(
'name',
models.CharField(
blank=True,
help_text='Name of the model run for download',
max_length=1024,
),
),
(
'celery_id',
models.CharField(
blank=True, help_text='Celery Task Id', max_length=255
),
),
(
'configuration',
models.ForeignKey(
help_text='The hyper parameters used for the xport',
on_delete=django.db.models.deletion.PROTECT,
to='rdwatch.hyperparameters',
),
),
],
),
]
8 changes: 6 additions & 2 deletions django/src/rdwatch/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
from . import lookups
from .annotation_exports import AnnotationExport
from .hyper_parameters import HyperParameters
from .region import Region
from .satellite_fetching import SatelliteFetching
from .site_evaluation import SiteEvaluation
from .site_evaluation import SiteEvaluation, SiteEvaluationTracking
from .site_image import SiteImage
from .site_observation import SiteObservation
from .site_observation import SiteObservation, SiteObservationTracking

__all__ = [
'AnnotationExport',
'lookups',
'HyperParameters',
'Region',
'SiteEvaluation',
'SiteObservation',
'SiteImage',
'SatelliteFetching',
'SiteEvaluationTracking',
'SiteObservationTracking',
]
31 changes: 31 additions & 0 deletions django/src/rdwatch/models/annotation_exports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from django.db import models
from django.dispatch import receiver


class AnnotationExport(models.Model):
configuration = models.ForeignKey(
to='HyperParameters',
on_delete=models.PROTECT,
help_text='The hyper parameters used for the xport',
db_index=True,
)
export_file = models.FileField(null=True, blank=True)
created = models.DateTimeField(
help_text='The zip file export, deleted 1 hour after creation',
)
name = models.CharField(
max_length=1024,
blank=True,
help_text='Name of the model run for download',
)
celery_id = models.CharField(
max_length=255,
blank=True,
help_text='Celery Task Id',
)


@receiver(models.signals.pre_delete, sender=AnnotationExport)
def delete_content(sender, instance, **kwargs):
if instance.export_file:
instance.export_file.delete(save=False)
15 changes: 15 additions & 0 deletions django/src/rdwatch/models/hyper_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,20 @@ class HyperParameters(models.Model):
help_text='Time relative to creation that this model run should be deleted.',
)

class ProposalStatus(models.TextChoices):
PROPOSAL = (
'PROPOSAL' # proposal is a proposal awaiting Adjudication/Confirmation
)
APPROVED = 'APPROVED' # proposal is approved and merged into ground truth

proposal = models.CharField(
max_length=255, # If we need future states
blank=True,
null=True,
help_text='Fetching Status',
choices=ProposalStatus.choices,
)
ground_truth = models.BooleanField(default=False)

def __str__(self) -> str:
return str(self.pk)
Loading
Loading