From 4cb73fe5bb5d0f138e79fe0cf4d63074e20fb183 Mon Sep 17 00:00:00 2001 From: JulienPeloton Date: Thu, 24 Oct 2024 09:08:53 +0200 Subject: [PATCH 1/6] Enable SSHG1G2 to be downloaded --- apps/api/api.py | 9 ++++++--- apps/api/utils.py | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/apps/api/api.py b/apps/api/api.py index 3f7b8edf..ce7dd9f0 100644 --- a/apps/api/api.py +++ b/apps/api/api.py @@ -21,6 +21,7 @@ COLUMNS_HG, COLUMNS_HG1G2, COLUMNS_SHG1G2, + COLUMNS_SSHG1G2, ) from fink_utils.xmatch.simbad import get_simbad_labels from flask import Blueprint, Response, jsonify, request @@ -588,7 +589,7 @@ def layout(): { "name": "flavor", "required": False, - "description": "Data model among SHG1G2 (default), HG1G2, HG.", + "description": "Data model among SSHG1G2, SHG1G2 (default), HG1G2, HG.", }, { "name": "version", @@ -1529,12 +1530,14 @@ def ssoft_table(payload=None): if "schema" in payload: if "flavor" in payload: flavor = payload["flavor"] - if flavor not in ["SHG1G2", "HG1G2", "HG"]: + if flavor not in ["SSHG1G2", "SHG1G2", "HG1G2", "HG"]: rep = { "status": "error", - "text": "flavor needs to be in ['SHG1G2', 'HG1G2', 'HG']\n", + "text": "flavor needs to be in ['SSHG1G2', 'SHG1G2', 'HG1G2', 'HG']\n", } return Response(str(rep), 400) + elif flavor == "SSHG1G2": + ssoft_columns = {**COLUMNS, **COLUMNS_SSHG1G2} elif flavor == "SHG1G2": ssoft_columns = {**COLUMNS, **COLUMNS_SHG1G2} elif flavor == "HG1G2": diff --git a/apps/api/utils.py b/apps/api/utils.py index 7b6d3573..3ae822ad 100644 --- a/apps/api/utils.py +++ b/apps/api/utils.py @@ -1676,10 +1676,10 @@ def return_ssoft_pdf(payload: dict) -> pd.DataFrame: if "flavor" in payload: flavor = payload["flavor"] - if flavor not in ["SHG1G2", "HG1G2", "HG"]: + if flavor not in ["SSHG1G2", "SHG1G2", "HG1G2", "HG"]: rep = { "status": "error", - "text": "flavor needs to be in ['SHG1G2', 'HG1G2', 'HG']\n", + "text": "flavor needs to be in ['SSHG1G2', 'SHG1G2', 'HG1G2', 'HG']\n", } return Response(str(rep), 400) else: From da16512a4ae0b78d753faf5afd30f8f1c796f3a3 Mon Sep 17 00:00:00 2001 From: JulienPeloton Date: Thu, 24 Oct 2024 11:44:12 +0200 Subject: [PATCH 2/6] Update test --- tests/api_ssoft_test.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/api_ssoft_test.py b/tests/api_ssoft_test.py index 40b67294..7861168d 100644 --- a/tests/api_ssoft_test.py +++ b/tests/api_ssoft_test.py @@ -162,6 +162,18 @@ def compare_schema() -> None: assert keys1 == keys2, [keys1, keys2] +def check_sshg1g2() -> None: + """ + Examples + -------- + >>> check_sshg1g2() + """ + pdf = ssoftsearch(flavor="SSHG1G2") + + assert "period" in pdf.columns + assert "a_b" in pdf.columns + + if __name__ == "__main__": """ Execute the test suite """ import sys From b15a5e53e9d1ef343c50f27f203082abfc5c6aee Mon Sep 17 00:00:00 2001 From: JulienPeloton Date: Thu, 24 Oct 2024 12:40:58 +0200 Subject: [PATCH 3/6] Test schema for SSHG1G2 --- tests/api_ssoft_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/api_ssoft_test.py b/tests/api_ssoft_test.py index 7861168d..6354abf4 100644 --- a/tests/api_ssoft_test.py +++ b/tests/api_ssoft_test.py @@ -136,7 +136,7 @@ def test_schema() -> None: """ pdf = ssoftsearch() - schema = ssoftsearch(schema=True, output_format="json") + schema = ssoftsearch(schema=True, flavor="SSHG1G2", output_format="json") # check columns msg = "Found {} entries in the DataFrame and {} entries in the schema".format( @@ -151,7 +151,7 @@ def compare_schema() -> None: -------- >>> compare_schema() """ - schema1 = ssoftsearch(schema=True, output_format="json") + schema1 = ssoftsearch(schema=True, flavor="SSHG1G2", output_format="json") # get the schema r = requests.get("{}/api/v1/ssoft?schema".format(APIURL)) From c389209a238af32aff2480cdc88979bf35e749e5 Mon Sep 17 00:00:00 2001 From: JulienPeloton Date: Thu, 24 Oct 2024 12:56:02 +0200 Subject: [PATCH 4/6] Fix test --- tests/api_ssoft_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/api_ssoft_test.py b/tests/api_ssoft_test.py index 6354abf4..26d4ed6a 100644 --- a/tests/api_ssoft_test.py +++ b/tests/api_ssoft_test.py @@ -134,7 +134,7 @@ def test_schema() -> None: -------- >>> test_schema() """ - pdf = ssoftsearch() + pdf = ssoftsearch(flavor="SSHG1G2") schema = ssoftsearch(schema=True, flavor="SSHG1G2", output_format="json") @@ -154,7 +154,7 @@ def compare_schema() -> None: schema1 = ssoftsearch(schema=True, flavor="SSHG1G2", output_format="json") # get the schema - r = requests.get("{}/api/v1/ssoft?schema".format(APIURL)) + r = requests.get("{}/api/v1/ssoft?schema&flavor=SSHG1G2".format(APIURL)) schema2 = r.json() keys1 = set(schema1["args"].keys()) From 8ef86cba103babf73238c885f364f5ece0cd3818 Mon Sep 17 00:00:00 2001 From: JulienPeloton Date: Thu, 24 Oct 2024 14:23:31 +0200 Subject: [PATCH 5/6] Expand test --- tests/api_ssoft_test.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/api_ssoft_test.py b/tests/api_ssoft_test.py index 26d4ed6a..562933de 100644 --- a/tests/api_ssoft_test.py +++ b/tests/api_ssoft_test.py @@ -139,7 +139,13 @@ def test_schema() -> None: schema = ssoftsearch(schema=True, flavor="SSHG1G2", output_format="json") # check columns - msg = "Found {} entries in the DataFrame and {} entries in the schema".format( + not_in_pdf = [i for i in set(schema["args"].keys()) if i not in set(pdf.columns)] + not_in_schema = [i for i in set(pdf.columns) if i not in set(schema["args"].keys())] + + assert not_in_pdf == [], not_in_pdf + assert not_in_schema == [], not_in_schema + + msg = "Found {} entries in the DataFrame and {} entries in the schema.".format( len(pdf.columns), len(schema) ) assert set(schema["args"].keys()) == set(pdf.columns), msg From 502a0756e1113b248a053c23f48e2f657f8970f2 Mon Sep 17 00:00:00 2001 From: JulienPeloton Date: Fri, 25 Oct 2024 16:20:59 +0200 Subject: [PATCH 6/6] Update requirements --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 834fd79b..f55548e2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -46,7 +46,7 @@ emcee==3.1.4 faust-cchardet==2.1.19 fink-filters==3.35 fink-spins==0.3.7 -fink-utils==0.28.0 +fink-utils==0.29.5 Flask==3.0.1 fonttools==4.47.2 frozenlist==1.4.1 @@ -159,4 +159,4 @@ Werkzeug==3.0.1 wrapt==1.16.0 yarl==1.9.4 zipp==3.17.0 -git+https://github.com/astrolabsoftware/fink-science@5.21.1 +git+https://github.com/astrolabsoftware/fink-science@5.21.3