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

Issue1 gcmd short names #52

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
c892f8a
#1: deleted fixtures not used in the tests. New tests use mock.
mortenwh Feb 1, 2019
ff12aec
#1: Some more fixtures that were needed in geospaas.catalog.tests and…
mortenwh Feb 1, 2019
61ae0ec
#1: added an entry to self.mock_pti.get_gcmd_platform_list
mortenwh Feb 1, 2019
b145dfa
#1: Added fields to __str__ and natural_key methods in geospaas.vocab…
mortenwh Feb 1, 2019
d894b51
#1: Updated catalog fixtures to new source model, and changed to late…
mortenwh Feb 4, 2019
9ad8686
#1: Changed __str__ method of Dataset to return entry_title, changed …
mortenwh Feb 4, 2019
dabc835
#1: Test updated to use Aqua instead of AQUA as short name for the pl…
mortenwh Feb 4, 2019
c8c020f
#1: Set entry_title to the filename of the ingested dataset, update t…
mortenwh Feb 4, 2019
3f90889
#1: Do not raise error in the tests, this should be handled by the co…
mortenwh Feb 4, 2019
52cbc74
#1: new name for Aqua platform (was AQUA before)
mortenwh Feb 4, 2019
09dee8d
#1: New methods get_by_natural_key to accomodate for more parameters …
mortenwh Feb 4, 2019
4cc45ee
#1: use only short_name in the __str__ method of DataCenter
mortenwh Feb 4, 2019
ad7bd0b
#1: Updating viewer Search model and forms to use platform, instrumen…
mortenwh Feb 4, 2019
b266add
#1: new migrations to accomodate model changes
mortenwh Feb 4, 2019
d0d7eb4
#1: Added parameters to fixture
mortenwh Feb 4, 2019
ed2eb04
#1: viewer form working with platform and instrument instead of source
mortenwh Feb 4, 2019
e38423b
#1: search platform, instrument and parameter in views.py and removed…
mortenwh Feb 4, 2019
eb4e9ea
#1: removed intermediate models. These should not be necessary unless…
mortenwh Feb 4, 2019
ef136a7
#1: Removed intermediate relationship through DatasetParameter, made …
mortenwh Feb 4, 2019
4b97b52
#1: merged with origin and resolved conflicts
mortenwh Feb 4, 2019
8a15d6c
#1: Removed old commented code
mortenwh Feb 4, 2019
c88c01d
#1: viewer tests passing
mortenwh Feb 4, 2019
2e05634
#1: import nansat_filename in test..
mortenwh Feb 4, 2019
6e853d4
#1: removed duplicate parameter entry in fixture and updated catalog.…
mortenwh Feb 4, 2019
b3ff98b
#1:renamed migration file
mortenwh Feb 5, 2019
6208a4b
#1: Added data migration of Dataset.source field to new Dataset.sourc…
mortenwh Feb 5, 2019
ebe676a
#1: corrected app label in migration file
mortenwh Feb 5, 2019
a83c862
#1: ongoing changes to update contents of Dataset.parameters field
mortenwh Feb 5, 2019
ee30d85
#1: data migration for parameters field
mortenwh Feb 5, 2019
78d0ca1
#1: both forward and backward migrations working
mortenwh Feb 5, 2019
3e44f5b
#1: Added default None in search model, created migration, and update…
mortenwh Feb 5, 2019
7d6a45d
#1: Assigned IP-address to the vm to be able to see the output from t…
mortenwh Feb 5, 2019
1401922
#1: changed __str__ methods of Source and DatasetURI models, and chan…
mortenwh Feb 6, 2019
8fe4d11
#1: full test coverage of catalog.models
mortenwh Feb 6, 2019
822a589
#1: reinserted fixture..
mortenwh Feb 6, 2019
ada572d
#1: almost full test coverage of geospaas.vocabularies.managers, exce…
mortenwh Feb 6, 2019
8be4bd2
#1: test coverage of new parameter search
mortenwh Feb 6, 2019
03ada4d
#1: test coverage of new parameter search in viewer.views.py
mortenwh Feb 6, 2019
37048b1
#1: make sure natural_key methods return tuple
mortenwh Feb 6, 2019
e5b22b5
#1: full test coverage of vocabularies/models.py
mortenwh Feb 6, 2019
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
1 change: 1 addition & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box_url = "https://atlas.hashicorp.com/ubuntu/trusty64"

config.vm.define "geospaas", primary: true do |geospaas|
geospaas.vm.network :private_network, ip: "192.168.33.10"
Copy link
Member

Choose a reason for hiding this comment

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

This is not needed. In fact it can conflict with other VMs for other projects. If not specified, vagrant allocates free IP to the VM without conflicts.

end

