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

Add hail backend - intitial status check #3480

Merged
merged 8 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ static/*
!static/images/*
deploy/*
!deploy/docker/seqr/*
hail_search/*
.git
.vscode
.idea
15 changes: 15 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,21 @@ jobs:
coverage run --source="./matchmaker","./seqr","./reference_data","./panelapp" --omit="*/migrations/*","*/apps.py" manage.py test -p '*_tests.py' -v 2 reference_data seqr matchmaker panelapp
coverage report --fail-under=99

hail_search:
runs-on: ubuntu-latest
container: hailgenetics/hail:0.2.115

steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip wheel
pip install -r hail_search/requirements-test.txt
- name: Run coverage tests
run: |
coverage run --source="./hail_search" --omit="./hail_search/__main__.py" -m pytest hail_search/
coverage report --fail-under=99

nodejs:
runs-on: ubuntu-latest

Expand Down
Empty file added hail_search/__init__.py
Empty file.
16 changes: 16 additions & 0 deletions hail_search/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from aiohttp import web

from hail_search.web_app import init_web_app


def run():
app = init_web_app()
web.run_app(
app,
host='0.0.0.0', # nosec
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like a backend service web app without authentication support. It should not be accessible from external.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Correct. The hail backend service will only be accessible via an internal, unauthenticated kubernetes service, so that only seqr can access it. Actually setting up the deployment is out of scope of this PR, but you can see the kubernetes yaml that I used to get this working in a test environment here: https://github.com/broadinstitute/seqr/blob/62084009dd60a35eef1c85608ad0c8a3e2a90cf8/deploy/kubectl_helpers/utils/hail-search.yaml

port=5000,
access_log_format='%{From}i "%r" %s %Tfs',
)


run()
2 changes: 2 additions & 0 deletions hail_search/requirements-test.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
coverage<5.2
pytest-aiohttp
48 changes: 48 additions & 0 deletions hail_search/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#
# This file is autogenerated by pip-compile with Python 3.9
# To update, run:
#
# pip-compile hail_search/requirements-test.in
#
aiohttp==3.8.4
# via pytest-aiohttp
aiosignal==1.3.1
# via aiohttp
async-timeout==4.0.2
# via aiohttp
attrs==23.1.0
# via aiohttp
charset-normalizer==3.2.0
# via aiohttp
coverage==5.1
# via -r hail_search/requirements-test.in
exceptiongroup==1.1.2
# via pytest
frozenlist==1.3.3
# via
# aiohttp
# aiosignal
idna==3.4
# via yarl
iniconfig==2.0.0
# via pytest
multidict==6.0.4
# via
# aiohttp
# yarl
packaging==23.1
# via pytest
pluggy==1.2.0
# via pytest
pytest==7.4.0
# via
# pytest-aiohttp
# pytest-asyncio
pytest-aiohttp==1.0.4
# via -r hail_search/requirements-test.in
pytest-asyncio==0.21.0
# via pytest-aiohttp
tomli==2.0.1
# via pytest
yarl==1.9.2
# via aiohttp
15 changes: 15 additions & 0 deletions hail_search/test_search.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from aiohttp.test_utils import AioHTTPTestCase

from hail_search.web_app import init_web_app


class HailSearchTestCase(AioHTTPTestCase):

async def get_application(self):
return init_web_app()

async def test_status(self):
async with self.client.request('GET', '/status') as resp:
self.assertEqual(resp.status, 200)
resp_json = await resp.json()
self.assertDictEqual(resp_json, {'success': True})
17 changes: 17 additions & 0 deletions hail_search/web_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from aiohttp import web
import hail as hl
import logging


async def status(request: web.Request) -> web.Response:
return web.json_response({'success': True})


def init_web_app():
logging.basicConfig(level=logging.INFO)
hl.init()
app = web.Application()
app.add_routes([
web.get('/status', status),
])
return app