Skip to content

Commit

Permalink
[misc] Allow failure when installing gym_jiminy addon modules.
Browse files Browse the repository at this point in the history
  • Loading branch information
duburcqa committed Mar 13, 2024
1 parent 408164f commit c48b2d2
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 38 deletions.
13 changes: 3 additions & 10 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ jobs:
run: |
BUILD_TYPE="${{ matrix.BUILD_TYPE }}" ./build_tools/build_install_deps_unix.sh
- name: Install pre-compiled binaries for additional gym-jiminy dependencies
if: matrix.PYTHON_VERSION != '3.12'
if: matrix.PYTHON_VERSION != '3.13'
run: |
"${PYTHON_EXECUTABLE}" -m pip install "torch" -f https://download.pytorch.org/whl/torch
"${PYTHON_EXECUTABLE}" -m pip install "gymnasium>=0.28,<1.0" "importlib-metadata>=3.3.0"
"${PYTHON_EXECUTABLE}" -m pip install "gymnasium>=0.28,<1.0" "stable_baselines3>=2.0"
#####################################################################################

Expand All @@ -91,7 +91,7 @@ jobs:
-DBoost_NO_SYSTEM_PATHS=TRUE -DBoost_NO_BOOST_CMAKE=TRUE -DBoost_USE_STATIC_LIBS=ON \
-DPYTHON_EXECUTABLE="${PYTHON_EXECUTABLE}" \
-DBUILD_TESTING=ON -DBUILD_EXAMPLES=ON -DBUILD_PYTHON_INTERFACE=ON \
-DINSTALL_GYM_JIMINY=${{ (matrix.PYTHON_VERSION == '3.12' && 'OFF') || 'ON' }} \
-DINSTALL_GYM_JIMINY=${{ (matrix.PYTHON_VERSION == '3.13' && 'OFF') || 'ON' }} \
-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS}" -DCMAKE_BUILD_TYPE="${{ matrix.BUILD_TYPE }}"
make install -j2
Expand Down Expand Up @@ -127,10 +127,6 @@ jobs:
gdb -batch -ex "run" -ex "bt" --args "${PYTHON_EXECUTABLE}" acrobot_ppo.py 2>&1 | \
grep -v ^"No stack."$ && exit 1
# FIXME: Must install stable_baselines3 after running rllib test
# because they require a different version of `gymnasium`.
"${PYTHON_EXECUTABLE}" -m pip install "stable_baselines3>=2.0"
"${PYTHON_EXECUTABLE}" -m unittest discover -s "$RootDir/python/gym_jiminy/unit_py" -v
- name: Python static type checker
Expand All @@ -147,9 +143,6 @@ jobs:
cd "$RootDir/build"
make install
# FIXME: Force re-installing the right version of gymnasium
"${PYTHON_EXECUTABLE}" -m pip install "gymnasium>=0.28,<1.0"
# mypy is not able to follow `.pth` when checking directories or files.
# This bug may be fixed in the future. The only workaround is to set `MYPYPATH` manually.
# Anyway, the stubs generated for eigenpy, hppfcl and pinocchio they are incomplete and
Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ jobs:
OSX_DEPLOYMENT_TARGET=${OSX_DEPLOYMENT_TARGET} OSX_ARCHITECTURES=${OSX_ARCHITECTURES} \
BUILD_TYPE="${{ matrix.BUILD_TYPE }}" ./build_tools/build_install_deps_unix.sh
- name: Install pre-compiled binaries for additional gym-jiminy dependencies
if: matrix.PYTHON_VERSION != '3.12'
if: matrix.PYTHON_VERSION != '3.13'
run: |
"${PYTHON_EXECUTABLE}" -m pip install "torch" -f https://download.pytorch.org/whl/torch
"${PYTHON_EXECUTABLE}" -m pip install "gymnasium>=0.28,<1.0" "importlib-metadata>=3.3.0"
"${PYTHON_EXECUTABLE}" -m pip install "gymnasium>=0.28,<1.0" "stable_baselines3>=2.0"
#####################################################################################

