Skip to content

Commit

Permalink
feat: Update model selection descriptions (#217)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcuesta-pass authored Sep 6, 2024
1 parent 729fa61 commit 6a06900
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
from huggy.schemas.user import UserContext
from huggy.schemas.utils import parse_input
from huggy.utils.env_vars import (
DEFAULT_RECO_MODEL,
DEFAULT_RECO_MODEL_DESCRIPTION,
DEFAULT_SIMILAR_OFFER_DESCRIPTION,
DEFAULT_SIMILAR_OFFER_MODEL,
RECO_MODEL_CONTEXT,
SIMILAR_OFFER_MODEL_CONTEXT,
VERSION_B_RECO_MODEL_DESCRIPTION,
VERSION_B_SIMILAR_OFFER_DESCRIPTION,
)
from pydantic import ValidationError

Expand Down Expand Up @@ -55,7 +57,7 @@
),
"version_b": RecoModelConfigurationInput(
name="version_b",
description="""Configuration Ranking Version B.""",
description=VERSION_B_RECO_MODEL_DESCRIPTION,
diversification_params=DiversificationParamsInput(
diversication_type=DiversificationChoices.ON,
),
Expand Down Expand Up @@ -187,7 +189,7 @@
),
"version_b": SimilarModelConfigurationInput(
name="version_b",
description="""Similar offers (ranking version b).""",
description=VERSION_B_SIMILAR_OFFER_DESCRIPTION,
diversification_params=DiversificationParamsInput(
diversication_type=DiversificationChoices.OFF,
),
Expand Down Expand Up @@ -240,7 +242,7 @@ def select_reco_model_params(model_endpoint: str, user: UserContext) -> ForkOut:
model_fork = model_endpoint.custom_configuration.generate()
else:
if model_name not in list(RECOMMENDATION_ENDPOINTS.keys()):
model_name = DEFAULT_RECO_MODEL
model_name = RECO_MODEL_CONTEXT
model_fork = RECOMMENDATION_ENDPOINTS[model_name].generate()
return model_fork.get_user_status(user=user, model_origin=model_name)

Expand All @@ -259,7 +261,7 @@ def select_sim_model_params(
model_fork = model_endpoint.custom_configuration.generate()
else:
if model_name not in list(SIMILAR_OFFER_ENDPOINTS.keys()):
model_name = DEFAULT_SIMILAR_OFFER_MODEL
model_name = SIMILAR_OFFER_MODEL_CONTEXT
model_fork = SIMILAR_OFFER_ENDPOINTS[model_name].generate()
return model_fork.get_offer_status(
offer=offer, offers=offers, model_origin=model_name
Expand Down
5 changes: 2 additions & 3 deletions apps/recommendation/api/src/huggy/crud/recommendable_offer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ class RecommendableOffer:
async def is_geolocated(self, user: UserContext, offer: o.Offer) -> bool:
if user is not None and user.is_geolocated:
return True
if offer is not None and offer.is_geolocated:
return True
return False
else:
return bool(offer is not None and offer.is_geolocated)

async def get_nearest_offers(
self,
Expand Down
11 changes: 9 additions & 2 deletions apps/recommendation/api/src/huggy/utils/env_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,23 @@
http_request_context = contextvars.ContextVar("http_request_context", default={})

# config
DEFAULT_SIMILAR_OFFER_MODEL = os.environ.get("DEFAULT_SIMILAR_OFFER_MODEL", "default")
SIMILAR_OFFER_MODEL_CONTEXT = os.environ.get("SIMILAR_OFFER_MODEL_CONTEXT", "default")
RECO_MODEL_CONTEXT = os.environ.get("RECO_MODEL_CONTEXT", "default")

DEFAULT_SIMILAR_OFFER_DESCRIPTION = os.environ.get(
"DEFAULT_SIMILAR_OFFER_DESCRIPTION", "Similar Offer Configuration (default)"
)

DEFAULT_RECO_MODEL = os.environ.get("DEFAULT_RECO_MODEL", "default")
DEFAULT_RECO_MODEL_DESCRIPTION = os.environ.get(
"DEFAULT_RECO_MODEL_DESCRIPTION", "Recommendation Configuration (default)"
)

VERSION_B_RECO_MODEL_DESCRIPTION = os.environ.get(
"VERSION_B_RECO_MODEL_DESCRIPTION", "Recommendation Configuration (version B)"
)
VERSION_B_SIMILAR_OFFER_DESCRIPTION = os.environ.get(
"VERSION_B_SIMILAR_OFFER_DESCRIPTION", "Similar Offer Configuration (version B)"
)
# endpoints
RANKING_VERSION_B_ENDPOINT_NAME = os.environ.get(
"RANKING_VERSION_B_ENDPOINT_NAME",
Expand Down

0 comments on commit 6a06900

Please sign in to comment.