diff --git a/.dockerignore b/.dockerignore index 5f4aa653c1..e6db845c25 100644 --- a/.dockerignore +++ b/.dockerignore @@ -5,6 +5,7 @@ static/* !static/images/* deploy/* !deploy/docker/seqr/* +hail_search/* .git .vscode .idea diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index c01a540f30..0cb64c863d 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -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 diff --git a/hail_search/__init__.py b/hail_search/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/hail_search/__main__.py b/hail_search/__main__.py new file mode 100644 index 0000000000..6b08495110 --- /dev/null +++ b/hail_search/__main__.py @@ -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 + port=5000, + access_log_format='%{From}i "%r" %s %Tfs', + ) + + +run() diff --git a/hail_search/requirements-test.in b/hail_search/requirements-test.in new file mode 100644 index 0000000000..245d0d3637 --- /dev/null +++ b/hail_search/requirements-test.in @@ -0,0 +1,2 @@ +coverage<5.2 +pytest-aiohttp diff --git a/hail_search/requirements-test.txt b/hail_search/requirements-test.txt new file mode 100644 index 0000000000..e15b9abad2 --- /dev/null +++ b/hail_search/requirements-test.txt @@ -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 diff --git a/hail_search/test_search.py b/hail_search/test_search.py new file mode 100644 index 0000000000..1daad2bd33 --- /dev/null +++ b/hail_search/test_search.py @@ -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}) diff --git a/hail_search/web_app.py b/hail_search/web_app.py new file mode 100644 index 0000000000..0415bd83a2 --- /dev/null +++ b/hail_search/web_app.py @@ -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