Expand All @@ -99,7 +99,7 @@ jobs:
-DBoost_NO_SYSTEM_PATHS=TRUE -DBoost_NO_BOOST_CMAKE=TRUE \
-DBoost_USE_STATIC_LIBS=ON -DPYTHON_EXECUTABLE="${PYTHON_EXECUTABLE}" \
-DBUILD_TESTING=ON -DBUILD_EXAMPLES=ON -DBUILD_PYTHON_INTERFACE=ON \
-DINSTALL_GYM_JIMINY=${{ (matrix.PYTHON_VERSION == '3.12' && 'OFF') || 'ON' }} \
-DINSTALL_GYM_JIMINY=${{ (matrix.PYTHON_VERSION == '3.13' && 'OFF') || 'ON' }} \
-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS}" -DCMAKE_BUILD_TYPE="${{ matrix.BUILD_TYPE }}"
make -j2
Expand Down Expand Up @@ -191,10 +191,6 @@ jobs:
cd "${RootDir}/python/gym_jiminy/examples/rllib"
"${PYTHON_EXECUTABLE}" acrobot_ppo.py
# FIXME: Must install stable_baselines3 after running rllib test
# because they require a different version of `gymnasium`.
"${PYTHON_EXECUTABLE}" -m pip install "stable_baselines3>=2.0"
"${PYTHON_EXECUTABLE}" -m unittest discover -s "${RootDir}/python/gym_jiminy/unit_py" -v
#########################################################################################
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
sudo apt install ninja-build
fi
"${PYTHON_EXECUTABLE}" -m pip install "torch" -f https://download.pytorch.org/whl/torch
"${PYTHON_EXECUTABLE}" -m pip install "gymnasium>=0.28,<1.0" "importlib-metadata>=3.3.0"
"${PYTHON_EXECUTABLE}" -m pip install "gymnasium>=0.28,<1.0" "stable_baselines3>=2.0"
#####################################################################################