config.vm.provider "virtualbox" do |v|
Expand Down
11 changes: 6 additions & 5 deletions geospaas/catalog/fixtures/catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
"pk": 1,
"model": "catalog.source",
"fields": {
"platform": ["AQUA"],
"instrument": ["MODIS"],
"specs": "Nothing special"
"platform": ["Earth Observation Satellites", "", "Aqua", "Earth Observing System, Aqua"],
"instrument": ["Earth Remote Sensing Instruments", "Passive Remote Sensing", "Spectrometers/Radiometers", "Imaging Spectrometers/Radiometers", "MODIS", "Moderate-Resolution Imaging Spectroradiometer"]
}
},{
"pk": 1,
Expand All @@ -27,7 +26,8 @@
"time_coverage_end": "2010-01-02T00:00:00Z",
"time_coverage_start": "2010-01-01T00:00:00Z",
"summary": "This is a quite short summary about the test dataset.",
"source": ["AQUA", "MODIS"],
"sources": [[["Earth Observation Satellites", "", "Aqua", "Earth Observing System, Aqua"], ["Earth Remote Sensing Instruments", "Passive Remote Sensing", "Spectrometers/Radiometers", "Imaging Spectrometers/Radiometers", "MODIS", "Moderate-Resolution Imaging Spectroradiometer"]]],
"parameters": [["sea_surface_temperature"], ["wind_speed"]],
"geographic_location": 1,
"data_center": ["NERSC"],
"gcmd_location": ["VERTICAL LOCATION", "SEA SURFACE", "", "", ""],
Expand All @@ -43,7 +43,8 @@
"time_coverage_end": "2010-01-03T00:00:00Z",
"time_coverage_start": "2010-01-02T00:00:00Z",
"summary": "This is a quite short summary about the test dataset.",
"source": ["AQUA", "MODIS"],
"sources": [[["Earth Observation Satellites", "", "Aqua", "Earth Observing System, Aqua"], ["Earth Remote Sensing Instruments", "Passive Remote Sensing", "Spectrometers/Radiometers", "Imaging Spectrometers/Radiometers", "MODIS", "Moderate-Resolution Imaging Spectroradiometer"]]],
"parameters": [["sea_surface_temperature"], ["wind_speed"]],
"geographic_location": 2,
"data_center": ["NERSC"],
"gcmd_location": ["VERTICAL LOCATION", "SEA SURFACE", "", "", ""],
Expand Down
5 changes: 4 additions & 1 deletion geospaas/catalog/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
class SourceManager(models.Manager):

def get_by_natural_key(self, p, i):
return self.get(platform__short_name=p, instrument__short_name=i)
return self.get(platform__category=p[0], platform__series_entity=p[1],
platform__short_name=p[2], platform__long_name=p[3], instrument__category=i[0],
instrument__instrument_class=i[1], instrument__type=i[2], instrument__subtype=i[3],
instrument__short_name=i[4], instrument__long_name=i[5])

class DatasetURIQuerySet(models.QuerySet):
def get_non_ingested_uris(self, all_uris):
Expand Down
18 changes: 18 additions & 0 deletions geospaas/catalog/migrations/0007a_add_sources_field.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.1.5 on 2019-02-04 10:25

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('catalog', '0006_auto_20190130_1442'),
]

operations = [
migrations.AddField(
model_name='dataset',
name='sources',
field=models.ManyToManyField(to='catalog.Source'),
),
]
23 changes: 23 additions & 0 deletions geospaas/catalog/migrations/0007b_migrate_source_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from django.db import migrations

def copy_source(apps, schema_editor):
Dataset = apps.get_model('catalog', 'Dataset')
for ds in Dataset.objects.all():
ds.sources.add(ds.source)

def copy_source_backwards(apps, schema_editor):
Dataset = apps.get_model('catalog', 'Dataset')
for ds in Dataset.objects.all():
src = ds.sources.all()[0]
ds.source = src
ds.save()

class Migration(migrations.Migration):

dependencies = [
('catalog', '0007a_add_sources_field'),
]

operations = [
migrations.RunPython(copy_source, copy_source_backwards),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 2.1.5 on 2019-02-04 10:25

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('catalog', '0007b_migrate_source_data'),
]

operations = [
migrations.RemoveField(
model_name='dataset',
name='source',
),
migrations.RemoveField(
model_name='source',
name='specs',
),
]
19 changes: 19 additions & 0 deletions geospaas/catalog/migrations/0008a_add_newparameters_field.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 2.1.5 on 2019-02-04 18:01

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('vocabularies', '0001_initial'),
('catalog', '0007c_remove_source_and_specs_fields'),
]

operations = [
migrations.AddField(
model_name='dataset',
name='newparameters',
Copy link
Member

Choose a reason for hiding this comment

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

Can you squash these migrations? You added newparameters and then removed it but generated migrations in between.

field=models.ManyToManyField(to='vocabularies.Parameter'),
),
]
28 changes: 28 additions & 0 deletions geospaas/catalog/migrations/0008b_migrate_parameters_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 2.1.5 on 2019-02-05 12:18

