Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
884feab
Add doc strings and precommit
rk1a Jul 5, 2023
80479dc
WIP add sphinx documentation
rk1a Jul 6, 2023
9d27cfd
WIP sphinx docs
rk1a Jul 10, 2023
32bd942
WIP sphinx docs
rk1a Jul 10, 2023
7915e13
WIP sphinx docs
rk1a Jul 14, 2023
e7922cb
Merge branch 'add-documentation' of https://github.com/rk1a/minetest …
rk1a Jul 14, 2023
b58e6d8
Fix no curser image segfaulting and make dumb client recording by def…
rk1a Jul 14, 2023
f03ceaa
WIP documentation
rk1a Jul 14, 2023
46a98fc
Improves docs and adds page on sync mode
rk1a Jul 16, 2023
64bb274
Adds client API doc and fixes
rk1a Jul 17, 2023
e81b7a9
Update sphinx versions and README
rk1a Jul 17, 2023
8a71e77
Merge branch 'develop' into add-documentation
rk1a Dec 3, 2023
46db1eb
Fix docstrings
rk1a Dec 3, 2023
ef97cbe
Fix build
rk1a Dec 3, 2023
fa846c5
Update documentation
rk1a Dec 3, 2023
d54ac96
Create minetester.yml
rk1a Dec 24, 2023
b82da26
Fix make target name
rk1a Dec 24, 2023
48df16f
Use SDL2 branch
rk1a Dec 27, 2023
9db394f
Cd back to root dir
rk1a Dec 27, 2023
6da2f82
Add IrrlichtMt build script
rk1a Dec 27, 2023
7171bf7
Add IrrlichtMt build script
rk1a Dec 27, 2023
4c9df32
Merge branch 'develop' of https://github.com/rk1a/minetest into develop
rk1a Dec 27, 2023
223e043
Explicitly set irrlicht dir
rk1a Dec 27, 2023
a1b3a96
Fix submodules
rk1a Jan 8, 2024
6a80901
Fix custom IrrlichtMt branch
rk1a Jan 8, 2024
3fca9ac
Fix IrrlichtMt path
rk1a Jan 8, 2024
df5a140
Fix zmqpp build script
rk1a Jan 8, 2024
b0da980
Fix pre-commit step
rk1a Jan 8, 2024
e982a28
Allow manually triggering the pipeline
rk1a Jan 17, 2024
0ace92c
Add some python tests
rk1a Jan 17, 2024
8943b3e
Use xvfb headless in tests
rk1a Jan 17, 2024
3794a85
Add minimum python version
rk1a Jan 18, 2024
ebee944
Add pytest-timeout for debugging hanging pipeline
rk1a Jan 18, 2024
e373b55
Update minetester.yml
rk1a Jan 19, 2024
a4edb68
Remove unused package
rk1a Jan 20, 2024
2ea727a
Fix permission error
rk1a Jan 20, 2024
6628e51
Fix headlessness and use fixed SDL tag
rk1a Jan 20, 2024
9b6840b
Test both headless modes
rk1a Jan 20, 2024
c1a8343
Try combined reset/step test
rk1a Jan 20, 2024
94bd017
Use unused port and display fixtures
rk1a Jan 20, 2024
75f109b
Pring logs for debugging
rk1a Jan 21, 2024
830b075
Try to fix x server related bug
rk1a Jan 21, 2024
ccd502d
Improve xvfb utility
rk1a Jan 21, 2024
b09f2cf
Clean up
rk1a Jan 21, 2024
8c5e2c2
Remove debuggin prints and update test requirements
rk1a Jan 21, 2024
be2b178
Run pytest with coverage
rk1a Jan 22, 2024
cdc08c0
Fix string formatting bug
rk1a Jan 22, 2024
84c9f0d
Add more tests
rk1a Jan 22, 2024
2c42199
Fix typo
rk1a Jan 22, 2024
6d043c0
Update minetester.yml
rk1a Jan 23, 2024
dd37112
Update gitignore
rk1a Feb 19, 2024
adbf925
Improve envrionment seeding
rk1a Feb 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[run]
omit = minetester/tests/*
56 changes: 56 additions & 0 deletions .github/workflows/minetester.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Build and test Minetester

on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]
workflow_dispatch:

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install Linux dependencies
run: make linux_deps
- name: Install build dependencies
run: make python_build_deps
- name: Init submodules
run: make repos
- name: Build SDL2
run: make sdl2
- name: Build zmqpp
run: make zmqpp
- name: Create Protobuf files
run: make proto
# - name: Build irrlicht
# run: bash util/minetester/build_irrlicht.sh
- name: Build minetest binary
run: make minetest
- name: Build minetester wheel
run: make minetester
- name: Install minetester along with dependencies
run: |
python -m pip install --upgrade pip
make install
- name: Run pre-commit hooks
run: |
pip install pre-commit
pre-commit install
pre-commit run --all-files
- name: Run tests
run: |
pip install pytest pytest-timeout pytest-asyncio pytest-cov
pip freeze
pytest -vs --timeout=180 --cov=minetester --cov-report term-missing:skip-covered
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/tags.temp
/*-*-*-*-*.conf
/*-*-*-*-*/
/data/

## Editors and development environments
*~
Expand Down
16 changes: 8 additions & 8 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[submodule "lib/irrlichtmt"]
path = lib/irrlichtmt
url = https://github.com/EleutherAI/irrlicht.git
branch = headless-rendering

[submodule "lib/zmqpp"]
path = lib/zmqpp
url = https://github.com/zeromq/zmqpp.git
[submodule "games/minetest_game"]
path = games/minetest_game
url = https://github.com/minetest/minetest_game.git
[submodule "lib/SDL"]
path = lib/SDL
url = https://github.com/libsdl-org/SDL.git
branch = SDL2
[submodule "lib/zmqpp"]
path = lib/zmqpp
url = https://github.com/zeromq/zmqpp.git
[submodule "lib/irrlicht"]
path = lib/irrlichtmt
url = https://github.com/EleutherAI/irrlicht.git
branch = headless-rendering
42 changes: 42 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
# Linting
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-ast
files: ^minetester/.*$
- id: trailing-whitespace
files: ^minetester/.*$
- id: end-of-file-fixer
exclude_types: [jupyter]
files: ^minetester/.*$
- id: check-added-large-files
files: ^minetester/.*$
- repo: https://github.com/psf/black
rev: 22.6.0
hooks:
- id: black
files: ^minetester/.*$
- id: black-jupyter
files: ^minetester/.*$
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black", "--filter-files"]
files: ^minetester/.*$
# Python static analysis
- repo: https://github.com/pycqa/flake8
rev: '5.0.4'
hooks:
- id: flake8
additional_dependencies:
- darglint~=1.8.1
- flake8-blind-except==0.2.1
- flake8-builtins~=1.5.3
- flake8-commas~=2.1.0
- flake8-debugger~=4.1.2
- flake8-docstrings~=1.6.0
files: ^minetester/(?!(tests)/).*\.py$
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
.PHONY: all deps repos sdl2 package zmqpp minetester minetest install demo proto clean
.PHONY: all deps repos sdl2 package zmqpp irrlicht minetester minetest install demo proto clean

MINETESTER_VERSION := 0.0.1
SDL2_CMAKE_FILE := lib/SDL/build/lib/cmake/SDL2/sdl2-config.cmake
ZMQPP_LIB_FILE := lib/zmqpp/build/max-g++/libzmqpp.a
IRRLICHTMT_LIB_FILE := lib/irrlichtmt/lib/Linux/libIrrlichtMt.a
MINETEST_BINARY := bin/minetest
DEBUG_BINARY := bin/debug
MINETESTER_WHEEL := build/package/wheel/minetester-$(MINETESTER_VERSION)-py3-none-manylinux_2_35_x86_64.whl
Expand Down Expand Up @@ -38,6 +39,10 @@ $(ZMQPP_LIB_FILE):

zmqpp: $(ZMQPP_LIB_FILE)

$(IRRLICHTMT_LIB_FILE):
util/minetester/build_irrlicht.sh

irrlicht: $(IRRLICHTMT_LIB_FILE)