Expand Down Expand Up @@ -155,8 +155,6 @@ jobs:
cd "${RootDir}/python/gym_jiminy/examples/rllib"
"${PYTHON_EXECUTABLE}" acrobot_ppo.py
"${PYTHON_EXECUTABLE}" -m pip install "stable_baselines3>=2.0"
"${PYTHON_EXECUTABLE}" -m unittest discover -s "${RootDir}/python/gym_jiminy/unit_py" -v
#####################################################################################
Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ jobs:
${env:BUILD_TYPE} = "${{ matrix.BUILD_TYPE }}"
& "./workspace/build_tools/build_install_deps_windows.ps1"
- name: Install pre-compiled binaries for additional gym-jiminy dependencies
if: matrix.PYTHON_VERSION != '3.12'
if: matrix.PYTHON_VERSION != '3.13'
run: |
python -m pip install "torch" -f https://download.pytorch.org/whl/torch
python -m pip install "gymnasium>=0.28,<1.0" "importlib-metadata>=3.3.0"
python -m pip install "gymnasium>=0.28,<1.0" "stable_baselines3>=2.0"
#####################################################################################

Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:
-DBoost_NO_SYSTEM_PATHS=TRUE -DBoost_NO_BOOST_CMAKE=TRUE `
-DBoost_USE_STATIC_LIBS=ON -DPYTHON_REQUIRED_VERSION="${{ matrix.PYTHON_VERSION }}" `
-DBUILD_TESTING=ON -DBUILD_EXAMPLES=ON -DBUILD_PYTHON_INTERFACE=ON `
-DINSTALL_GYM_JIMINY=${{ ((matrix.PYTHON_VERSION == '3.12') && 'OFF') || 'ON' }} `
-DINSTALL_GYM_JIMINY=${{ ((matrix.PYTHON_VERSION == '3.13') && 'OFF') || 'ON' }} `
-DCMAKE_CXX_FLAGS="${env:CMAKE_CXX_FLAGS} $(
) -DBOOST_ALL_NO_LIB -DBOOST_LIB_DIAGNOSTIC -DBOOST_CORE_USE_GENERIC_CMATH $(
) -DEIGENPY_STATIC -DURDFDOM_STATIC -DHPP_FCL_STATIC -DPINOCCHIO_STATIC"
Expand Down Expand Up @@ -198,10 +198,6 @@ jobs:
Set-Location -Path "$RootDir/python/gym_jiminy/examples/rllib"
python acrobot_ppo.py
# FIXME: Must install stable_baselines3 after running rllib test
# because they require a different version of `gymnasium`.
python -m pip install "stable_baselines3>=2.0"
python -m unittest discover -s "$RootDir/python/gym_jiminy/unit_py" -v
#########################################################################################
Expand Down
28 changes: 22 additions & 6 deletions build_tools/cmake/setupPython.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,10 @@ if(${Boost_MINOR_VERSION} GREATER_EQUAL 67)
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_LIB_PREFIX "")
unset(Boost_LIBRARIES)
find_package(Boost REQUIRED COMPONENTS
"python${Python_VERSION_MAJOR}${Python_VERSION_MINOR}"
"numpy${Python_VERSION_MAJOR}${Python_VERSION_MINOR}")
find_package(
Boost REQUIRED COMPONENTS
"python${Python_VERSION_MAJOR}${Python_VERSION_MINOR}"
"numpy${Python_VERSION_MAJOR}${Python_VERSION_MINOR}")
set(BOOST_PYTHON_LIB "${Boost_LIBRARIES}")
unset(Boost_LIBRARIES)
if(WIN32)
Expand Down Expand Up @@ -154,13 +155,28 @@ function(deployPythonPackage)
endfunction()

function(deployPythonPackageDevelop)
# The input arguments are [PKG_NAME...]
foreach(PKG_NAME IN LISTS ARGN)
# The input arguments are [PKG_NAME...], ALLOW_FAILURE

# Extract the output arguments (see `buildPythonWheel`)
set(ARGS ${ARGN})
list(LENGTH ARGS NUM_ARGS)
if(${NUM_ARGS} LESS 2)
message(FATAL_ERROR "Please specify at least one PKG_NAME and ALLOW_FAILURE.")
endif()
list(GET ARGS -1 ALLOW_FAILURE)
list(REMOVE_AT ARGS -1)

# Loop over all packages sequentially
foreach(PKG_NAME IN LISTS ARGS)
install(CODE "execute_process(COMMAND ${Python_EXECUTABLE} -m pip install ${PYTHON_INSTALL_FLAGS} -e .
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/${PKG_NAME}
RESULT_VARIABLE RETURN_CODE)
if(NOT RETURN_CODE EQUAL 0)
message(FATAL_ERROR \"Python installation of '${PKG_NAME}' failed.\")
if (NOT ${ALLOW_FAILURE})
message(FATAL_ERROR \"Python installation of '${PKG_NAME}' failed.\")
else()
message(WARNING \"Python installation of '${PKG_NAME}' failed.\")
endif()
endif()")
endforeach()
endfunction()
7 changes: 4 additions & 3 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ if(INSTALL_GYM_JIMINY)
"python/gym_${LIBRARY_NAME}/envs"
"python/gym_${LIBRARY_NAME}/rllib"
"${CMAKE_BINARY_DIR}/pypi/dist/gym_${LIBRARY_NAME}")
deployPythonPackageDevelop("python/gym_${LIBRARY_NAME}/common"
"python/gym_${LIBRARY_NAME}/toolbox"
deployPythonPackageDevelop("python/gym_${LIBRARY_NAME}/common" FALSE)
deployPythonPackageDevelop("python/gym_${LIBRARY_NAME}/toolbox"
"python/gym_${LIBRARY_NAME}/envs"
"python/gym_${LIBRARY_NAME}/rllib")
"python/gym_${LIBRARY_NAME}/rllib"
TRUE) # ALLOW_FAILURE
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from copy import deepcopy
from abc import abstractmethod
from collections import OrderedDict
from collections.abc import MutableMapping
from itertools import chain
from typing import (
Dict, Any, List, Optional, Tuple, Union, Iterable, Generic, TypeVar,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Solve the official Open AI Gym Acrobot problem simulated in Jiminy using PPO
algorithm of Stable_baseline3 reinforcement learning framework.
algorithm of Stable_baselines3 reinforcement learning framework.
It solves it consistently in less than 100000 timesteps in average, and in
about 40000 at best.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Solve the official Open AI Gym Acrobot problem simulated in Jiminy using PPO
algorithm of Stable_baseline3 reinforcement learning framework.
algorithm of Stable_baselines3 reinforcement learning framework.
It solves it consistently in less than 100000 timesteps in average, and in
about 40000 at best.
Expand Down

0 comments on commit c48b2d2

Please sign in to comment.