Skip to content

Fix CI Divergence (Mostly mypy)#1293

Open
jeff-hykin wants to merge 55 commits intodevfrom
jeff/fix/ci
Open

Fix CI Divergence (Mostly mypy)#1293
jeff-hykin wants to merge 55 commits intodevfrom
jeff/fix/ci

Conversation

@jeff-hykin
Copy link
Member

@jeff-hykin jeff-hykin commented Feb 18, 2026

READ B4 REVIEW

Why does the new CI workflow have a ARM/MacOS runner?
Why are there modifications to pyproject.toml?

  • Mypy divergence has been a miserable rabbit hole, so please bear with me
  • whether mypy fails/passes depends on EVERY version of EVERY dependency (because it inspects their source code)
    • Easy fix right? uv sync --freeze <ci stuff>
    • no. Because of the <ci stuff>
  • In principle uv sync <ci stuff> shouldn't fail on any system because we should be adding stuff like add "drake; only if linux" guards in our pyproject.toml. But our current pyproject.toml doesn't because we don't have any checks to prevent it (and not everyone should get a jetson and a mac just to test their changes to pyproject.toml)
  • This PR should prevent those pyproject.toml issues from getting on dev (and thus prevent CI divergence)

Why is setup.py modified?

  • Turns out, when testing with the macos-15 github runner, there's a MacOS install issue with dimos. When using a python executable that is universal (which is true for the uv python action on github runners) our C-compiler optimization arguments (e.g. -march=native in setup.py) cause uv sync to break. This is because clang can only perform that optimization if it targets specifically arm64 xor x86 MacOS (can't do it when targeting MacOS's universal executable format). The setup.py keeps the optimization whenever possible.

Why is there a fast-docs.yml?

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
Copy link
Member Author

@jeff-hykin jeff-hykin Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this workflow (documentation checks) the version shouldn't matter

with:
files: 'docs/**/*.md'
fail-on-change: true
# maybe later we can enforce python, for now just do diagram langs
Copy link
Member Author

@jeff-hykin jeff-hykin Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously we weren't checking diagram generation AFAIK, this adds that


- name: Install System dependencies
run: |
# these lines should stay exactly in sync with docs/development/README.md
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an important change: we should have something on CI that matches our docs, and this new test does that

pytest_fast:
strategy:
matrix:
os: [ubuntu-24.04, macos-15, ubuntu-24.04-arm]
Copy link
Member Author

@jeff-hykin jeff-hykin Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussion needed: do we want to host our own macos / linux-arm testers? (or keep this as-is and run on github)

@@ -0,0 +1,26 @@
#!/usr/bin/env bash
Copy link
Member Author

@jeff-hykin jeff-hykin Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is the overlap between local and CI: this file gets executed by CI and is executed locally (when running bin/check-pr)


echo "Running mypy checks"
time uv run mypy --python-version 3.10 dimos
time uv run mypy --python-version 3.12 dimos
Copy link
Member Author

@jeff-hykin jeff-hykin Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be faster by excuting in parallel, but I opted for simplicity. No cache ~5min on github runners, so its pretty fast

@@ -0,0 +1,32 @@
#!/usr/bin/env bash
set -euo pipefail
Copy link
Member Author

@jeff-hykin jeff-hykin Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge #1291 (very small) first and this diff will go away

@@ -0,0 +1,99 @@
#!/usr/bin/env python3
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what everyone should run locally before making a pull request.
It

  1. checks branch name (you can ignore the error and keep going)
  2. runs only doclink checks if only markdown is edited
  3. runs bin/ci-fast if more than just markdown is edited

A lot of good enhancements could be added, but I wanted to start simple

Copy link
Contributor

@paul-nechifor paul-nechifor Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why just the fast tests? Shouldn't people run all the tests? (The non-fast ones are more commonly broken on dev especially since a few of them don't run in CI at all.)

@@ -0,0 +1,68 @@
#!/usr/bin/env bash
Copy link
Member Author

@jeff-hykin jeff-hykin Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't care which branch-naming-scheme we use, I just implemented a check for the one that is listed on our wiki <name>/<type>/<description>

Right now its not a forceful/blocking check it'll just yell at you if it doesnt match

# Install dependencies with UV (10-100x faster than pip)
RUN uv pip install --upgrade 'pip>=24' 'setuptools>=70' 'wheel' 'packaging>=24' && \
uv pip install '.[misc,cpu,sim,drone,unitree,web,perception,visualization]'
uv sync --frozen --extra misc --extra visualization --extra agents --extra web --extra perception --extra unitree --extra manipulation --extra cpu --extra dev --extra sim --extra drone --extra base
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most Important Change

--frozen instead of "close enough" install

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An issue I see here is that this forces us to always run with uv run .... This should be fixable by adding some of the variables which activating gives you. This could be enough:

ENV VIRTUAL_ENV=/app/.venv
ENV PATH="/app/.venv/bin:$PATH"

Another issue that worries me is that uv sync always installs in .venv. The previous command installed in the system python. By installing in /app it means we can't mount our local dir as /app because it would use the .venv we have locally instead of the one in the docker image.

