diff --git a/src/ubkg_api/common_routes/common_neo4j_logic.py b/src/ubkg_api/common_routes/common_neo4j_logic.py index 501bf05..e623d21 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 @@ -53,12 +56,18 @@ def loadquerystring(filename: str) -> str: :param filename: filename, without path. - Assumes that the file is in the cypher directory. + 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()) - 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.parent + fpath = os.path.join(fpath,'cypher',filename) f = open(fpath, "r") query = f.read() f.close() @@ -311,8 +320,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) \ 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) 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