Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1. Correct relative file location of cypher query strings for scenario when ubkg-api is invoked from hs-ontology-api 2. Fixed issue with minimum depth check in paths/expand call. #120

Merged
merged 6 commits into from
Apr 30, 2024
18 changes: 13 additions & 5 deletions src/ubkg_api/common_routes/common_neo4j_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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) \
Expand Down
11 changes: 6 additions & 5 deletions src/ubkg_api/common_routes/concepts/concepts_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/ubkg_api/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

python_dateutil >= 2.6.0
setuptools >= 21.0.0
Flask == 2.1.3
Expand Down
Loading