Skip to content

Commit

Permalink
Merge pull request #333 from aurelio-labs/james/route-delete-hotfix
Browse files Browse the repository at this point in the history
fix: more permissive deletes
  • Loading branch information
jamescalam authored Jun 20, 2024
2 parents 3c7d1fc + fca53a6 commit 8e6966e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "semantic-router"
version = "0.0.47"
version = "0.0.48"
description = "Super fast semantic router for AI decision making"
authors = [
"James Briggs <james@aurelio.ai>",
Expand Down
6 changes: 3 additions & 3 deletions semantic_router/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,9 @@ def delete(self, route_name: str):
:type str:
"""
if route_name not in [route.name for route in self.routes]:
err_msg = f"Route `{route_name}` not found"
logger.error(err_msg)
raise ValueError(err_msg)
err_msg = f"Route `{route_name}` not found in RouteLayer"
logger.warning(err_msg)
self.index.delete(route_name=route_name)
else:
self.routes = [route for route in self.routes if route.name != route_name]
self.index.delete(route_name=route_name)
Expand Down
7 changes: 2 additions & 5 deletions tests/unit/test_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,8 @@ def test_remove_route_not_found(self, openai_encoder, routes, index_cls):
)
# Attempt to remove a route that does not exist
non_existent_route = "non-existent-route"
with pytest.raises(ValueError) as excinfo:
route_layer.delete(non_existent_route)
assert (
str(excinfo.value) == f"Route `{non_existent_route}` not found"
), "Attempting to remove a non-existent route should raise a ValueError."
route_layer.delete(non_existent_route)
# we should see warning in logs only (ie no errors)

def test_add_multiple_routes(self, openai_encoder, routes, index_cls):
route_layer = RouteLayer(encoder=openai_encoder, index=index_cls())
Expand Down

0 comments on commit 8e6966e

Please sign in to comment.