$(MINETEST_BINARY):
#build minetest binary
Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@ Minetester
==========
Minetester is the Python package that exposes Minetest environments via the `gym(nasium)` interface.
After [building the minetest executable](https://github.com/EleutherAI/minetest/blob/develop/build_instructions.txt) you can install it with:
```
``` bash
pip install -e .
```
To verify the installation run
```
``` bash
python -m minetester.scripts.test_loop
```
To build the documentation in `docs-minetester` please run
``` bash
pip install -e .[docs]
cd docs-minetester && make livehtml
```

Quick Build Instructions for Linux
==================================
Expand All @@ -45,7 +50,7 @@ make clean #clean up build artifacts

Additionally the makefile supports a utility to clean only the minetester install

```
```bash
make clean_minetester #remove existing minetester install
make minetester #build minetester python library
make install #install python library into local environment along with nessesary dependencies
Expand Down
66 changes: 20 additions & 46 deletions build_instructions.txt
Original file line number Diff line number Diff line change
@@ -1,46 +1,20 @@
1. Install prereqs
1. sudo apt-get install xvfb g++ make libzmq3-dev libtool pkg-config build-essential autoconf automake libc6-dev cmake libpng-dev libjpeg-dev libxi-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev libzstd-dev libluajit-5.1-dev protobuf-compiler

2. Build SDL2
1. clone the SDL2 repo https://github.com/libsdl-org/SDL
2. checkout release-2.26.2 https://github.com/libsdl-org/SDL/tree/release-2.26.2
3. create a build directory inside the SDL repo
4. cd into it and run ../configure --prefix=/path/to/SDL/dir/build && make && make install

3. Build zmqpp
1. clone https://github.com/zeromq/zmqpp
2. checkout the develop branch
3. run make

4. Clone EAI alignment minetest repos
1. clone https://github.com/EleutherAI/minetest
2. checkout the develop branch
3. clone https://github.com/EleutherAI/irrlicht
4. checkout headless-renderer

5. Clone minetest game spec
1. clone https://github.com/minetest/minetest_game
2. checkout master branch

5. Establish symlinks
1. cd into minetest/lib
2. rm -r zmqpp irrlichtmt
3. ln -s ../../zmqpp/ zmqpp
4. ln -s ../../irrlicht/ irrlichtmt
5. cd into minetest/games
6. ln -s ../../minetest_game/ minetest_game

6. Build minetest
1. cd into minetest
2. either run
cmake . -DRUN_IN_PLACE=TRUE -DBUILD_HEADLESS=1 -DSDL2_DIR=<path to SDL repo>/SDL/build/lib/cmake/SDL2/
or
cmake . -DRUN_IN_PLACE=TRUE -DBUILD_HEADLESS=0 -DSDL2_DIR=
3. run make -j$(nproc)

7. setup python
1. create and activate a new python conda env or venv (tested with python3.9)
2. pip install gym matplotlib protobuf==3.20.1 psutil zmq -e ./minetest
3. cd into the scripts directory and run compile_proto.sh
4. run python -m minetester.scripts.test_loop

# 1. Install debian dependencies, equivalent commands are nessesary for other distros
make deb_deps
# 2. Install build dependencies into the local python environment (we reccomend using a venv)
make python_build_deps
# 3. Init submodules
make repos
# 4. Build sdl2
make sdl2
# 5. Build zmqpp
make zmqpp
# 6. Create c++ and python protobuf files
make proto
# 7. Build minetest binary
make minetest
# 8. Build minetester python library
make minetester
# 9. Install minetester into local environment along with necessary dependencies
make install
# 10. Run the demo script
make demo
4 changes: 2 additions & 2 deletions clientmods/mods.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load_mod_random_v0 = true
load_mod_rewards = true
load_mod_treechop_v1 = false
load_mod_treechop_shaped_v0 = false
load_mod_random_v1 = false
load_mod_preview = false
load_mod_treechop_v0 = false
load_mod_random_v0 = false
load_mod_preview = false
23 changes: 23 additions & 0 deletions docs-minetester/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

livehtml:
sphinx-autobuild "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) --open-browser
1 change: 1 addition & 0 deletions docs-minetester/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sphinx-apidoc -o ./source ../minetester ../minetester/proto
35 changes: 35 additions & 0 deletions docs-minetester/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
1 change: 1 addition & 0 deletions docs-minetester/source/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_api
30 changes: 30 additions & 0 deletions docs-minetester/source/_templates/module.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{{ fullname | escape | underline }}

Description
-----------

.. automodule:: {{ fullname | escape }}

{% if classes %}
Classes
-------
.. autosummary:
:toctree: _autosummary

{% for class in classes %}
{{ class }}
{% endfor %}

{% endif %}

{% if functions %}
Functions
---------
.. autosummary:
:toctree: _autosummary

{% for function in functions %}
{{ function }}
{% endfor %}

{% endif %}
Loading