Skip to content

Refactor GitHub's CI config and helper scripts#7672

Merged
lagru merged 19 commits intoscikit-image:mainfrom
stefanv:refactor-gh-scripts
Jan 30, 2025
Merged

Refactor GitHub's CI config and helper scripts#7672
lagru merged 19 commits intoscikit-image:mainfrom
stefanv:refactor-gh-scripts

Conversation

@stefanv
Copy link
Member

@stefanv stefanv commented Jan 24, 2025

I found the naming of the GH scripts confusing, and they didn't seem to stick to their respective purposes. So, I shuffled things around a bit to make it more consistent, and documented the variables.

@stefanv stefanv added the 🤖 type: Infrastructure CI, packaging, tools and automation label Jan 24, 2025
Copy link
Member

Choose a reason for hiding this comment

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

We might want to get rid of this script altogether in a follow-up PR. It is a lot more "trivial" now. Might make our CI more readable to not have the extra layer of abstraction.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, I got rid of it

@stefanv stefanv force-pushed the refactor-gh-scripts branch 5 times, most recently from bf0aa33 to e018ee7 Compare January 29, 2025 08:01
@stefanv
Copy link
Member Author

stefanv commented Jan 29, 2025

The windows runners are now by far the slowest. The gallery build took 40 minutes, where it takes 10 minutes on the aarch64 runner, so I removed it. I thought we may be able to get faster machines, but the documentation suggests we cannot.

Slightly bizarrely, the Windows runner specs differ between Azure Pipelines and GitHub:

GH: 4 cpu, 16 GB RAM, 14 GB SSD
Azure: 2 core CPU, 7 GB RAM, 14 GB of SSD

If parallelization weren't an issue, I'd have said we should switch immediately.

Maybe we should ask GitHub if they'd raise our quota? /cc @jarrodmillman

Copy link
Contributor

@jarrodmillman jarrodmillman left a comment

Choose a reason for hiding this comment

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

Thanks!!!

# TODO: delete when scipy, numpy, cython and pywavelets free-threaded wheels are available on PyPi
FREE_THREADED_BUILD="$(python -c"import sysconfig; print(bool(sysconfig.get_config_var('Py_GIL_DISABLED')))")"
if [[ $FREE_THREADED_BUILD == "True" ]]; then
pip install --pre -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple cython numpy scipy pywavelets
Copy link
Member

Choose a reason for hiding this comment

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

Do we need Cython during testing?

Suggested change
pip install --pre -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple cython numpy scipy pywavelets
pip install --pre -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy scipy pywavelets

Copy link
Member

Choose a reason for hiding this comment

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

Still curious about this. But not critical I think since we plan to remove this eventually anyway.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, we should get rid of this as soon as free-threaded builds are more commonly available.

echo "Installing docs / examples dependencies..."
# Use previous installed requirements as well, otherwise installing
# successively may update previously constraint dependencies
python -m pip install $PIP_FLAGS $REQUIREMENT_FILES -r ./requirements/docs.txt
Copy link
Member

Choose a reason for hiding this comment

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

Should we make sure that $REQUIREMENT_FILES includes default.txt, and optional.txt (if needed) regardless of setup_test_env.sh being run? Also are we sure that $REQUIREMENT_FILES sticks from running setup_test_env.sh before?

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 a remnant from the previous script; I will remove $REQUIREMENT_FILES, since there's really no need to robustly check the docs build under minimum AND latest dependencies. User should only need to be able to build docs after pip install -r requirements/docs.txt.

Docs are a small subset of functionality that should be covered by regular test suite.
Docs examples should work, of course, which is why it needs to be run once. But library functionality should be tested in the test suite, and all platforms.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, might be good to check that there's a working dependency solution between "default", "test", "optional" and "docs" for local development. But agreed not critical right now. Might be something we think about, when / if we update our dependency groups though.

Copy link
Member Author

Choose a reason for hiding this comment

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

We could build some checking logic into tools/generate_requirements.py?

# Build the documentation
choco install optipng
export SPHINXCACHE=${AGENT_BUILDDIRECTORY}/.cache/sphinx
export SPHINXOPTS="-W -j auto"
Copy link
Member

@lagru lagru Jan 29, 2025

Choose a reason for hiding this comment

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

I think this is currently the only place in our CI where we fail on warnings for Sphinx. We should make sure to add that flag in another job.

