Skip to content

Commit

Permalink
Fix Python CI breakages (#262)
Browse files Browse the repository at this point in the history
Mitigate drift in supported GitHub runner versions:
* ubuntu-latest now uses ubuntu-24.04, which broke our Python CI due to newer and stricter GCC.
* macos-12 is EOL.

Fix (1) by pinning Python builds to ubuntu-22.04. Note that ubuntu-24.04 also drops out-of-the-box support for Python 3.8, which we should continue testing to match the Brain.

Fix (2) by upgrading to macos-13, likewise the final runner with Python 3.8 baked in. This required a fix to an undefined behavior (compiler-dependent) bug in the pybindings for Lie group types.

Completes SWE-531 and SWE-538.
  • Loading branch information
mihelich authored Dec 19, 2024
1 parent c430439 commit b78ce90
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/api_reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04]
os: [ubuntu-22.04]
fail-fast: false


Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/ci_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ jobs:
strategy:
fail-fast: false
matrix:
# Using macos-12 bc:
# 1. they removed support for python 3.8 & 3.9 on macos-14 (now macos-latest)
# - See: https://github.com/actions/setup-python/issues/696#issuecomment-2071769156
# 2. `test_pose` fails on macos-13 and macos-14 (but not macos-12)
os: [ubuntu-latest, macos-12]
# We use ubuntu-22.04 and macos-13 because they are the final Github runner images
# with Python 3.8 pre-installed. Brain OS images based on Jetpack 5 use 3.8 as the
# system Python, so we want to test 3.8 even though it is EOL.
os: [ubuntu-22.04, macos-13]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
Expand All @@ -28,7 +27,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: pip3 install -vvv -e .[dev]
run: pip3 install -v -e .[dev]
- name: Run sequential tests
run: ./run_python_tests.sh
- name: Run asyncio tests
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
jobs:
deploy:
name: Deploy to GitHub Pages
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ concurrency:

jobs:
pre-commit-check:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pypi-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-12]
os: [ubuntu-22.04, macos-13]
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -41,7 +41,7 @@ jobs:

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Build sdist
Expand All @@ -52,7 +52,7 @@ jobs:

upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
# Based on https://dev.to/eugenebabichenko/automated-multi-platform-releases-with-github-actions-1abg
create_release:
name: Create Release and Provide Upload URL.
runs-on: ubuntu-latest # OS to create release, not for build
runs-on: ubuntu-20.04 # OS to create release, not for build
outputs:
# This job will provide URL for build jobs to use for uploading assets
upload_url: ${{ steps.create_release.outputs.upload_url }}
Expand Down
2 changes: 1 addition & 1 deletion cpp/sophus/lie/pose3.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class Pose3 {
tangent_in_b_);
}

friend Expected<Tangent> error(
static Expected<Tangent> error(
Pose3 const& lhs_a_from_b, Pose3 const& rhs_a_from_b) {
return (lhs_a_from_b.inverse() * rhs_a_from_b)
.and_then([](Expected<Pose3> const& pose) -> Expected<Tangent> {
Expand Down
5 changes: 3 additions & 2 deletions py/pybind/lie_pybind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,10 @@ void bind_lie(py::module_& m) {
})
.def_static(
"error",
[](Pose3F64 const& lhs_a_from_b, Pose3F64 const& rhs_a_from_b) {
[](Pose3F64 const& lhs_a_from_b,
Pose3F64 const& rhs_a_from_b) -> Eigen::Vector<double, 6> {
farm_ng::Expected<Pose3F64::Tangent> err =
error(lhs_a_from_b, rhs_a_from_b);
Pose3F64::error(lhs_a_from_b, rhs_a_from_b);
if (err) {
return err->array();
}
Expand Down
6 changes: 5 additions & 1 deletion py/tests/test_lie.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,14 @@ def test_pose():

for _i in range(50):
world_from_robot_now = world_from_robot.evolve(dt)
print("world_from_robot:", world_from_robot.log())
print("world_from_robot_now:", world_from_robot_now.log())

# computes the error between frame_b of two respective poses
# e.g. robot and robot now
err = ng.Pose3F64.error(world_from_robot, world_from_robot_now) * (1 / dt)
err_unscaled = ng.Pose3F64.error(world_from_robot, world_from_robot_now)
print("err_unscaled:", err_unscaled)
err = err_unscaled * (1 / dt)
print("err:", err)
print("tan:", world_from_robot_now.tangent_of_b_in_a)
assert np.allclose(err, world_from_robot_now.tangent_of_b_in_a)
Expand Down
2 changes: 1 addition & 1 deletion scripts/install_deps_ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ sudo apt-get -y install \
libtiff-dev \
ninja-build \
python3-dev \
python3.8-venv \
python3-venv \
&& sudo apt-get clean

0 comments on commit b78ce90

Please sign in to comment.