From 6ce744a7016213c66467db31715cf708b735c0fc Mon Sep 17 00:00:00 2001 From: Hana Snow Date: Tue, 11 Jul 2023 13:20:40 -0400 Subject: [PATCH 1/8] add hail search status endpoint --- hail_search/__init__.py | 0 hail_search/__main__.py | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 hail_search/__init__.py create mode 100644 hail_search/__main__.py 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..6187dc58ef --- /dev/null +++ b/hail_search/__main__.py @@ -0,0 +1,25 @@ +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 run(): + logging.basicConfig(level=logging.INFO) + hl.init() + app = web.Application() + app.add_routes([ + web.get('/status', status), + ]) + web.run_app( + app, + host='0.0.0.0', + port=5000, + access_log_format='%{From}i "%r" %s %Tfs', + ) + + +run() From 1c0d17362898beb0024db86de59047b1a8bd6a6d Mon Sep 17 00:00:00 2001 From: Hana Snow Date: Tue, 11 Jul 2023 14:48:13 -0400 Subject: [PATCH 2/8] add unit tests --- .github/workflows/unit-tests.yml | 21 ++++++++++++++ hail_search/__main__.py | 11 ++----- hail_search/requirements-test.in | 2 ++ hail_search/requirements-test.txt | 48 +++++++++++++++++++++++++++++++ hail_search/test_search.py | 15 ++++++++++ hail_search/web_app.py | 17 +++++++++++ 6 files changed, 105 insertions(+), 9 deletions(-) create mode 100644 hail_search/requirements-test.in create mode 100644 hail_search/requirements-test.txt create mode 100644 hail_search/test_search.py create mode 100644 hail_search/web_app.py diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index c01a540f30..72e8d4dd61 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -63,6 +63,27 @@ 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: + - name: Use pip cache + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: pip-${{ hashFiles('**/hail_search/requirements-test.txt') }} + restore-keys: | + pip- + - name: Install dependencies + run: | + python -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/__main__.py b/hail_search/__main__.py index 6187dc58ef..19e308d852 100644 --- a/hail_search/__main__.py +++ b/hail_search/__main__.py @@ -2,18 +2,11 @@ import hail as hl import logging - -async def status(request: web.Request) -> web.Response: - return web.json_response({'success': True}) +from hail_search.web_app import init_web_app def run(): - logging.basicConfig(level=logging.INFO) - hl.init() - app = web.Application() - app.add_routes([ - web.get('/status', status), - ]) + app = init_web_app() web.run_app( app, host='0.0.0.0', 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..d662d6a3eb --- /dev/null +++ b/hail_search/requirements-test.txt @@ -0,0 +1,48 @@ +# +# This file is autogenerated by pip-compile with python 3.10 +# 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..7725eb5cd1 --- /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}) \ No newline at end of file diff --git a/hail_search/web_app.py b/hail_search/web_app.py new file mode 100644 index 0000000000..7d86d8f991 --- /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 From 31b1204c928e80abb31fb57b4b17d4c494831c3a Mon Sep 17 00:00:00 2001 From: Hana Snow Date: Tue, 11 Jul 2023 14:51:01 -0400 Subject: [PATCH 3/8] add hail to test --- hail_search/requirements-test.txt | 2 +- hail_search/test_search.py | 2 +- hail_search/web_app.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hail_search/requirements-test.txt b/hail_search/requirements-test.txt index d662d6a3eb..e15b9abad2 100644 --- a/hail_search/requirements-test.txt +++ b/hail_search/requirements-test.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile with python 3.10 +# This file is autogenerated by pip-compile with Python 3.9 # To update, run: # # pip-compile hail_search/requirements-test.in diff --git a/hail_search/test_search.py b/hail_search/test_search.py index 7725eb5cd1..1daad2bd33 100644 --- a/hail_search/test_search.py +++ b/hail_search/test_search.py @@ -12,4 +12,4 @@ 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}) \ No newline at end of file + self.assertDictEqual(resp_json, {'success': True}) diff --git a/hail_search/web_app.py b/hail_search/web_app.py index 7d86d8f991..0415bd83a2 100644 --- a/hail_search/web_app.py +++ b/hail_search/web_app.py @@ -9,7 +9,7 @@ async def status(request: web.Request) -> web.Response: def init_web_app(): logging.basicConfig(level=logging.INFO) - #hl.init() + hl.init() app = web.Application() app.add_routes([ web.get('/status', status), From 39f7289cef9c9f3af5adb8adec37bc631d97ac40 Mon Sep 17 00:00:00 2001 From: Hana Snow Date: Tue, 11 Jul 2023 14:51:43 -0400 Subject: [PATCH 4/8] fix python name --- .github/workflows/unit-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 72e8d4dd61..eec3b08c1d 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -55,7 +55,7 @@ jobs: pip- - name: Install dependencies run: | - python -m pip install --upgrade pip wheel + python3 -m pip install --upgrade pip wheel pip install -r requirements.txt pip install -r requirements-dev.txt - name: Run coverage tests From ab4283884bde254f9f24b80fa7cb489c5f23e353 Mon Sep 17 00:00:00 2001 From: Hana Snow Date: Tue, 11 Jul 2023 14:52:19 -0400 Subject: [PATCH 5/8] actually fix python name --- .github/workflows/unit-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index eec3b08c1d..1a8e2d045b 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -55,7 +55,7 @@ jobs: pip- - name: Install dependencies run: | - python3 -m pip install --upgrade pip wheel + python -m pip install --upgrade pip wheel pip install -r requirements.txt pip install -r requirements-dev.txt - name: Run coverage tests @@ -77,7 +77,7 @@ jobs: pip- - name: Install dependencies run: | - python -m pip install --upgrade pip wheel + python3 -m pip install --upgrade pip wheel pip install -r hail_search/requirements-test.txt - name: Run coverage tests run: | From 84e6bf9b714d98768b65bb2bcb34acf1cfded8dd Mon Sep 17 00:00:00 2001 From: Hana Snow Date: Tue, 11 Jul 2023 14:55:14 -0400 Subject: [PATCH 6/8] checkout code --- .github/workflows/unit-tests.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 1a8e2d045b..0cb64c863d 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -68,13 +68,7 @@ jobs: container: hailgenetics/hail:0.2.115 steps: - - name: Use pip cache - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: pip-${{ hashFiles('**/hail_search/requirements-test.txt') }} - restore-keys: | - pip- + - uses: actions/checkout@v2 - name: Install dependencies run: | python3 -m pip install --upgrade pip wheel From 31bfc0d9f042e6d0f0cc1ca1765df9abaf979499 Mon Sep 17 00:00:00 2001 From: Hana Snow Date: Tue, 11 Jul 2023 14:59:33 -0400 Subject: [PATCH 7/8] add docker ignore --- .dockerignore | 1 + 1 file changed, 1 insertion(+) 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 From f5aacfc99c11ecdbe95e530a1250fa51f67ac227 Mon Sep 17 00:00:00 2001 From: Hana Snow Date: Tue, 11 Jul 2023 15:16:43 -0400 Subject: [PATCH 8/8] codacy fixes --- hail_search/__main__.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hail_search/__main__.py b/hail_search/__main__.py index 19e308d852..6b08495110 100644 --- a/hail_search/__main__.py +++ b/hail_search/__main__.py @@ -1,6 +1,4 @@ from aiohttp import web -import hail as hl -import logging from hail_search.web_app import init_web_app @@ -9,7 +7,7 @@ def run(): app = init_web_app() web.run_app( app, - host='0.0.0.0', + host='0.0.0.0', # nosec port=5000, access_log_format='%{From}i "%r" %s %Tfs', )