Skip to content

Commit

Permalink
bumping transpiler and adding error checking to prevent config/env va…
Browse files Browse the repository at this point in the history
…r related results_limit and subclass_depth bugs
  • Loading branch information
EvanDietzMorris committed Apr 22, 2024
1 parent 10266e2 commit 6c6752d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion PLATER/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pyaml==20.4.0
pytest==7.4.3
pytest-asyncio==0.21.1
uvicorn==0.24.0
reasoner-transpiler==2.0.11
reasoner-transpiler==2.0.12
reasoner-pydantic==5.0.0
httpx==0.25.1
pytest-httpx==0.26.0
Expand Down
18 changes: 16 additions & 2 deletions PLATER/services/util/question.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ def __init__(self, question_json):
self._question_json = copy.deepcopy(question_json)

self.plater_provenance = config.get('PROVENANCE_TAG', 'infores:plater.notspecified')
self.results_limit = config.get('RESULTS_LIMIT', None)
self.subclass_depth = config.get('SUBCLASS_DEPTH', None)
self.results_limit = self.get_positive_int_from_config('RESULTS_LIMIT', None)
self.subclass_depth = self.get_positive_int_from_config('SUBCLASS_DEPTH', 1)

def compile_cypher(self, **kwargs):
query_graph = copy.deepcopy(self._question_json[Question.QUERY_GRAPH_KEY])
Expand Down Expand Up @@ -383,3 +383,17 @@ def transform_schema_to_question_template(graph_schema):
question_templates.append({Question.QUERY_GRAPH_KEY: question_graph})
return question_templates

@staticmethod
def get_positive_int_from_config(config_var_name: str, default=None):
config_var = config.get(config_var_name, None)
if config_var is not None and config_var != "":
try:
config_int = int(config_var)
if config_int >= 0:
return config_int
else:
logger.warning(f'Negative value provided for {config_var_name}: {config_var}, using default {default}')
except ValueError:
logger.warning(f'Invalid value provided for {config_var_name}: {config_var}, using default {default}')
return default

2 changes: 1 addition & 1 deletion PLATER/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

setup(
name='PLATER',
version='v1.6.3',
version='v1.6.4',
packages=find_packages(),
)

0 comments on commit 6c6752d

Please sign in to comment.