Skip to content

Commit

Permalink
v2.2 (#1271)
Browse files Browse the repository at this point in the history
* Update Django to v2.2.17 (#1256)

* Update Django and other related libs. Django 2.1.15 -> 2.2.17 #1255

* Update of other dependencies

* Integrate with DESaccess (#1258)

* Minor correction in the target catalogs query using postgresql

* Start of integration with Descut service.

* Created methods to Submit and Check the status of the Descut job. and the creation of the method to download the files has started.

* Created methods to download the results, match between targets and images. the method of registering images is still incomplete.

* Finalized the methods of registering images. Correction of target queries. creation of methods that retrieve the list of objects before submitting.

* Partial implementation of the cutout workflow.

* Integration with DESaccess cutout has been implemented. workflow created for submitting and downloading cutout jobs. #1257

* Created methods that allow integration with DESaccess Tile Finder. docstrings of the methods related to Cutout have been added. #1257

* Commenting the 'teste' endpoint

Co-authored-by: Matheus Allein <[email protected]>

* Target Cutout and Integration with DESaccess (#1267)

* Minor correction in the target catalogs query using postgresql

* Start of integration with Descut service.

* Created methods to Submit and Check the status of the Descut job. and the creation of the method to download the files has started.

* Created methods to download the results, match between targets and images. the method of registering images is still incomplete.

* Finalized the methods of registering images. Correction of target queries. creation of methods that retrieve the list of objects before submitting.

* Partial implementation of the cutout workflow.

* Integration with DESaccess cutout has been implemented. workflow created for submitting and downloading cutout jobs. #1257

* Created methods that allow integration with DESaccess Tile Finder. docstrings of the methods related to Cutout have been added. #1257

* Cutout Jobs submission form has been changed to be compatible with the new version of DESaccess. new color image options have been added. #1257

* Alteration of the Mosaic panel has started to allow the selection of more than one type of color image. Cutout Jobs loading and selection has been improved, now the job list will always be updated with all available jobs and the most recent job will be selected by default. #1257

* Refactoring the visualization of the cutouts, it is now possible to choose the color image used in the mosaic.

* minor fix in default settings #1257

* The discard_fits_files function has been implemented to avoid downloading fits files that have not been requested by the user. #1257

* Download Target List compatible with DESacces. (#1269)

* Minor fix in cutout.

* A correction was made to the download feature. to be compatible with the new version of DESaccess.

* Change labels Mosaic -> Cutout

* Minor fix in cutout (#1270)

* Fixing contrast bug and removing features from tile inspection (#1259)

* Fixing contrast bug and removing features from tile inspection

* Changing virtual list library

* Fixing reload logic based on new virtual list

* Fixing release change not loading datasets

* The name of the configuration variable has been changed.

* Enabling clear search and positioning visiomatic on search by position

Co-authored-by: glaubervila <[email protected]>

* Feat/eyeballing tile download (#1268)

* Fetching tile info and displaying on download dialog

* Fetching tile info and displaying on download dialog

* Fetching tile info and displaying on download dialog

* Adding error handler for the case of not having data on tile

* Fixing release change not loading datasets

Co-authored-by: Matheus Allein <[email protected]>
  • Loading branch information
glaubervila and matheusallein authored Dec 4, 2020
1 parent 2dfdf9e commit 584583e
Show file tree
Hide file tree
Showing 60 changed files with 3,327 additions and 2,154 deletions.
2 changes: 2 additions & 0 deletions api/catalog/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@


class CommentsAPITestCase(APITestCase):
databases = '__all__'

def setUp(self):
self.user = User.objects.create_user("dri", "[email protected]", "dri")
self.client.login(username='dri', password='dri')
Expand Down
141 changes: 124 additions & 17 deletions api/coadd/views.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
import copy
import os
from urllib.parse import urljoin

import django_filters
from common.models import Filter
from django.conf import settings
from django_filters.rest_framework import DjangoFilterBackend, OrderingFilter
from lib.sqlalchemy_wrapper import DBBase
from rest_framework import filters
from rest_framework import viewsets
from rest_framework.decorators import api_view, list_route
from rest_framework import filters, viewsets
from rest_framework.decorators import api_view
from rest_framework.decorators import action
from rest_framework.response import Response
from django_filters.rest_framework import DjangoFilterBackend
from django_filters.rest_framework import OrderingFilter

from .models import Release, Tag, Tile, Dataset, Survey
from .serializers import ReleaseSerializer, TagSerializer, TileSerializer, DatasetSerializer, \
SurveySerializer, DatasetFootprintSerializer
from django.conf import settings
import os
from urllib.parse import urljoin

from common.models import Filter
from .models import Dataset, Release, Survey, Tag, Tile
from .serializers import (DatasetFootprintSerializer, DatasetSerializer,
ReleaseSerializer, SurveySerializer, TagSerializer,
TileSerializer)

# Create your views here.
from common.desaccess import DesAccessApi


class ReleaseViewSet(viewsets.ModelViewSet):
Expand Down Expand Up @@ -66,18 +65,53 @@ class TileViewSet(viewsets.ModelViewSet):

ordering_fields = ('tli_tilename', 'tli_ra', 'tli_dec',)

@action(detail=True)
def desaccess_tile_info(self, request, pk=None):
"""Search DESaccess for tilename and return a list of tile files.
Returns:
dict: returns a dict with the image and catalog urls.
"""
tile = self.get_object()

tilename = tile.tli_tilename

desapi = DesAccessApi()
tileinfo = desapi.tile_by_name(tilename)

return Response(tileinfo)

@action(detail=False, methods=['post'])
def desaccess_get_download_url(self, request):
"""creates an authenticated url for a file served by DESaccess.
Args:
file_url (str): URL of the file to be downloaded.
Returns:
str: Authenticated URL, note that this url has a time limit to be used. must be generated at the time the download is requested.
"""

params = request.data
file_url = params['file_url']

desapi = DesAccessApi()

download_url = desapi.file_url_to_download(file_url)

return Response(dict({"download_url": download_url}))


class DatasetFilter(django_filters.FilterSet):
tag__in = django_filters.CharFilter(method='filter_tag__in')
tli_tilename = django_filters.CharFilter(field_name='tile__tli_tilename', label='Tilename')
position = django_filters.CharFilter(method='filter_position')
release = django_filters.CharFilter(method='filter_release')
inspected = django_filters.CharFilter(method='filter_inspected')


class Meta:
model = Dataset
fields = ['id', 'tag', 'tile', 'tag__in', 'tli_tilename', 'release',]
fields = ['id', 'tag', 'tile', 'tag__in', 'tli_tilename', 'release', ]
order_by = True

def filter_release(self, queryset, name, value):
Expand Down Expand Up @@ -145,6 +179,79 @@ class DatasetViewSet(viewsets.ModelViewSet):

ordering = ('tile__tli_tilename',)

@action(detail=True)
def desaccess_tile_info(self, request, pk=None):
"""Search DESaccess for tilename and return a list of tile files already filtered by the dataset release.
Returns:
dict: returns a dict with the image and catalog urls, both organized by band and with the file url.
"""
dataset = self.get_object()

# Requested to associate these internal releases
# to the DESAccess releases:
associated_releases = {
'y6a2_coadd': 'y6a1_coadd',
'y3a1_coadd': 'y3a2_coadd',
'y1_supplemental_dfull': 'y1a1_coadd',
'y1_supplemental_d10': 'y1a1_coadd',
'y1_supplemental_d04': 'y1a1_coadd',
'y1_wide_survey': 'y1a1_coadd',
}

tilename = dataset.tile.tli_tilename
rls_name = dataset.tag.tag_release.rls_name

# Associate the internal release to the release of DESAccess:
if rls_name in associated_releases.keys():
rls_name = associated_releases[rls_name]

desapi = DesAccessApi()

tileinfo = desapi.tile_by_name(tilename)

for release in tileinfo["releases"]:
# Compara o release pelo internal name, nas nossas tabelas o release tem _coadd no nome. por isso é necessário fazer um split.
if release["release"] == rls_name.split("_")[0].lower():

result = dict({
"tilename": tileinfo["tilename"],
"ra_cent": tileinfo["ra_cent"],
"dec_cent": tileinfo["dec_cent"],
"racmin": tileinfo["racmin"],
"racmax": tileinfo["racmax"],
"deccmin": tileinfo["deccmin"],
"deccmax": tileinfo["deccmax"],
"images": {},
"catalogs": {},
})

for band in release["bands"]:
result["images"][band.lower()] = release["bands"][band]["image"]
result["catalogs"][band.lower()] = release["bands"][band]["catalog"]

return Response(result)

@action(detail=False, methods=['post'])
def desaccess_get_download_url(self, request):
"""creates an authenticated url for a file served by DESaccess.
Args:
file_url (str): URL of the file to be downloaded.
Returns:
str: Authenticated URL, note that this url has a time limit to be used. must be generated at the time the download is requested.
"""

params = request.data
file_url = params['file_url']

desapi = DesAccessApi()

download_url = desapi.file_url_to_download(file_url)

return Response(dict({"download_url": download_url}))


class DatasetFootprintViewSet(viewsets.ModelViewSet):
queryset = Dataset.objects.select_related().all()
Expand Down Expand Up @@ -172,7 +279,7 @@ class SurveyViewSet(viewsets.ModelViewSet):
ordering_fields = ('srv_filter__lambda_min',)


@api_view(['GET'])
@ api_view(['GET'])
def get_fits_by_tilename(request):
if request.method == 'GET':

Expand Down
Loading

0 comments on commit 584583e

Please sign in to comment.