Skip to content

Commit

Permalink
Support running the default homemade engines without the need to prov…
Browse files Browse the repository at this point in the history
…ide a `homemade.py` file (#951)

* Homemade engines in docker

* Delete lib/extra_game_handlers_wrapper.py

* Remove warning

* Update Dockerfile
  • Loading branch information
AttackingOrDefending authored May 3, 2024
1 parent da2249b commit 48fc702
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 43 deletions.
5 changes: 1 addition & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,5 @@ COPY . .
RUN python3 -m pip install --no-cache-dir -r requirements.txt

ARG CONF_FOLDER=$LICHESS_DIR/config
RUN ln -s $CONF_FOLDER/config.yml config.yml &&\
ln -sf $CONF_FOLDER/homemade.py homemade.py &&\
ln -sf $CONF_FOLDER/extra_game_handlers.py extra_game_handlers.py

CMD python3 lichess-bot.py ${OPTIONS} --disable_auto_logging
CMD docker/copy_files.sh && python3 lichess-bot.py ${OPTIONS} --disable_auto_logging
1 change: 0 additions & 1 deletion docker/Dockerfile.dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
docker/
docs/
wiki/
.git*
Expand Down
11 changes: 11 additions & 0 deletions docker/copy_files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

ln -s /lichess-bot/config/config.yml config.yml

if [ -f /lichess-bot/config/homemade.py ]; then
ln -sf /lichess-bot/config/homemade.py homemade.py
fi

if [ -f /lichess-bot/config/extra_game_handlers.py ]; then
ln -sf /lichess-bot/config/extra_game_handlers.py extra_game_handlers.py
fi
2 changes: 1 addition & 1 deletion lib/engine_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from lib import config, model, lichess
from lib.config import Configuration
from lib.timer import Timer, msec, seconds, msec_str, sec_str, to_seconds
from lib.extra_game_handlers_wrapper import game_specific_options
from extra_game_handlers import game_specific_options
from typing import Any, Optional, Union, Literal, Type
from types import TracebackType
OPTIONS_TYPE = dict[str, Any]
Expand Down
35 changes: 0 additions & 35 deletions lib/extra_game_handlers_wrapper.py

This file was deleted.

2 changes: 1 addition & 1 deletion lib/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def is_supported(self, config: Configuration,
if self.from_self:
return True, ""

from lib.extra_game_handlers_wrapper import is_supported_extra
from extra_game_handlers import is_supported_extra

allowed_opponents: list[str] = list(filter(None, config.allow_list)) or [self.challenger.name]
decline_reason = (self.decline_due_to(config.accept_bot or not self.challenger.is_bot, "noBot")
Expand Down
1 change: 0 additions & 1 deletion wiki/How-to-use-the-Docker-image.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ That's all!

### Warning:
- Make sure you've set the `dir` and `working_dir` attributes of your `config.yml` to the right path (remember the engine runs in the container's OS, so the path should start with `/lichess-bot/config/`).
- If you are using a homemade engine provided in the original [`homemade.py` file in the Github project](https://github.com/lichess-bot-devs/lichess-bot/blob/master/homemade.py), you **must** add this file to the folder containing your configuration files.
- **If you've configured a folder to save pgn files** using [`pgn_directory`](https://github.com/lichess-bot-devs/lichess-bot/wiki/Configure-lichess-bot#other-options) that is not in `/lichess-bot/config` directory, always mount a volume to that folder. Without that, your saved games will remain unreachable from the outside of the container, and storing a lot of games in the container's file system could result in disk saturation.
- The container uses the standard docker logging system and the bot is always launched with the `--disable_auto_logging` option.
Use the `docker logs myBot` [command](https://docs.docker.com/reference/cli/docker/container/logs/) to access to the bot logs.
Expand Down

0 comments on commit 48fc702

Please sign in to comment.