awslabs / sagemaker-battlesnake-ai

Starter pack to build an AI for Battlesnake with Amazon Sagemaker more content on wiki:
https://github.com/awslabs/sagemaker-battlesnake-ai/wiki
Apache License 2.0
89 stars 53 forks source link

api function throwing errors #49

Open wordstospend opened 1 year ago

wordstospend commented 1 year ago

INIT_START Runtime Version: python:3.7.v22 Runtime Version ARN: arn:aws:lambda:us-west-2::runtime:c20bdb59d3d6e84cc4b436e730261b773590c43962e79e9b7a43e9715ac5276d START RequestId: 3352c07d-f016-4128-9bfa-98d7891f8edf Version: $LATEST [ERROR] Runtime.ImportModuleError: Unable to import module 'lambda': IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE! Importing the numpy C-extensions failed. This error can happen for many reasons, often due to issues with your setup or how NumPy was installed. We have compiled some common reasons and troubleshooting tips at: https://numpy.org/devdocs/user/troubleshooting-importerror.html Please note and check the following:

  • The Python version is: Python3.7 from "/var/lang/bin/python3.7"
  • The NumPy version is: "1.22.4" and make sure that they are the versions you expect. Please carefully study the documentation linked above for further help. Original error was: No module named 'numpy.core._multiarray_umath'

This appears to be an issue with the api lambda code at S3Bucket: sagemaker-solutions-prod-us-west-2 S3Key: sagemaker-battlesnake-ai/1.2.1/build/api.zip

I'm going to attempt to rebuild and deploy to from local to see if I can resolve this. But otherwise this project is unusable.

wordstospend commented 1 year ago

After rebuilding this I was able to get the lambda to run successfully. The current output for the stack does include an output

CheckSnakeStatus XXXXX Check the snake status. If you see 'ready' you can use the snake

This status is also broken but can be repaired by adding back the status endpoint to the api lambda which was removed b71e62c98b9910cad553fd7c81854ceba3bf8bdd

This status endpoint relies on the name of the sagemaker endpoint which is hardcoded, and should be updated. A more permeant fix would be to have the endpoint name passed in as an env variable

queyrusi commented 1 year ago

Error reproduced on two separate AWS accounts: output URL CheckSnakeStatus https://xxxxxxx.execute-api.us-west-2.amazonaws.com/snake and /snake/status return {"message": "Internal server error"} upon GET request.

Note that prior to pile building I had to change parameters S3BucketName from snake-bucket to snake-bucket-1 to avoid a name-already-in-use issue.

Quick workaround: Lambda > Functions > sagemaker-soln-bs-2-api-function > Layers > Add a layer then chose an AWS layer e.g. AWSSDKPandas-Python39 and click Add. Be mindful of the Python version of the lambda function execution for this choice, mine is 3.9. Lambda function now supports numpy. /snake/status will now throw a 404 but the gateway will handle battlesnake webhooks correctly.