Skip to content
Snippets Groups Projects
Unverified Commit baa5e3fe authored by Siraj R Aizlewood's avatar Siraj R Aizlewood
Browse files

Fixed PyTest Fail

The test

TestRouteLayer::test_query_with_no_index

was failing because when it ran

assert route_layer("Anything").name is None

There were no Routes defined yet, and this meant that

route = [route for route in self.routes if route.name == top_class][0] was raising an error.

If no routes are defined then we can just defualt to RouteChoice().
parent 44f81658
Branches
Tags
No related merge requests found
...@@ -186,7 +186,11 @@ class RouteLayer: ...@@ -186,7 +186,11 @@ class RouteLayer:
results = self._query(text) results = self._query(text)
top_class, top_class_scores = self._semantic_classify(results) top_class, top_class_scores = self._semantic_classify(results)
# get chosen route object # get chosen route object
route = [route for route in self.routes if route.name == top_class][0] matching_routes = [route for route in self.routes if route.name == top_class]
if not matching_routes:
logger.error(f"No route found with name {top_class}. Check to see if any Routes have been defined.")
return RouteChoice()
route = matching_routes[0]
threshold = ( threshold = (
route.score_threshold route.score_threshold
if route.score_threshold is not None if route.score_threshold is not None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment