Skip to content

Commit

Permalink
[misc] Cleanup MacOS CI workflow. (#833)
Browse files Browse the repository at this point in the history
  • Loading branch information
duburcqa authored Nov 19, 2024
1 parent e5c4897 commit 7dad584
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
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" "stable_baselines3>=2.0"
"${PYTHON_EXECUTABLE}" -m pip install "gymnasium>=0.28,<1.0" "stable_baselines3>=2.0,<2.4"
- name: Install latest numpy version at build-time for run-time binary compatibility
run: |
"${PYTHON_EXECUTABLE}" -m pip install --upgrade "numpy>=1.24"
Expand Down
30 changes: 12 additions & 18 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ jobs:
strategy:
matrix:
OS: ['macos-14'] # 'macos-13': Intel (x86), 'macos-14+': Apple Silicon (arm64)
OS: ['macos-15'] # 'macos-13': Intel (x86), 'macos-14+': Apple Silicon (arm64)
PYTHON_VERSION: ['3.10', '3.11', '3.12'] # `setup-python` does not support Python<3.10 on Apple Silicon
BUILD_TYPE: ['Release']
include:
- OS: 'macos-13'
PYTHON_VERSION: '3.11'
PYTHON_VERSION: '3.10'
BUILD_TYPE: 'Release'
- OS: 'macos-15'
PYTHON_VERSION: '3.12'
BUILD_TYPE: 'Debug'
LINKER_FLAGS: '-Wl,-ld_classic' # New "ld_prime" linker (XCode 15+) causes build failures

Expand Down Expand Up @@ -61,13 +64,18 @@ jobs:
echo "RootDir=${GITHUB_WORKSPACE}" >> $GITHUB_ENV
echo "InstallDir=${GITHUB_WORKSPACE}/install" >> $GITHUB_ENV
# FIXME: Panda3d software rendering is partially broken on Apple Silicon
if [[ "${{ matrix.OS }}" != 'macos-13' ]] ; then
echo "JIMINY_PANDA3D_FORCE_TINYDISPLAY=" >> $GITHUB_ENV
fi
"${PYTHON_EXECUTABLE}" -m pip install setuptools wheel "pip>=20.3"
"${PYTHON_EXECUTABLE}" -m pip install delocate twine
- name: Install pre-compiled binaries for additional gym-jiminy dependencies
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" "stable_baselines3>=2.0"
"${PYTHON_EXECUTABLE}" -m pip install "gymnasium>=0.28,<1.0" "stable_baselines3>=2.0,<2.4"
- name: Install latest numpy version at build-time for run-time binary compatibility
run: |
"${PYTHON_EXECUTABLE}" -m pip install --upgrade "numpy>=1.24"
Expand Down Expand Up @@ -148,7 +156,7 @@ jobs:
-p "macosx_${OSX_DEPLOYMENT_TARGET//./_}_${WHEEL_ARCH}" "${RootDir}/build/wheelhouse/"*.whl
"${PYTHON_EXECUTABLE}" -m pip install --force-reinstall --no-deps "${RootDir}/build/wheelhouse/"*.whl
- name: Upload the wheel for Linux of jiminy_py
if: matrix.BUILD_TYPE != 'Debug'
if: matrix.BUILD_TYPE != 'Debug' && matrix.OS != 'macos-15'
uses: actions/upload-artifact@v4
with:
name: wheelhouse-${{ matrix.PYTHON_VERSION }}
Expand Down Expand Up @@ -184,22 +192,12 @@ jobs:
ctest --output-on-failure --test-dir "${RootDir}/build/core/unit"
cd "${RootDir}/python/jiminy_py/unit_py"
# FIXME: Panda3d software rendering is partially broken on Apple Silicon
if [[ "${{ matrix.OS }}" != 'macos-13' ]] ; then
export JIMINY_PANDA3D_FORCE_TINYDISPLAY=
fi
"${PYTHON_EXECUTABLE}" -m unittest discover -v
- name: Run unit tests for gym jiminy base module
run: |
export LD_LIBRARY_PATH="${InstallDir}/lib/:/usr/local/lib"
# FIXME: Panda3d software rendering is partially broken on Apple Silicon
if [[ "${{ matrix.OS }}" != 'macos-13' ]] ; then
export JIMINY_PANDA3D_FORCE_TINYDISPLAY=
fi
# FIXME: Disabling `test_pipeline_control.py` on MacOS because `test_pid_standing` is
# failing for 'panda3d-sync' backend due to meshes still loading at screenshot time.
if [[ "${{ matrix.BUILD_TYPE }}" == 'Debug' ]] ; then
export JIMINY_BUILD_DEBUG=
fi
Expand All @@ -211,10 +209,6 @@ jobs:
export LD_LIBRARY_PATH="${InstallDir}/lib/:/usr/local/lib"
cd "${RootDir}/python/gym_jiminy/examples/rllib"
# FIXME: Panda3d software rendering is partially broken on Apple Silicon
if [[ "${{ matrix.OS }}" != 'macos-13' ]] ; then
export JIMINY_PANDA3D_FORCE_TINYDISPLAY=
fi
"${PYTHON_EXECUTABLE}" acrobot_ppo.py
#########################################################################################
Expand Down
2 changes: 1 addition & 1 deletion .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" "stable_baselines3>=2.0"
"${PYTHON_EXECUTABLE}" -m pip install "gymnasium>=0.28,<1.0" "stable_baselines3>=2.0,<2.4"
#####################################################################################

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
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" "stable_baselines3>=2.0"
python -m pip install "gymnasium>=0.28,<1.0" "stable_baselines3>=2.0,<2.4"
- name: Install latest numpy version at build-time for run-time binary compatibility
run: |
python -m pip install --upgrade "numpy>=1.24"
Expand Down
2 changes: 1 addition & 1 deletion python/gym_jiminy/common/gym_jiminy/common/envs/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def __init__(self,
r"""
:param simulator: Jiminy Python simulator used for physics
computations. It must be fully initialized.
:param step_dt: Simulation timestep for learning. Note that it is
:param step_dt: Environment timestep for learning. Note that it is
independent from the controller and observation update
periods. The latter are configured via
`engine.set_options`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ def __init__(self,
used if available.
:param simulation_duration_max: Maximum duration of a simulation before
returning done.
:param step_dt: Simulation timestep for learning.
:param step_dt: Environment timestep for learning. Note that it is
independent from the controller and observation update
periods. The latter are configured via
`engine.set_options`.
:param reward_mixture: Weighting factors of selected contributions to
total reward.
:param std_ratio: Relative standard deviation of selected contributions
Expand Down
12 changes: 9 additions & 3 deletions python/gym_jiminy/rllib/gym_jiminy/rllib/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,13 @@ def train(algo_config: AlgorithmConfig,
}
)

# Help making training more deterministic if a seed is specified
seed = cast(Optional[int], algo_config.seed)
if seed is not None:
algo_config.reporting(
min_time_s_per_iteration=None
)

# Disable default logger but configure logging directory nonetheless
algo_config.debugging(
logger_config=dict(
Expand Down Expand Up @@ -603,7 +610,6 @@ def train(algo_config: AlgorithmConfig,
return_threshold = env_spec.reward_threshold

# Set the seed of the training and evaluation environments
seed = cast(Optional[int], algo_config.seed)
if seed is not None:
seed_seq_gen = np.random.SeedSequence(seed)
seed_seq = seed_seq_gen.generate_state(2)
Expand Down Expand Up @@ -789,7 +795,7 @@ def train(algo_config: AlgorithmConfig,

# Backup the policy
if checkpoint_period > 0 and iter_num % checkpoint_period == 0:
algo.save(str(Path(logdir) / f"checkpoint_{iter_num:06d}"))
algo.save(os.path.join(logdir, f"checkpoint_{iter_num:06d}"))

# Check terminal conditions
num_timesteps = result[NUM_ENV_STEPS_SAMPLED_LIFETIME]
Expand Down Expand Up @@ -820,7 +826,7 @@ def train(algo_config: AlgorithmConfig,

# Backup trained agent and return file location
checkpoint_result = algo.save(
str(Path(logdir) / f"checkpoint_{iter_num:06d}"))
os.path.join(logdir, f"checkpoint_{iter_num:06d}"))
assert checkpoint_result.metrics is not None
assert checkpoint_result.checkpoint is not None

Expand Down
2 changes: 0 additions & 2 deletions python/gym_jiminy/unit_py/test_pipeline_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ def _test_pid_standing(self):
self.assertTrue(np.all(
np.abs(velocity_mes[time > time[-1] - 1.0]) < 1.0e-3))

@unittest.skipIf(DEBUG and sys.platform == "darwin",
"skipping when compiled in debug on Mac OS")
def test_pid_standing(self):
for backend in ('panda3d-sync', 'meshcat'):
for Env in (AtlasPDControlJiminyEnv,
Expand Down
2 changes: 1 addition & 1 deletion python/jiminy_pywrap/src/module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace jiminy::python

BOOST_PYTHON_MODULE(PYTHON_LIBRARY_NAME)
{
/* Initialized Numpy C API.
/* Initialized "local" Numpy C API.
This is required to handle raw `numpy::ndarray` objects manually. */
import_numpy();

Expand Down

0 comments on commit 7dad584

Please sign in to comment.