Skip to content

Commit

Permalink
Ensure max_runtime is in use when we check for it
Browse files Browse the repository at this point in the history
If max_runtime is not given to the LTP framework, there's a risk that it
causes TypeError exception when used. We just keep an eye on it, so we
are sure this won't happen.
  • Loading branch information
acerv committed Aug 17, 2023
1 parent e55f96c commit fe29e7d
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions libkirk/ltp.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,21 @@ def _is_addable(self, test_params: dict) -> bool:
"""
addable = True

# filter out max_runtime tests
runtime = test_params.get("max_runtime")
if runtime:
try:
runtime = float(runtime)
if runtime >= self._max_runtime:
self._logger.info(
"max_runtime is bigger than %f",
self._max_runtime)
addable = False
except TypeError:
self._logger.error(
"metadata contains wrong max_runtime type: %s",
runtime)
# filter out max_runtime tests when required
if self._max_runtime:
runtime = test_params.get("max_runtime")
if runtime:
try:
runtime = float(runtime)
if runtime >= self._max_runtime:
self._logger.info(
"max_runtime is bigger than %f",
self._max_runtime)
addable = False
except TypeError:
self._logger.error(
"metadata contains wrong max_runtime type: %s",
runtime)

return addable

Expand Down

0 comments on commit fe29e7d

Please sign in to comment.