All useful information about development that is too detailed for README.md
Nethack has its own dependency group, just for transparency.
All non-production deps must be in the dev group to keep the docker image small.
Ruff is used for linting and formatting. There are two separate rules until astral-sh/ruff#8232 is solved.
uv run poe format-coderuns them both, but they can be run separately like this:
Run formatting:
uv run ruff formatCheck the formatting
uv run ruff checkPoe is used, because uv doesn't natively allow running two commands in one command by user.
During tests, ruff and optionally mypy are run using the pytest-* plugins.
Running pytest on individual files:
# Main bot functionality
uv run pytest tests/simek/test_main.py
# NetHack module tests
uv run pytest tests/grossmann/test_nethack.py
# Integration scenarios
uv run pytest tests/grossmann/test_integration.pyRunning pytest without ruff: Uncomment the
addopts = ["--import-mode=importlib", "-v", "--tb=short"]We don't enforce mypy, you can run it locally by uncommenting the mypy section in pyproject.toml
addopts = ["--import-mode=importlib", "-v", "--tb=short", "--ruff", "--ruff-format", "--mypy"]or by running
mypy .Mom jokes, dad jokes and help requests are implemented using ufal/morphodita, system description is here and complete documentation here.
Loading morphodita takes ~3s, but because it doesn't release the GIL, loading it in separate thread doesn't speed up the total start time. I did experiment with it and got nowhere, 2thread version took same time as single thread.
It's implemented using markov chain 3grams.
Running pip freeze inside the container doesn't do anything, because system pip doesn't see into env made by UV.
ENV VIRTUAL_ENV=/app/.venvdidn't help and I didn't want to install pip to the uv env, wasn't worth it.
I ran šimek with PYTHONASYNCIODEBUG=1 and it didn't print anything when processing some messages, meaning no
function is blocking the main event loop for over 100ms.
The dockerfile is highly optimized to produce small layers, the main logic is using UV to build and then copy only what is needed to slim image. Morphodita is copied first as it doesn't change. Then venv is copied without source code, and source code is copied last, so for just source code changes, there is minimal traffic related to docker image.