Skip to content

[gym_jiminy/common] Speed-up env pipeline. #3746

[gym_jiminy/common] Speed-up env pipeline.

[gym_jiminy/common] Speed-up env pipeline. #3746

Workflow file for this run

name: Windows CI (Build from source dependencies)
on:
# Trigger the workflow on push on the master branch, or for any pull request
push:
branches:
- master
pull_request:
jobs:
build-and-test-win10:
name: >-
(Windows) (${{ matrix.PYTHON_VERSION }}) Build the dependencies.
Build the project and run the unit tests.
runs-on: windows-2022
defaults:
run:
shell: pwsh
env:
TORCH_VERSION: "2.0.1+cpu"
BUILD_TYPE: "Release"
GENERATOR: "Visual Studio 17 2022"
CMAKE_CXX_FLAGS: "-DEIGEN_MPL2_ONLY /d2ReducedOptimizeHugeFunctions /fp:contract /arch:AVX2"
strategy:
matrix:
PYTHON_VERSION: ['3.8', '3.9', '3.10', '3.11']
#####################################################################################
steps:
- name: Configure Pagefile
uses: al-cheb/configure-pagefile-action@v1.3
- name: Checkout jiminy
uses: actions/checkout@v3
#####################################################################################
- name: Configure Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.PYTHON_VERSION }}
architecture: 'x64'
- name: Setup minimal build environment
run: |
git config --global advice.detachedHead false
python -m pip install setuptools wheel "pip>=20.3"
python -m pip install "numpy>=1.21" "numba>=0.54.0"
python -m pip install pefile machomachomangler
- name: Build project dependencies
run: |
if ("${{ matrix.PYTHON_VERSION }}" -ne '3.11') {
python -m pip install "torch==${env:TORCH_VERSION}" -f https://download.pytorch.org/whl/torch
python -m pip install "gymnasium>=0.26,<0.29" "importlib-metadata>=3.3.0"
}
& "./build_tools/build_install_deps_windows.ps1"
#####################################################################################
- name: Configure and build jiminy
run: |
$ErrorActionPreference = "Stop"
Set-PSDebug -Trace 1
$RootDir = "${env:GITHUB_WORKSPACE}" -replace '\\', '/'
$InstallDir = "$RootDir/install"
if (Test-Path env:Boost_ROOT) {
Remove-Item env:Boost_ROOT
}
if (-not (Test-Path -PathType Container $RootDir/build)) {
New-Item -ItemType "directory" -Force -Path "$RootDir/build"
}
Set-Location -Path $RootDir/build
cmake "$RootDir" -G "${env:GENERATOR}" -DCMAKE_GENERATOR_PLATFORM=x64 `
-DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$<CONFIG:Debug>:Debug>DLL" `
-DCMAKE_INSTALL_PREFIX="$InstallDir" -DCMAKE_PREFIX_PATH="$InstallDir" `
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF `
-DBOOST_ROOT="$InstallDir" -DBoost_INCLUDE_DIR="$InstallDir/include" `
-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.11' && '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"
cmake --build . --target ALL_BUILD --config "${env:BUILD_TYPE}" --parallel 2
if (-not (Test-Path -PathType Container "$RootDir/build/pypi/jiminy_py/src/jiminy_py")) {
New-Item -ItemType "directory" -Force -Path "$RootDir/build/pypi/jiminy_py/src/jiminy_py/core"
}
Copy-Item -Force -Recurse -Path "$InstallDir/lib/site-packages/*" `
-Destination "$RootDir/build/pypi/jiminy_py/src/jiminy_py/core"
${env:Path} += ";$InstallDir/lib"
cmake --build . --target INSTALL --config "${env:BUILD_TYPE}"
#####################################################################################
- name: Generating the Python Pip wheels
run: |
$RootDir = "${env:GITHUB_WORKSPACE}" -replace '\\', '/'
$InstallDir = "$RootDir/install"
${env:Path} += ";$InstallDir/lib"
# Generate stubs
stubgen -p jiminy_py -o $RootDir/build/pypi/jiminy_py/src
python "$RootDir/build_tools/stub_gen.py" `
-o $RootDir/build/stubs --ignore-invalid=all jiminy_py
Copy-Item -Force -Path "$RootDir/build/stubs/jiminy_py-stubs/core/__init__.pyi" `
-Destination "$RootDir/build/pypi/jiminy_py/src/jiminy_py/core/core.pyi"
# Generate wheels
Set-Location -Path "$RootDir/build"
cmake . -DCOMPONENT=pypi -P ./cmake_install.cmake
# Bundle non-standard dependencies with the wheels
Remove-Item -Recurse -Path "$RootDir/build/pypi" -Include *.tar.gz
Get-ChildItem -Recurse -Path "$RootDir/build/pypi/dist/jiminy_py" -Filter *.whl |
Foreach-Object {
$wheel_path = ($_.FullName)
python "$RootDir/build_tools/wheel_repair_win.py" "$wheel_path" -d "$InstallDir/lib" -w "$RootDir/build/wheelhouse"
}
Get-ChildItem -Path "$RootDir/build/wheelhouse" -Filter *.whl |
Foreach-Object {
$wheel_path = ($_.FullName)
python -m pip install --force-reinstall --no-deps $wheel_path
}
- name: Upload the wheel for Windows of jiminy_py
uses: actions/upload-artifact@v3
with:
name: wheelhouse
path: build/wheelhouse
#####################################################################################
- name: Build extension module
run: |
$ErrorActionPreference = "Stop"
Set-PSDebug -Trace 1
$RootDir = "${env:GITHUB_WORKSPACE}" -replace '\\', '/'
$InstallDir = "$RootDir/install"
& "$InstallDir/bin/jiminy_double_pendulum.exe"
mkdir -p "$RootDir/core/examples/external_project/build"
cd "$RootDir/core/examples/external_project/build"
$JIMINY_LIB_DIR = (python -c "import os, jiminy_py ; print(os.path.dirname(jiminy_py.get_libraries()))")
${env:Path} += ";$JIMINY_LIB_DIR"
cmake "$RootDir/core/examples/external_project/" -G "${env:GENERATOR}" -DCMAKE_GENERATOR_PLATFORM=x64 `
-DCMAKE_INSTALL_PREFIX="$InstallDir" -DCMAKE_PREFIX_PATH="$InstallDir" `
-DPYTHON_REQUIRED_VERSION="${{ matrix.PYTHON_VERSION }}" `
-DCMAKE_CXX_FLAGS="${env:CMAKE_CXX_FLAGS}"
cmake --build . --target INSTALL --config "${env:BUILD_TYPE}"
& "$InstallDir/bin/pip_double_pendulum.exe"
- name: Running unit tests for jiminy
run: |
$RootDir = "${env:GITHUB_WORKSPACE}" -replace '\\', '/'
Set-Location -Path "$RootDir/build/core/unit"
ctest --output-on-failure
Set-Location -Path "$RootDir/python/jiminy_py/unit_py"
python -m unittest discover -v
- name: Running unit tests for gym_jiminy
if: matrix.PYTHON_VERSION != '3.11'
run: |
$RootDir = "${env:GITHUB_WORKSPACE}" -replace '\\', '/'
Set-Location -Path "$RootDir/python/gym_jiminy/examples/reinforcement_learning/rllib"
$JIMINY_VIEWER_DEFAULT_BACKEND = "panda3d-sync"
python acrobot_ppo.py
python -m pip install "stable_baselines3>=2.0"
Set-Location -Path "$RootDir/python/gym_jiminy/unit_py"
python -m unittest discover -v
#########################################################################################
publish-pypi-win10:
name: (Windows) Publish on PyPi the wheel for Windows of jiminy_py
needs: build-and-test-win10
runs-on: ubuntu-20.04
if: github.repository == 'duburcqa/jiminy' && github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- name: Download the wheels previously generated
uses: actions/download-artifact@v3
with:
name: wheelhouse
path: wheelhouse
- name: Publish on PyPi the wheels
uses: pypa/gh-action-pypi-publish@v1.7.1
with:
user: __token__
password: ${{ secrets.PYPI_DEPLOY }}
packages-dir: wheelhouse
verify-metadata: false