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 87a34384..81bcdbd4 100644 --- a/apps/api/utils.py +++ b/apps/api/utils.py @@ -1689,10 +1689,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: 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 diff --git a/tests/api_ssoft_test.py b/tests/api_ssoft_test.py index 40b67294..562933de 100644 --- a/tests/api_ssoft_test.py +++ b/tests/api_ssoft_test.py @@ -134,12 +134,18 @@ def test_schema() -> None: -------- >>> test_schema() """ - pdf = ssoftsearch() + pdf = ssoftsearch(flavor="SSHG1G2") - 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( + 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 @@ -151,10 +157,10 @@ 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)) + r = requests.get("{}/api/v1/ssoft?schema&flavor=SSHG1G2".format(APIURL)) schema2 = r.json() keys1 = set(schema1["args"].keys()) @@ -162,6 +168,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