Skip to content

Commit

Permalink
Merge pull request #36 from CanDIG/daisieh-patch-1
Browse files Browse the repository at this point in the history
All sorts of fixes to get tests back up
  • Loading branch information
daisieh authored Feb 4, 2022
2 parents 4d5908f + 0958ed0 commit 6446b21
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 299 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Test

on:
push:
branches:
- develop
- master
pull_request:
branches:
- develop
- master

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
services:
postgres:
image: postgres:12
env:
POSTGRES_DB: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: python -m pip install -r requirements.txt
- name: Test
run: |
export POSTGRES_USER="postgres" && export POSTGRES_PASSWORD="postgres" && export POSTGRES_PORT=5432
coverage run ./manage.py test
- name: Codecov
run: codecov
8 changes: 2 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
dist: focal
language: python
python:
- "3.6"
- "3.8"
- "3.7"
addons:
postgresql: "12"
apt:
Expand All @@ -13,10 +12,7 @@ before_install:
- sudo -u postgres psql -U postgres -p 5433 -d postgres -c "alter user postgres with password 'hj38f3Ntr';"
install:
- pip install -r requirements.txt
- pip install .
script:
- export POSTGRES_USER="postgres" && export POSTGRES_PASSWORD="hj38f3Ntr" && export POSTGRES_PORT=5433
- python3 -m tox
- python3 -m coverage run ./manage.py test
- codecov
- rm -rf chord_metadata_service
- python3 -m coverage run ./manage.py test chord_metadata_service
2 changes: 1 addition & 1 deletion chord_metadata_service/chord/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@
"id": "readset_files",
"type": "file[]",
"required": True,
"extensions": [".cram", ".bam", ".bigWig", ".bigBed"]
"extensions": [".cram", ".bam", ".bigWig", ".bigBed", ".bw", ".bb"]
}
],
"outputs": [
Expand Down
57 changes: 28 additions & 29 deletions chord_metadata_service/mcode/api_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,20 @@ def get_queryset(self):
queryset = m.CancerGeneticVariant.objects.all()
return queryset


class GenomicRegionStudiedViewSet(McodeModelViewSet):
serializer_class = s.GenomicRegionStudiedSerializer
filter_backends = [DjangoFilterBackend]
filter_class = f.GenomicRegionStudiedFilter

def get_queryset(self):
if hasattr(self.request, "allowed_datasets"):
allowed_datasets = self.request.allowed_datasets
queryset = m.GenomicRegionStudied.objects\
.filter(genomicsreport__mcodepacket__table__ownership_record__dataset__title__in=allowed_datasets)
else:
queryset = m.GenomicRegionStudied.objects.all()
return queryset


GENOMIC_REPORT_PREFETCH = (
"genetic_specimen",
Expand All @@ -71,15 +79,6 @@ class GenomicRegionStudiedViewSet(McodeModelViewSet):
"genetic_variant",
)

def get_queryset(self):
if hasattr(self.request, "allowed_datasets"):
allowed_datasets = self.request.allowed_datasets
queryset = m.GenomicRegionStudied.objects\
.filter(genomicsreport__mcodepacket__table__ownership_record__dataset__title__in=allowed_datasets)
else:
queryset = m.GenomicRegionStudied.objects.all()
return queryset


class GenomicsReportViewSet(McodeModelViewSet):
serializer_class = s.GenomicsReportSerializer
Expand All @@ -101,11 +100,6 @@ class LabsVitalViewSet(McodeModelViewSet):
filter_backends = [DjangoFilterBackend]
filter_class = f.LabsVitalFilter


CANCER_CONDITION_PREFETCH = (
"tnmstaging_set",
)

def get_queryset(self):
if hasattr(self.request, "allowed_datasets"):
allowed_datasets = self.request.allowed_datasets
Expand All @@ -116,6 +110,11 @@ def get_queryset(self):
return queryset


CANCER_CONDITION_PREFETCH = (
"tnmstaging_set",
)


class CancerConditionViewSet(McodeModelViewSet):
serializer_class = s.CancerConditionSerializer
renderer_classes = tuple(McodeModelViewSet.renderer_classes) + (ARGORenderer,)
Expand All @@ -137,11 +136,6 @@ class TNMStagingViewSet(McodeModelViewSet):
filter_backends = [DjangoFilterBackend]
filter_class = f.TNMStagingFilter


CANCER_RELATED_PROCEDURE = (
"reason_reference",
)

def get_queryset(self):
if hasattr(self.request, "allowed_datasets"):
allowed_datasets = self.request.allowed_datasets
Expand All @@ -152,6 +146,11 @@ def get_queryset(self):
return queryset


CANCER_RELATED_PROCEDURE = (
"reason_reference",
)


class CancerRelatedProcedureViewSet(McodeModelViewSet):
serializer_class = s.CancerRelatedProcedureSerializer
renderer_classes = tuple(McodeModelViewSet.renderer_classes) + (ARGORenderer,)
Expand All @@ -174,6 +173,15 @@ class MedicationStatementViewSet(McodeModelViewSet):
filter_backends = [DjangoFilterBackend]
filter_class = f.MedicationStatementFilter

def get_queryset(self):
if hasattr(self.request, "allowed_datasets"):
allowed_datasets = self.request.allowed_datasets
queryset = m.MedicationStatement.objects\
.filter(mcodepacket__table__ownership_record__dataset__title__in=allowed_datasets)
else:
queryset = m.MedicationStatement.objects.all()
return queryset


MCODEPACKET_PREFETCH = (
"cancer_condition",
Expand All @@ -186,15 +194,6 @@ class MedicationStatementViewSet(McodeModelViewSet):
"genomics_report",
)

def get_queryset(self):
if hasattr(self.request, "allowed_datasets"):
allowed_datasets = self.request.allowed_datasets
queryset = m.MedicationStatement.objects\
.filter(mcodepacket__table__ownership_record__dataset__title__in=allowed_datasets)
else:
queryset = m.MedicationStatement.objects.all()
return queryset


class MCodePacketViewSet(McodeModelViewSet):
serializer_class = s.MCodePacketSerializer
Expand Down
2 changes: 1 addition & 1 deletion chord_metadata_service/package.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[package]
name = katsu
version = 2.6.0
version = 2.7.0
authors = Ksenia Zaytseva, David Lougheed, Simon Chénard, Romain Grégoire
2 changes: 2 additions & 0 deletions chord_metadata_service/phenopackets/api_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from rest_framework.decorators import api_view, permission_classes
from rest_framework.permissions import AllowAny
from rest_framework.response import Response
from django.utils.decorators import method_decorator
from django.views.decorators.cache import cache_page
from django_filters.rest_framework import DjangoFilterBackend

from chord_metadata_service.restapi.api_renderers import PhenopacketsRenderer, FHIRRenderer
Expand Down
141 changes: 0 additions & 141 deletions chord_metadata_service/phenopackets/tests/test_phenopackets_api.py

This file was deleted.

3 changes: 3 additions & 0 deletions chord_metadata_service/restapi/api_views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from collections import Counter

from django.views.decorators.cache import cache_page

from rest_framework.permissions import AllowAny
from rest_framework.response import Response
from rest_framework.decorators import api_view, permission_classes
Expand Down
Loading

0 comments on commit 6446b21

Please sign in to comment.