Skip to content

Commit

Permalink
support new task generating profile comparisons
Browse files Browse the repository at this point in the history
  • Loading branch information
aperrin66 committed Sep 13, 2024
1 parent 5c8f0b9 commit 3752511
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
11 changes: 6 additions & 5 deletions geospaas_rest_api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
geospaas_processing = None

if geospaas_processing:
from .processing_api.models import (Job,
DownloadJob,
ConvertJob,
SyntoolCleanupJob,
HarvestJob)
from geospaas_rest_api.processing_api.models import (Job,
DownloadJob,
ConvertJob,
SyntoolCleanupJob,
SyntoolCompareJob,
HarvestJob)
29 changes: 29 additions & 0 deletions geospaas_rest_api/processing_api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,35 @@ def make_task_parameters(parameters):
return ((parameters['criteria'],), {})


class SyntoolCompareJob(Job):
"""Job which generates comparison between Argo profiles and a 3D
product
"""
class Meta:
proxy = True

@classmethod
def get_signature(cls, parameters):
return celery.chain(
tasks_syntool.compare_profiles.signature(),
tasks_syntool.db_insert.signature(),
tasks_core.remove_downloaded.signature()
)

@staticmethod
def check_parameters(parameters):
accepted_keys = ('dataset_id', 'profiles_lookups')
if not set(parameters).issubset(set(accepted_keys)):
raise ValidationError(
f"The convert action accepts only these parameters: {', '.join(accepted_keys)}")
return parameters

@staticmethod
def make_task_parameters(parameters):
return (((parameters['dataset_id'],),),
{'profiles_lookups': parameters['profiles_lookups']})


class HarvestJob(Job):
"""Job which harvests metadata into the database"""
class Meta:
Expand Down
4 changes: 3 additions & 1 deletion geospaas_rest_api/processing_api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class JobSerializer(rest_framework.serializers.Serializer):
'convert': models.ConvertJob,
'harvest': models.HarvestJob,
'syntool_cleanup': models.SyntoolCleanupJob,
'compare_profiles': models.SyntoolCompareJob,
}

# Actual Job fields
Expand All @@ -27,7 +28,8 @@ class JobSerializer(rest_framework.serializers.Serializer):
'download',
'convert',
'harvest',
'syntool_cleanup'
'syntool_cleanup',
'compare_profiles',
],
required=True, write_only=True,
help_text="Action to perform")
Expand Down

0 comments on commit 3752511

Please sign in to comment.