TylerLubeck / battlebots

3 stars 3 forks source link

The testing image seems to be missing something #10

Closed evemorgen closed 4 years ago

evemorgen commented 4 years ago

The example from README.md doesn't seem to work, it spits out the following error:

docker run -t docker.pkg.github.com/tylerlubeck/battlebots/battlebots:latest \
        rps p1 battlebot-python:latest p2 battlebot-python:latest /art --rounds 11
Traceback (most recent call last):
  File "/usr/local/bin/battlebots", line 5, in <module>
    from battlebots.__main__ import main
  File "/usr/local/lib/python3.8/site-packages/battlebots/__main__.py", line 1, in <module>
    from battlebots.cli import main
  File "/usr/local/lib/python3.8/site-packages/battlebots/cli.py", line 13, in <module>
    from battlebots.games.rps import RockPaperScissorsGame
ModuleNotFoundError: No module named 'battlebots.games'

I tried debugging it further inside the container and it looks like the battlebots package is missing some python modules:

root@31a1e7c0c02e:/app# ls /usr/local/lib/python3.8/site-packages/battlebots/
__init__.py  __main__.py  __pycache__  art_to_gif.py  cli.py

Running it with PYTHONPATH set to /app/src fixes the issue, I think

root@1a93094436e7:/# PYTHONPATH=/app/src battlebots
Usage: battlebots [OPTIONS] COMMAND [ARGS]...

Options:
  --install-completion [bash|zsh|fish|powershell|pwsh]
                                  Install completion for the specified shell.
  --show-completion [bash|zsh|fish|powershell|pwsh]
                                  Show completion for the specified shell, to
                                  copy it or customize the installation.

  --help                          Show this message and exit.

Commands:
  generate-gif  Generate an animated GIF from a series of ascii art files...
  rps           Run a Battle
TylerLubeck commented 4 years ago

In general, modifying PYTHONPATH makes things worse. In this particular case, it looks like the pushed image was missing an src/battlebots/games/__init__.py or something similar. I've repushed a new image

TylerLubeck commented 4 years ago

Bah the image I build locally works but not the remote one. I'll revisit this tonight