From 2286f0eaeb55d34b32cb7e176f3d3e4b426198fb Mon Sep 17 00:00:00 2001 From: AlanSimmons Date: Thu, 25 Apr 2024 08:24:55 -0500 Subject: [PATCH 1/6] Corrected order of range check in expand endpoint. --- .../common_routes/concepts/concepts_controller.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/ubkg_api/common_routes/concepts/concepts_controller.py b/src/ubkg_api/common_routes/concepts/concepts_controller.py index e63ae68..48d34b0 100644 --- a/src/ubkg_api/common_routes/concepts/concepts_controller.py +++ b/src/ubkg_api/common_routes/concepts/concepts_controller.py @@ -136,17 +136,18 @@ def concepts_paths_expand_get(concept_id): if err != 'ok': return make_response(err, 400) + # APR 2024 - Check range after setting defaults. + # Set default mininum. + mindepth = set_default_minimum(param_value=mindepth, default=1) + # Set default maximum. + maxdepth = str(int(mindepth) + 2) + # Validate that mindepth is not greater than maxdepth. err = validate_parameter_range_order(min_name='mindepth', min_value=mindepth, max_name='maxdepth', max_value=maxdepth) if err != 'ok': return make_response(err, 400) - # Set default mininum. - mindepth = set_default_minimum(param_value=mindepth, default=1) - # Set default maximum. - maxdepth = str(int(mindepth) + 2) - # Check that the non-default skip is non-negative. skip = request.args.get('skip') err = validate_parameter_is_nonnegative(param_name='skip', param_value=skip) From bfba6e7ba1469a5deb1b394b9d3836a8adadc251 Mon Sep 17 00:00:00 2001 From: AlanSimmons Date: Thu, 25 Apr 2024 10:32:26 -0500 Subject: [PATCH 2/6] Corrected order of range check in expand endpoint. --- src/ubkg_api/common_routes/common_neo4j_logic.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ubkg_api/common_routes/common_neo4j_logic.py b/src/ubkg_api/common_routes/common_neo4j_logic.py index 501bf05..b16d208 100644 --- a/src/ubkg_api/common_routes/common_neo4j_logic.py +++ b/src/ubkg_api/common_routes/common_neo4j_logic.py @@ -311,8 +311,7 @@ def concepts_expand_get_logic(neo4j_instance, query_concept_id=None, sab=None, r # Set timeout for query based on value in app.cfg. query = neo4j.Query(text=querytxt, timeout=neo4j_instance.timeout) - return get_graph(neo4j_instance, query=query) - + return get_graph(neo4j_instance, query=querytxt) def concepts_shortestpath_get_logic(neo4j_instance, origin_concept_id=None, terminus_concept_id=None, sab=None, rel=None) \ From 545b9d1ec30c95c70a18261addf090626f442387 Mon Sep 17 00:00:00 2001 From: AlanSimmons Date: Thu, 25 Apr 2024 11:01:09 -0500 Subject: [PATCH 3/6] Corrected relative file path for cypher loading when the ubkg-api is called from the hs-ontology-api. --- src/ubkg_api/common_routes/common_neo4j_logic.py | 9 +++++++-- src/ubkg_api/requirements.txt | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ubkg_api/common_routes/common_neo4j_logic.py b/src/ubkg_api/common_routes/common_neo4j_logic.py index b16d208..b34af24 100644 --- a/src/ubkg_api/common_routes/common_neo4j_logic.py +++ b/src/ubkg_api/common_routes/common_neo4j_logic.py @@ -15,6 +15,9 @@ from typing import List import os +# Apr 2024 +from pathlib import Path + import neo4j from models.codes_codes_obj import CodesCodesObj @@ -56,9 +59,11 @@ def loadquerystring(filename: str) -> str: Assumes that the file is in the cypher directory. """ - fpath = os.path.dirname(os.getcwd()) - fpath = os.path.join(fpath, 'ubkg_api/cypher', filename) + #fpath = os.path.dirname(os.getcwd()) + #fpath = os.path.join(fpath, 'ubkg_api/cypher', filename) + fpath = Path(__file__).resolve().parent + fpath = os.path.join(fpath,'cypher',filename) f = open(fpath, "r") query = f.read() f.close() diff --git a/src/ubkg_api/requirements.txt b/src/ubkg_api/requirements.txt index 35952de..afd1a72 100644 --- a/src/ubkg_api/requirements.txt +++ b/src/ubkg_api/requirements.txt @@ -1,3 +1,4 @@ + python_dateutil >= 2.6.0 setuptools >= 21.0.0 Flask == 2.1.3 From d8e0edfc0cc085330a87762e751a7bdf2e38f9bf Mon Sep 17 00:00:00 2001 From: AlanSimmons Date: Thu, 25 Apr 2024 11:08:42 -0500 Subject: [PATCH 4/6] Corrected relative file path for cypher loading when the ubkg-api is called from the hs-ontology-api. --- src/ubkg_api/common_routes/common_neo4j_logic.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ubkg_api/common_routes/common_neo4j_logic.py b/src/ubkg_api/common_routes/common_neo4j_logic.py index b34af24..7997c3e 100644 --- a/src/ubkg_api/common_routes/common_neo4j_logic.py +++ b/src/ubkg_api/common_routes/common_neo4j_logic.py @@ -64,6 +64,7 @@ def loadquerystring(filename: str) -> str: fpath = Path(__file__).resolve().parent fpath = os.path.join(fpath,'cypher',filename) + print(f'UBKG: path = {fpath}') f = open(fpath, "r") query = f.read() f.close() From 1011571f7122a34ae5837d9733bd30184ef9098a Mon Sep 17 00:00:00 2001 From: AlanSimmons Date: Thu, 25 Apr 2024 11:42:08 -0500 Subject: [PATCH 5/6] Corrected relative file path for cypher loading when the ubkg-api is called from the hs-ontology-api. --- src/ubkg_api/common_routes/common_neo4j_logic.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ubkg_api/common_routes/common_neo4j_logic.py b/src/ubkg_api/common_routes/common_neo4j_logic.py index 7997c3e..0385beb 100644 --- a/src/ubkg_api/common_routes/common_neo4j_logic.py +++ b/src/ubkg_api/common_routes/common_neo4j_logic.py @@ -56,15 +56,14 @@ def loadquerystring(filename: str) -> str: :param filename: filename, without path. - Assumes that the file is in the cypher directory. + Assumes that the file is in the cypher subdirectory, which is at the same level as the script path. """ #fpath = os.path.dirname(os.getcwd()) #fpath = os.path.join(fpath, 'ubkg_api/cypher', filename) - fpath = Path(__file__).resolve().parent + fpath = Path(__file__).resolve().parent.parent fpath = os.path.join(fpath,'cypher',filename) - print(f'UBKG: path = {fpath}') f = open(fpath, "r") query = f.read() f.close() From 765d1e68985cc8b3af878c1fce913725f8c6fd48 Mon Sep 17 00:00:00 2001 From: AlanSimmons Date: Thu, 25 Apr 2024 11:43:30 -0500 Subject: [PATCH 6/6] Corrected relative file path for cypher loading when the ubkg-api is called from the hs-ontology-api. --- src/ubkg_api/common_routes/common_neo4j_logic.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ubkg_api/common_routes/common_neo4j_logic.py b/src/ubkg_api/common_routes/common_neo4j_logic.py index 0385beb..e623d21 100644 --- a/src/ubkg_api/common_routes/common_neo4j_logic.py +++ b/src/ubkg_api/common_routes/common_neo4j_logic.py @@ -56,7 +56,11 @@ def loadquerystring(filename: str) -> str: :param filename: filename, without path. + APRIL 2024 Assumes that the file is in the cypher subdirectory, which is at the same level as the script path. + When ubkg-api endpoints are called as passthrough from hs-ontology api, the script path is in hs-ontology-api. + + """ #fpath = os.path.dirname(os.getcwd())