from django.db import migrations

def forward(apps, schema_editor):
Dataset = apps.get_model('catalog', 'Dataset')
DatasetParameter = apps.get_model('catalog', 'DatasetParameter')
for ds in Dataset.objects.all():
dataset_params = DatasetParameter.objects.filter(dataset=ds)
for dp in dataset_params:
ds.newparameters.add(dp.parameter)

def backward(apps, schema_editor):
Dataset = apps.get_model('catalog', 'Dataset')
DatasetParameter = apps.get_model('catalog', 'DatasetParameter')
for ds in Dataset.objects.all():
for pp in ds.newparameters.all():
dp, created = DatasetParameter.objects.get_or_create(dataset=ds, parameter=pp)

class Migration(migrations.Migration):

dependencies = [
('catalog', '0008a_add_newparameters_field'),
]

operations = [
migrations.RunPython(forward, backward),
]
18 changes: 18 additions & 0 deletions geospaas/catalog/migrations/0008c_remove_parameters_field.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.1.5 on 2019-02-04 18:01

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('vocabularies', '0001_initial'),
('catalog', '0008b_migrate_parameters_data'),
]

operations = [
migrations.RemoveField(
model_name='dataset',
name='parameters',
),
]
18 changes: 18 additions & 0 deletions geospaas/catalog/migrations/0009_rename_newparameters_field.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.1.5 on 2019-02-04 18:02

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('catalog', '0008c_remove_parameters_field'),
]

operations = [
migrations.RenameField(
model_name='dataset',
old_name='newparameters',
new_name='parameters',
),
]
25 changes: 11 additions & 14 deletions geospaas/catalog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,21 @@ def __str__(self):


class Source(models.Model):
# Consider updating to follow https://gcmd.nasa.gov/DocumentBuilder/defaultDif10/guide/platform.html
platform = models.ForeignKey(Platform, on_delete=models.CASCADE)
instrument = models.ForeignKey(Instrument, on_delete=models.CASCADE)
specs = models.CharField(max_length=50, default='',
help_text=_('Further specifications of the source.'))

objects = SourceManager()

class Meta:
unique_together = (("platform", "instrument"),)

def __str__(self):
if not self.platform and not self.instrument:
return '%s' % self.specs
else:
return '%s/%s' % (self.platform, self.instrument)
return 'Platform: (%s) / Instrument: (%s)' % (self.platform.__str__(),
self.instrument.__str__())

def natural_key(self):
return (self.platform.short_name, self.instrument.short_name)
return (self.platform.natural_key(), self.instrument.natural_key())

class Personnel(models.Model):
'''
Expand Down Expand Up @@ -103,8 +100,8 @@ class Dataset(models.Model):
In addition to some general information, the summary should also
contain information about the project from/for which the data was
collected/created
source : ForeignKey to Source
Contains information about the instrument and platform by which the
sources : ManyToMany relation to Source
Contains information about the instruments and platforms by which the
data was collected
time_coverage_start : DateTimeField
time_coverage_end : DateTimeField
Expand All @@ -131,13 +128,14 @@ class Dataset(models.Model):
]
)
entry_title = models.CharField(max_length=220)
parameters = models.ManyToManyField(Parameter, through='DatasetParameter')
#parameters = models.ManyToManyField(Parameter, through='DatasetParameter')
parameters = models.ManyToManyField(Parameter)
Copy link
Member

Choose a reason for hiding this comment

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

Can you also remove the model DatasetParameter if it is not used anymore?

ISO_topic_category = models.ForeignKey(ISOTopicCategory, on_delete=models.CASCADE)
data_center = models.ForeignKey(DataCenter, on_delete=models.CASCADE)
summary = models.TextField()

# DIF highly recommended fields
source = models.ForeignKey(Source, blank=True, null=True, on_delete=models.CASCADE)
sources = models.ManyToManyField(Source)
time_coverage_start = models.DateTimeField(blank=True, null=True)
time_coverage_end = models.DateTimeField(blank=True, null=True)
geographic_location = models.ForeignKey(GeographicLocation, blank=True, null=True, on_delete=models.CASCADE)
Expand All @@ -146,8 +144,7 @@ class Dataset(models.Model):
choices=ACCESS_CHOICES, blank=True, null=True)

def __str__(self):
return '%s/%s/%s' % (self.source.platform, self.source.instrument,
self.time_coverage_start.isoformat())
return self.entry_title

# Keep this for reference if we want to add it
#class DataResolution(models.Model):
Expand Down Expand Up @@ -179,7 +176,7 @@ class Meta:
unique_together = (('uri', 'dataset'),)

def __str__(self):
return '%s: %s'%(self.dataset, os.path.split(self.uri)[1])
return str(self.uri)

def protocol(self):
return self.uri.split(':')[0]
Expand Down
Loading