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

Missing SELECTED_RL_METHOD environment variable in BattlesnakeAPIFunction Lamba #29

Closed dangor closed 1 year ago

dangor commented 3 years ago

Using the Cloudformation template and getting around https://github.com/awslabs/sagemaker-battlesnake-ai/issues/28, I was getting internal server errors when I hit the snake/status endpoint. Digging into the logs, I found the following error:

[ERROR] KeyError: 'SELECTED_RL_METHOD'
Traceback (most recent call last):
  File "/var/lang/lib/python3.7/imp.py", line 234, in load_module
    return load_source(name, filename, file)
  File "/var/lang/lib/python3.7/imp.py", line 171, in load_source
    module = _load(spec)  File "<frozen importlib._bootstrap>", line 696, in _load
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/var/task/lambda.py", line 29, in <module>
    if os.environ['SELECTED_RL_METHOD'] == "MXNet":
  File "/var/lang/lib/python3.7/os.py", line 681, in __getitem__
    raise KeyError(key) from None

After I manually added the environment variable SELECTED_RL_METHOD with the value "RLLib" to this Lambda, I was able to get a 200 status saying the snake is ready.

jonomon commented 3 years ago

Hi @dangor thank you for reporting the bug. I will push a new version to fix within the next week.

jonomon commented 3 years ago

Fixed in https://github.com/awslabs/sagemaker-battlesnake-ai/commit/789036399cfdc034d8b79c00feec134834476a9b