Not sure what the solution is here. (Maybe copy pyproject.toml to /app-deps and install from that dir so the packages are installed outside /app?

- If it only matters to people who contribute to dimos (like this doc), put them in `docs/development`
- Otherwise put them in `docs/usage`
2. Run `bin/gen_diagrams` to generate the svg's for your diagrams. We use [pikchr](https://pikchr.org/home/doc/trunk/doc/userman.md) as a diagram language.
2. Run `bin/gen-diagrams` to generate the svg's for your diagrams. We use [mermaid](https://mermaid.js.org/intro/) (no generation needed) and [pikchr](https://pikchr.org/home/doc/trunk/doc/userman.md) as diagrams languages.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge #1291 (very small) first and this diff will go away

@jeff-hykin jeff-hykin changed the title Fix CI Divergence Fix CI Divergence (Mostly mypy) Feb 18, 2026
cmd: "MYPYPATH=/opt/ros/humble/lib/python3.10/site-packages mypy dimos"
dev-image: ros-dev:${{ (needs.check-changes.outputs.python == 'true' || needs.check-changes.outputs.dev == 'true' || needs.check-changes.outputs.ros == 'true') && needs.ros-dev.result == 'success' && needs.check-changes.outputs.branch-tag || 'dev' }}

# Run module tests directly to avoid pytest forking issues
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we need to restore old code, lets use git as it was meant to be (instead of having giant blocks of commented out code

with:
cmd: "pytest -m heavy"
cmd: "uv run pytest -m heavy"
dev-image: dev:${{ (needs.check-changes.outputs.python == 'true' || needs.check-changes.outputs.dev == 'true') && needs.dev.result == 'success' && needs.check-changes.outputs.branch-tag || 'dev' }}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# Planning (Drake)
"drake>=1.40.0; platform_machine != 'aarch64'",
"drake==1.45.0; sys_platform == 'darwin' and platform_machine != 'aarch64'",
"drake>=1.40.0; sys_platform != 'darwin' and platform_machine != 'aarch64'",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is both a fix for MacOS and Arm. On MacOS drake 1.45.0 is needed, on x86 arm anything >1.40 is okay.

The drake team says they're interested in supporting Arm linux so hopefully that'll come soon

cpu = [
# CPU inference backends
"onnxruntime",
"onnxruntime<1.24; python_version < '3.11'",
Copy link
Member Author

@jeff-hykin jeff-hykin Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI caught this which is great: it was impossible for python 3.10 to have the version of onnx we had specified in the lock file. This guard fixes that

from setuptools import find_packages, setup


def python_is_macos_universal_binary(executable: str | None = None) -> bool:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without this change macos-15 github uv python runner can't uv sync

@jeff-hykin
Copy link
Member Author

@greptile-apps please re-review. Edit your original message if you are able to

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

15 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +3 to +8
on:
pull_request:
- main
- dev
paths:
- 'docs/**'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invalid YAML structure — pull_request needs branches: key and paths must be at same indentation level as pull_request:

Suggested change
on:
pull_request:
- main
- dev
paths:
- 'docs/**'
on:
pull_request:
branches:
- main
- dev
paths:
- 'docs/**'

Comment on lines +44 to +45
# install homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Installing Homebrew on every CI run is slow (~5-10 minutes) and unnecessary. GitHub's macos-15 runners come with Homebrew pre-installed. Remove these lines:

Suggested change
# install homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
elif [ "$(uname)" = "Darwin" ]; then
# install dependencies

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huge fantastic


echo
echo "== dev: pytest -m integration =="
run_in_image "dev" "pytest -m integration"
Copy link
Contributor

@paul-nechifor paul-nechifor Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're running all of them sequentially, you might as well run a single command:

run_in_image "dev" "-m 'not (tool or module or neverending or mujoco)'"

jeff-hykin and others added 2 commits February 18, 2026 21:33
Co-authored-by: Paul Nechifor <paul@nechifor.net>
Co-authored-by: Paul Nechifor <paul@nechifor.net>
secrets: inherit
with:
cmd: "pytest && pytest -m ros" # run tests that depend on ros as well
cmd: "uv run pytest && uv run pytest -m ros" # run tests that depend on ros as well
Copy link
Contributor

@paul-nechifor paul-nechifor Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By changing environment variables we can make the uv python be the default python so that we don't need to prefix with uv run (mentioned in a comment below)

echo "# pytest fast"
echo "# "
echo "# "
time uv run bin/pytest-fast
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pytest-fast has this:

. .venv/bin/activate
exec pytest "$@" dimos

You probably just want to run pytest without any -m, not ./bin/pytest-fast.

set -euo pipefail

echo "Ensuring pip versions are correct"
time uv sync --frozen --extra misc --extra visualization --extra agents --extra web --extra perception --extra unitree --extra manipulation --extra cpu --extra dev --extra sim --extra drone --extra base
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this should be here. In CI, the packages should have been installed in the python step, no?

And locally this removes packages. (I do uv sync --all-extras locally.)

with:
python-version: '3.12'

- name: Run doclinks # Note: doesn't need uv python, just needs some python to run the script
Copy link
Contributor

@leshy leshy Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

git-commit hooks run this, so this is already executed by our code-cleanup action in CI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments