Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
vbusson-pass committed Nov 28, 2024
1 parent 333f367 commit 78e956e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,9 @@ async def model_score(self) -> list[RecommendableItem]:
await VERTEX_CACHE.set(cache_key, result)
self._log_cache_usage(cache_key, "Set")
except Exception as e:
logger.error(f"Failed to set cache for {cache_key}: {e}", exc_info=True)
logger.error(
f"Failed to set cache for {cache_key}: {e}", exc_info=True
)

# Check result before accessing attributes
if result is None:
Expand Down
11 changes: 8 additions & 3 deletions apps/recommendation/api/src/huggy/core/scorer/offer.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,21 @@ async def get_recommendable_offers(
try:
await OFFER_DB_CACHE.set(cache_key, result)
except Exception as e:
logger.error(f"Failed to set cache for {cache_key}: {e}", exc_info=True)
logger.error(
f"Failed to set cache for {cache_key}: {e}", exc_info=True
)

# Check result and its recommendable_offer attribute
if result is None or not hasattr(result, "recommendable_offer") or result.recommendable_offer is None:
if (
result is None
or not hasattr(result, "recommendable_offer")
or result.recommendable_offer is None
):
logger.error("Recommendable offers could not be retrieved.")
return []

return result.recommendable_offer


async def get_distance(
self,
item: i.RecommendableItem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ async def test_offer_distance(

# Sort the results for comparison
result_offers = sorted(result_offers, key=lambda x: x.offer_id, reverse=True)
expected_offers = sorted(expected_offers, key=lambda x: x.offer_id, reverse=True)
expected_offers = sorted(
expected_offers, key=lambda x: x.offer_id, reverse=True
)

# Assert that the list sizes match
assert len(result_offers) == len(
Expand Down

0 comments on commit 78e956e

Please sign in to comment.