Skip to content

CI Adapt Circle CI script for ARM #21174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Oct 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5221d06
CI Adapt Circle CI script for ARM
jjerphan Sep 28, 2021
b57f219
Apply review suggestions
jjerphan Sep 28, 2021
6dead95
Use the latest supported version of python
jjerphan Sep 28, 2021
664dd21
Initialise mamba before activating the environment
jjerphan Sep 28, 2021
7f90a7a
Source environment directly
jjerphan Sep 28, 2021
c723fe3
Build in editable mode
jjerphan Sep 28, 2021
20efa5e
Change directory to have proper module resolution
jjerphan Sep 29, 2021
2a49a8f
Use mamba consistently
jjerphan Sep 29, 2021
b791c85
Use a single cache for linux-arm64
jjerphan Sep 29, 2021
fd5eaff
Correctly resolve sklearn for pytest
jjerphan Sep 29, 2021
dbeade6
Be verbose on ccache setup and usage
jjerphan Sep 29, 2021
383a9ab
Test using as many workers as available cores
jjerphan Sep 29, 2021
739c7d6
Correct path of ccache cache directory
jjerphan Sep 29, 2021
b0bde20
[cd build] Trigger CI to test ccache cache usage
jjerphan Sep 29, 2021
ba4a498
[DEBUG] Use another CircleCI cache to test ccache setup
jjerphan Sep 29, 2021
3727b7b
[DEBUG] Test if the ccache's cache was populated
jjerphan Sep 30, 2021
96821dd
[DEBUG] List cache content
jjerphan Sep 30, 2021
64aa742
[DEBUG] Unset ccache limits
jjerphan Sep 30, 2021
f0aca1d
[DEBUG] Use yet another CircleCI cache to test ccache setup
jjerphan Sep 29, 2021
0b77c7f
[DEBUG] Inspect ccache cache again
jjerphan Sep 30, 2021
1cbe365
Remove trailing slash in PATH
jjerphan Oct 1, 2021
8d8a134
[DEBUG] Build the project in the source tree
jjerphan Oct 7, 2021
b0572b7
[DEBUG] Add source folder to Circle CI cache
jjerphan Oct 7, 2021
e384508
[DEBUG] Use yet another Circle CI cache
jjerphan Oct 7, 2021
030262a
[DEBUG] Use yet another Circle CI cache
jjerphan Oct 7, 2021
b35797c
[DEBUG] Revert to correct key names
jjerphan Oct 7, 2021
47a7fbc
[DEBUG] Remove temporary logging
jjerphan Oct 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,12 @@ jobs:
image: ubuntu-2004:202101-01
resource_class: arm.medium
environment:
# Use the latest supported version of python
- PYTHON_VERSION: '3.9'
- OMP_NUM_THREADS: 2
- OPENBLAS_NUM_THREADS: 2
- NUMPY_VERSION: 'latest'
- SCIPY_VERSION: 'latest'
- CYTHON_VERSION: 'latest'
- JOBLIB_VERSION: 'latest'
- THREADPOOLCTL_VERSION: 'latest'
Expand All @@ -126,18 +130,16 @@ jobs:
- checkout
- run: ./build_tools/circle/checkout_merge_commit.sh
- restore_cache:
key: v1-datasets-{{ .Branch }}
key: linux-arm64-{{ .Branch }}
- run: ./build_tools/circle/build_test_arm.sh
- save_cache:
key: doc-ccache-{{ .Branch }}-{{ .BuildNum }}
key: linux-arm64-{{ .Branch }}
paths:
- ~/.ccache
- ~/.cache/ccache
- ~/.cache/pip
- save_cache:
key: v1-datasets-{{ .Branch }}
paths:
- ~/scikit_learn_data

# The source build folder.
- ~/project/build
Comment on lines +141 to +142
Copy link
Member

Choose a reason for hiding this comment

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

If we cache the whole build directory, I do not think we need ccache anymore. But we can leave it as is since the PR is already a net improvement.

Copy link
Member

Choose a reason for hiding this comment

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

That's an interesting point :)

deploy:
docker:
- image: circleci/python:3.7
Expand Down
78 changes: 53 additions & 25 deletions build_tools/circle/build_test_arm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ set -e
set -x

UNAMESTR=`uname`
N_CORES=`nproc --all`


setup_ccache() {
echo "Setting up ccache"
Expand All @@ -12,49 +14,75 @@ setup_ccache() {
for name in gcc g++ cc c++ x86_64-linux-gnu-gcc x86_64-linux-gnu-c++; do
ln -s $(which ccache) "/tmp/ccache/${name}"
done
export PATH="/tmp/ccache/:${PATH}"
ccache -M 256M
export PATH="/tmp/ccache:${PATH}"
# Unset ccache limits
ccache -F 0
ccache -M 0
}

# imports get_dep
source build_tools/shared.sh

sudo add-apt-repository --remove ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install python3-virtualenv ccache
python3 -m virtualenv --system-site-packages --python=python3 testenv
source testenv/bin/activate
pip install --upgrade pip

# Setup conda environment
MINICONDA_URL="https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-Linux-aarch64.sh"

# Install Mambaforge
wget $MINICONDA_URL -O mambaforge.sh
MINICONDA_PATH=$HOME/miniconda
chmod +x mambaforge.sh && ./mambaforge.sh -b -p $MINICONDA_PATH
export PATH=$MINICONDA_PATH/bin:$PATH
mamba init --all --verbose
mamba update --yes conda

# Create environment and install dependencies
mamba create -n testenv --yes $(get_dep python $PYTHON_VERSION)
source activate testenv

# Use the latest by default
mamba install --verbose -y ccache \
pip \
$(get_dep numpy $NUMPY_VERSION) \
$(get_dep scipy $SCIPY_VERSION) \
$(get_dep cython $CYTHON_VERSION) \
$(get_dep joblib $JOBLIB_VERSION) \
$(get_dep threadpoolctl $THREADPOOLCTL_VERSION) \
$(get_dep pytest $PYTEST_VERSION) \
$(get_dep pytest-xdist $PYTEST_XDIST_VERSION)
setup_ccache
python -m pip install $(get_dep cython $CYTHON_VERSION) \
$(get_dep joblib $JOBLIB_VERSION)
python -m pip install $(get_dep threadpoolctl $THREADPOOLCTL_VERSION) \
$(get_dep pytest $PYTEST_VERSION) \
$(get_dep pytest-xdist $PYTEST_XDIST_VERSION)

if [[ "$COVERAGE" == "true" ]]; then
python -m pip install codecov pytest-cov
fi

if [[ "$PYTEST_XDIST_VERSION" != "none" ]]; then
python -m pip install pytest-xdist
mamba install --verbose -y codecov pytest-cov
fi

if [[ "$TEST_DOCSTRINGS" == "true" ]]; then
# numpydoc requires sphinx
python -m pip install sphinx
python -m pip install numpydoc
mamba install --verbose -y sphinx
mamba install --verbose -y numpydoc
fi

python --version

# Set parallelism to 3 to overlap IO bound tasks with CPU bound tasks on CI
# workers with 2 cores when building the compiled extensions of scikit-learn.
export SKLEARN_BUILD_PARALLEL=3
# Set parallelism to $N_CORES + 1 to overlap IO bound tasks with CPU bound tasks on CI
# workers with $N_CORES cores when building the compiled extensions of scikit-learn.
export SKLEARN_BUILD_PARALLEL=$(($N_CORES + 1))

# Disable the build isolation and build in the tree so that the same folder can be
# cached between CI runs.
# TODO: remove the '--use-feature' flag when made obsolete in pip 21.3.
pip install --verbose --no-build-isolation --use-feature=in-tree-build .

# Report cache usage
ccache -s --verbose

mamba list

python -m pip list
pip install --verbose --editable .
ccache -s
# Changing directory not to have module resolution use scikit-learn source
# directory but to the installed package.
cd /tmp
python -c "import sklearn; sklearn.show_versions()"
python -m threadpoolctl --import sklearn
python -m pytest sklearn
# Test using as many workers as available cores
pytest --pyargs -n $N_CORES sklearn