To be honest, I would prefer if we discuss and deal with removing docs on Azure separately. See also #7658 that proposes a different route.

Copy link
Member

Choose a reason for hiding this comment

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

To be clear. Not a blocker, just noting that I'd like to keep testing our doc pipeline on Windows in some form. Might be good to get those faster runners from GitHub so this is no longer a huge time sink!

Copy link
Member Author

Choose a reason for hiding this comment

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

I emailed GH about the faster runners earlier today, and will be happy to reinstate the Windows docs build if we are able to get those going. The 4x build time is a major blocker right now for getting CI build times down. I saw the differently proposed route, and will be happy to add that if you and @jarrodmillman come to an agreement.

Copy link
Member Author

Choose a reason for hiding this comment

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

Noted about the warnings, thanks.

Comment on lines +24 to +27
if [[ $MINIMUM_REQUIREMENTS == 1 ]]; then
for filename in requirements/*.txt; do
sed -i 's/>=/==/g' "$filename"
done
fi
Copy link
Member

Choose a reason for hiding this comment

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

This could also sed the dependencies in pyproject.toml. Otherwise pip install . to be safe?

Copy link
Member Author

Choose a reason for hiding this comment

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

It requires a bit more finesse to do this in the pyproject.toml, because you'd need to avoid areas other than the test dependencies. I can double check that all pip installs are with --build-isolation.

- name: Run tests
run: source tools/github/script.sh
run: |
(cd .. && pytest --doctest-plus --showlocals --pyargs skimage)
Copy link
Member

Choose a reason for hiding this comment

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

This will miss the pytest config in pyproject.toml but we will deal with that in a separate PR.


test_docs_aarch64:
name: macos-docs
runs-on: ubuntu-24.04-arm
Copy link
Member

Choose a reason for hiding this comment

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

Did you chose aarch64 / ARM because its the fastest right now?

Copy link
Member Author

Choose a reason for hiding this comment

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

Exactly; we can reduce the 40 minute doc build down to 10 minutes.

Copy link
Member

@lagru lagru left a comment

Choose a reason for hiding this comment

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

Wow, this seems like a huge step in making our CI config feel more sane. 🙏 Thanks Stéfan. I've left a few suggestions that I think would be good to include here. Approving anyway since all those things could be dealt with in follow-up PRs as well.

Though, there are a few places where I'd like a clarification or your perspective.

@stefanv stefanv force-pushed the refactor-gh-scripts branch from 02b8e0a to 7ee2cd8 Compare January 29, 2025 21:31
@stefanv stefanv force-pushed the refactor-gh-scripts branch from 7ee2cd8 to 891b6fd Compare January 29, 2025 21:31
@stefanv
Copy link
Member Author

stefanv commented Jan 30, 2025

We should now have access to the Windows runners we need on GA. I'll refactor to use those as soon as we get this in.

- name: Build and install from source
if: ${{ matrix.INSTALL_FROM_SDIST != 1 }}
run: |
pip install -vv --no-build-isolation .
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering now why we actually use --no-build-isolation at all. Seems to me that we could remove the "Install build dependencies" step before and simply rely on pip install to do its thing?

Might be something we could look into as a follow-up simplification. But not terribly important.

Copy link
Member

Choose a reason for hiding this comment

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

You actually set it up this way already for INSTALL_FROM_SDIST which skips installing the builds and uses an isolated build env.

Copy link
Member Author

Choose a reason for hiding this comment

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

I suppose it shortens the subsequent testing and documentation dependency installation steps, but it's not a big deal; we could, indeed, remove that step.

@lagru lagru merged commit 81acd3b into scikit-image:main Jan 30, 2025
18 of 25 checks passed
@lagru lagru changed the title Refactor gh scripts Refactor GitHub's CI config and helper scripts Jan 30, 2025
@lagru
Copy link
Member

lagru commented Jan 30, 2025

Thank you, Stéfan! Really happy with the direction we are going here. The better separation into steps, on its own, makes the CI logs already easier to navigate. 😊

matthew-brett added a commit to matthew-brett/scikit-image that referenced this pull request Jan 30, 2025
…ailure

* origin/main:
  Refactor GitHub's CI config and helper scripts (scikit-image#7672)
@stefanv stefanv mentioned this pull request Feb 3, 2025
@stefanv stefanv added this to the 0.25.2 milestone Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖 type: Infrastructure CI, packaging, tools and automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants