aws-samples/personalization-apis

Using a lambda function as a recommender variation for an experiment gives an error

Closed this issue · 1 comments

a13z commented

Hello,

I'm trying to setup an A/B testing with Evidently using 2 variations, one coming from AWS personalize and the other with a lambda function to serve a custom and non personalised response of items. Evidently has a feature and experiment with two variations that matches the names of the variations specified in the Personalization APIs configuration.

It seems based on the Personalization APIs lambda logs that the mapping between the Evidently and the Personalization APIs config works fine.

The problem I'm facing is when the path goes to the lambda function I got the following exception:

{
  "type": "Unhandled",
  "code": "InternalError",
  "message": "'path'",
  "details": [
    "Traceback (most recent call last):",
    "  File \"/var/task/main.py\", line 590, in lambda_handler",
    "    return app.resolve(event, context)",
    "  File \"/opt/python/aws_lambda_powertools/event_handler/api_gateway.py\", line 498, in resolve",
    "    return self._resolve().build(self.current_event, self._cors)",
    "  File \"/opt/python/aws_lambda_powertools/event_handler/api_gateway.py\", line 557, in _resolve",
    "    return self._call_route(route, match_results.groupdict())  # pass fn args",
    "  File \"/opt/python/aws_lambda_powertools/event_handler/api_gateway.py\", line 611, in _call_route",
    "    return ResponseBuilder(self._to_response(route.func(**args)), route)",
    "  File \"/opt/python/aws_lambda_powertools/tracing/tracer.py\", line 632, in decorate",
    "    response = method(*args, **kwargs)",
    "  File \"/var/task/main.py\", line 304, in get_recommend_items",
    "    response = lambda_resolver.get_recommend_items(",
    "  File \"/opt/python/aws_lambda_powertools/tracing/tracer.py\", line 632, in decorate",
    "    response = method(*args, **kwargs)",
    "  File \"/var/task/lambda_resolver.py\", line 57, in get_recommend_items",
    "    'path': recommender_config['path']",
    "KeyError: 'path'"
  ]
}

It seems a path key is expected in the recommender_config dict but I don't really know what is expected to add in that path in here


I couldn't find that path key in the schema either.

Could anyone help me out and let me know what and where should I add that path key please?

Many thanks in advance.

Based on initial investigation, this looks to be caused by logic from the initial design for the configuration that was refactored before the project was published. Testing a fix that should resolve the issue.