Skip to content
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

[ci] use conda-forge in Linux and macOS CI jobs #4953

Merged
merged 86 commits into from
Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
771889f
[ci] use conda-forge in CI jobs (fixes #4948)
jameslamb Jan 16, 2022
33642db
comment out more jobs
jameslamb Jan 16, 2022
6fb5c51
try reverting graphviz patch, running more cuda jobs
jameslamb Jan 16, 2022
ec3378a
get graphviz from PyPI and try removing some patches for r-lintr
jameslamb Jan 16, 2022
d6705ce
start running appveyor again
jameslamb Jan 16, 2022
83fbe0f
use conda-forge if using conda
jameslamb Jan 16, 2022
d365aeb
fix commands
jameslamb Jan 16, 2022
59070c3
conda install graphviz
jameslamb Jan 16, 2022
87804fe
try newer openmp
jameslamb Jan 17, 2022
2455e0d
pin below openmp 11.x
jameslamb Jan 17, 2022
3b6b0c0
focus on gpu task
jameslamb Jan 17, 2022
ab20d1f
trying to narrow down error
jameslamb Jan 17, 2022
592252f
maybe gcc11 is the issue
jameslamb Jan 17, 2022
7e2763e
start adding other tests back
jameslamb Jan 17, 2022
c066906
pin openmp too
jameslamb Jan 17, 2022
1cac6f8
maybe need to pin to gcc less than 10.x
jameslamb Jan 17, 2022
7777b10
pin libgfortran and libstdcxx as well
jameslamb Jan 17, 2022
8897fa8
pin to gcc 9.3.0
jameslamb Jan 17, 2022
be2ad19
move constraints up to initial environment
jameslamb Jan 17, 2022
b4a2eef
add all CI jobs back
jameslamb Jan 17, 2022
92d4956
try installing python-graphviz separately
jameslamb Jan 17, 2022
a1a9cc3
try new lightgbm/vsts-agent image
jameslamb Jan 17, 2022
9c72d0e
fix typo
jameslamb Jan 17, 2022
94d226e
test if pinning gcc for linux gpu_source build is still necessary
jameslamb Jan 17, 2022
5ea98b9
ok yes, pinning gcc is necessary
jameslamb Jan 17, 2022
53d55fa
test if Linux gpu_source works with Python 3.9.6
jameslamb Jan 19, 2022
30b5e39
no special exception for Linux gpu_source job
jameslamb Jan 19, 2022
e271e62
pin to Python 3.9.6 in Linux gpu_source
jameslamb Jan 19, 2022
c9ba0b2
try explicitly asking for libstdcxx-ng for every linux build
jameslamb Jan 19, 2022
4bf9af4
swap compilers
jameslamb Jan 19, 2022
5808c24
switch compilers back
jameslamb Jan 19, 2022
d1db657
revert accidental whitespace change
jameslamb Jan 19, 2022
c4cf301
Merge branch 'master' into ci/conda-forge
jameslamb Jan 20, 2022
7042755
Merge branch 'ci/conda-forge' of github.com:microsoft/LightGBM into c…
jameslamb Jan 20, 2022
ece191f
comment out CI
jameslamb Jan 20, 2022
f6f63cb
try Linux gpu_source with different Python versions
jameslamb Jan 20, 2022
41f4afa
Revert "try Linux gpu_source with different Python versions"
jameslamb Jan 20, 2022
11d104f
Revert "comment out CI"
jameslamb Jan 20, 2022
bc750fb
remove libxml2 install, change CONDA path
jameslamb Jan 22, 2022
3457be7
Merge branch 'master' into ci/conda-forge
jameslamb Jan 22, 2022
44de0ba
avoid installing conda in rchk job
jameslamb Jan 22, 2022
5fadcff
empty commit 1
StrikerRUS Jan 23, 2022
1256e2c
empty commit 2
jameslamb Jan 23, 2022
6bfd496
empty commit 3
StrikerRUS Jan 23, 2022
5ab1789
empty commit 4
StrikerRUS Jan 23, 2022
3dc3907
Merge branch 'master' into ci/conda-forge
jameslamb Jan 26, 2022
537fbd4
add more verbose logging around installation of python-graphviz
jameslamb Jan 26, 2022
4776f16
empty commit 1
jameslamb Jan 30, 2022
bf227b4
get mamba info
jameslamb Jan 30, 2022
a49cefb
get more conda info
jameslamb Jan 30, 2022
de2be6f
add another mamba info call
jameslamb Jan 30, 2022
a3c7a19
allow for other macOS environments in GHA configuration
jameslamb Jan 30, 2022
e5b5435
Revert "allow for other macOS environments in GHA configuration"
jameslamb Jan 30, 2022
bdba86c
get more logs from mamba
jameslamb Jan 30, 2022
0487a8c
get Build.ArtifactsStagingDirectory
jameslamb Jan 30, 2022
9078fb0
get more logs and try to force re-installing everything
jameslamb Jan 30, 2022
c82fe21
clean cache after every step
jameslamb Jan 30, 2022
10c68a8
remove --update-all and make logs less verbose
jameslamb Jan 30, 2022
a450ed1
remove more print statements and uncomment jobs
jameslamb Jan 31, 2022
2b1a940
Merge branch 'master' into ci/conda-forge
jameslamb Feb 1, 2022
33a199e
test if conda-clean issue fixes segfaults for gpu_source
jameslamb Feb 1, 2022
986dad6
pin python version for gpu_source
jameslamb Feb 1, 2022
591a68a
empty commit 1
jameslamb Feb 1, 2022
d9550c4
use miniforge instead
jameslamb Feb 4, 2022
bd472b4
empty commit 1
jameslamb Feb 4, 2022
932cc93
Apply suggestions from code review
StrikerRUS Feb 4, 2022
5e033ad
bring workarounds back
StrikerRUS Feb 4, 2022
b33195e
remove duplicated graphviz system-wide installation (reverts #4095, #…
StrikerRUS Feb 4, 2022
304230b
empty commit 1
StrikerRUS Feb 5, 2022
812a535
empty commit 2
StrikerRUS Feb 5, 2022
263fb05
empty commit 3
StrikerRUS Feb 5, 2022
4149f99
empty commit 4
StrikerRUS Feb 5, 2022
a5173d9
empty commit 5
StrikerRUS Feb 5, 2022
6e4a8d6
empty commit 6
StrikerRUS Feb 5, 2022
79797fc
empty commit 7
StrikerRUS Feb 5, 2022
6052a0f
empty commit 8
StrikerRUS Feb 5, 2022
cee93ac
empty commit 9
StrikerRUS Feb 5, 2022
ce5154e
empty commit 10
StrikerRUS Feb 5, 2022
10a6956
empty commit 10
StrikerRUS Feb 5, 2022
a67af60
empty commit 10
StrikerRUS Feb 5, 2022
66d05f4
empty commit 10
StrikerRUS Feb 6, 2022
543abe2
empty commit 11
StrikerRUS Feb 6, 2022
b36d2ae
one more try
StrikerRUS Feb 6, 2022
8f26585
try to downgrade Python version for Linux GPU job
StrikerRUS Feb 6, 2022
f04dc27
swap compilers
StrikerRUS Feb 6, 2022
1aa67bd
Revert "swap compilers"
StrikerRUS Feb 6, 2022
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
11 changes: 5 additions & 6 deletions .ci/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if [[ $OS_NAME == "macos" ]]; then
brew install swig
fi
brew install graphviz
curl -sL -o conda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
curl -sL -o conda.sh https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-MacOSX-x86_64.sh
jameslamb marked this conversation as resolved.
Show resolved Hide resolved
else # Linux
if [[ $IN_UBUNTU_LATEST_CONTAINER == "true" ]]; then
# fixes error "unable to initialize frontend: Dialog"
Expand Down Expand Up @@ -121,11 +121,10 @@ else # Linux
fi
fi
if [[ $SETUP_CONDA != "false" ]]; then
if [[ $ARCH == "x86_64" ]]; then
curl -sL -o conda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
else
curl -sL -o conda.sh https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-${ARCH}.sh
fi
curl \
-sL \
-o conda.sh \
jameslamb marked this conversation as resolved.
Show resolved Hide resolved
https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-Linux-${ARCH}.sh
fi
fi

Expand Down
61 changes: 47 additions & 14 deletions .ci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,29 @@ if [[ "$TASK" == "cpp-tests" ]]; then
exit 0
fi

conda create -q -y -n $CONDA_ENV python=$PYTHON_VERSION
# Ubuntu 14.04 jobs using https://github.com/guolinke/lightgbm-ci-docker do not have mambaforge
if [[ $SETUP_CONDA == "false" ]]; then
CONDA_CREATE="conda create -c conda-forge --override-channels"
CONDA_INSTALL="conda install -c conda-forge --override-channels"
else
CONDA_CREATE="mamba create"
CONDA_INSTALL="mamba install"
fi

# on Ubuntu 14.04, GPU build segfaults with gcc 11.x
INITIAL_CONDA_CONSTRAINTS="python=${PYTHON_VERSION}"
if [[ $TASK == "gpu" ]] && [[ $OS_NAME == "linux" ]] && [[ $IN_UBUNTU_LATEST_CONTAINER != "true" ]]; then
INITIAL_CONDA_CONSTRAINTS="${INITIAL_CONDA_CONSTRAINTS} libgcc-ng=9.3.0 libgomp=9.3.0"
fi

${CONDA_CREATE} -q -y -n $CONDA_ENV ${INITIAL_CONDA_CONSTRAINTS}
source activate $CONDA_ENV

cd $BUILD_DIRECTORY

if [[ $TASK == "check-docs" ]] || [[ $TASK == "check-links" ]]; then
cd $BUILD_DIRECTORY/docs
# NOTE: this job uses conda instead of mamba for consistency with RTD builds
jameslamb marked this conversation as resolved.
Show resolved Hide resolved
conda install -q -y -n $CONDA_ENV -c conda-forge doxygen rstcheck
pip install --user -r requirements.txt
# check reStructuredText formatting
Expand All @@ -61,17 +77,15 @@ if [[ $TASK == "check-docs" ]] || [[ $TASK == "check-links" ]]; then
fi

if [[ $TASK == "lint" ]]; then
conda install -q -y -n $CONDA_ENV \
${CONDA_INSTALL} -q -y -n $CONDA_ENV \
cmakelint \
cpplint \
isort \
libxml2 \
jameslamb marked this conversation as resolved.
Show resolved Hide resolved
mypy \
pycodestyle \
pydocstyle \
r-stringi # stringi needs to be installed separate from r-lintr to avoid issues like 'unable to load shared object stringi.so'
# r-xfun below has to be upgraded because lintr requires > 0.19 for that package
conda install -q -y -n $CONDA_ENV \
-c conda-forge \
libxml2 \
"r-xfun>=0.19" \
"r-lintr>=2.0"
pip install --user cmakelint cpplint isort mypy
"r-lintr>=2.0"
echo "Linting Python code"
pycodestyle --ignore=E501,W503 --exclude=./.nuget,./external_libs . || exit -1
pydocstyle --convention=numpy --add-ignore=D105 --match-dir="^(?!^external_libs|test|example).*" --match="(?!^test_|setup).*\.py" . || exit -1
Expand All @@ -87,7 +101,7 @@ if [[ $TASK == "lint" ]]; then
fi

if [[ $TASK == "if-else" ]]; then
conda install -q -y -n $CONDA_ENV numpy
${CONDA_INSTALL} -q -y -n $CONDA_ENV numpy
mkdir $BUILD_DIRECTORY/build && cd $BUILD_DIRECTORY/build && cmake .. && make lightgbm -j4 || exit -1
cd $BUILD_DIRECTORY/tests/cpp_tests && ../../lightgbm config=train.conf convert_model_language=cpp convert_model=../../src/boosting/gbdt_prediction.cpp && ../../lightgbm config=predict.conf output_result=origin.pred || exit -1
cd $BUILD_DIRECTORY/build && make lightgbm -j4 || exit -1
Expand All @@ -114,8 +128,23 @@ if [[ $TASK == "swig" ]]; then
exit 0
fi

conda install -q -y -n $CONDA_ENV cloudpickle "dask=2021.9.1" "distributed=2021.9.1" joblib matplotlib numpy pandas psutil pytest scikit-learn scipy
pip install graphviz # python-graphviz from Anaconda is not allowed to be installed with Python 3.9

${CONDA_INSTALL} -q -y -n $CONDA_ENV \
cloudpickle \
dask \
distributed \
jmoralez marked this conversation as resolved.
Show resolved Hide resolved
joblib \
matplotlib \
numpy \
pandas \
psutil \
pytest \
scikit-learn \
scipy || exit -1

# python-graphviz has to be installed separately to prevent conda from downgrading to pypy
${CONDA_INSTALL} -q -y -n $CONDA_ENV \
python-graphviz || exit -1
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Only for the specific of case of Linux sdist (Python 3.7, ubuntu:14.04, gcc), I found that conda was downgrading Python from a cpython-based Python 3.7.12 to a PyPy-based Python 3.7.12: #4953 (comment)

Was able to reproduce this locally in Docker.

docker run \
    --rm \
    --env CONDA=/opt/conda \
    --entrypoint="" \
    -it lightgbm/vsts-agent:ubuntu-14.04 \
    /bin/bash

# then run the following in the container
export PATH=${CONDA}/bin:${PATH}

conda create \
    --name test-env \
    -c conda-forge \
    --override-channels \
        python=3.7

conda config --set always_yes yes --set changeps1 no
conda update -q -y conda

source activate test-env
conda install -c conda-forge --override-channels -q -y -n test-env \
    cloudpickle \
    dask \
    distributed \
    joblib \
    matplotlib \
    numpy \
    pandas \
    psutil \
    python-graphviz \
    pytest \
    scikit-learn \
    scipy

This resulted in the following from the conda install logs

The following packages will be DOWNGRADED:

  python                        3.7.12-hf930737_100_cpython --> 3.7.12-0_73_pypy
  python_abi                                    3.7-2_cp37m --> 3.7-2_pypy37_pp73
  setuptools                          60.5.0-py37h89c1867_0 --> 59.8.0-py37h9c2f6ca_0

So I started thinking "ok, what is changing in this PR? One thing I'm proposing changing in this PR is installing python-graphviz with conda instead of as a separate pip install, to reduce the risk of conflicts.

Funny enough, it seems like that change was the cause for conda choosing PyPy. Using the sample code above, I found that installing python-graphviz by itself, separately, does not result in conda choosing to downgrade from a cpython-based Python to the PyPy one.


if [[ $OS_NAME == "macos" ]] && [[ $COMPILER == "clang" ]]; then
# fix "OMP: Error #15: Initializing libiomp5.dylib, but found libomp.dylib already initialized." (OpenMP library conflict due to conda's MKL)
Expand Down Expand Up @@ -229,7 +258,11 @@ import matplotlib\
matplotlib.use\(\"Agg\"\)\
' plot_example.py # prevent interactive window mode
sed -i'.bak' 's/graph.render(view=True)/graph.render(view=False)/' plot_example.py
conda install -q -y -n $CONDA_ENV h5py ipywidgets notebook # requirements for examples
# requirements for examples
${CONDA_INSTALL} -q -y -n $CONDA_ENV \
h5py \
ipywidgets \
notebook
for f in *.py **/*.py; do python $f || exit -1; done # run all examples
cd $BUILD_DIRECTORY/examples/python-guide/notebooks
sed -i'.bak' 's/INTERACTIVE = False/assert False, \\"Interactive mode disabled\\"/' interactive_plot_example.ipynb
Expand Down
120 changes: 60 additions & 60 deletions .github/workflows/r_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,66 +179,66 @@ jobs:
$env:GITHUB_ACTIONS = "true"
$env:TASK = "${{ matrix.task }}"
& "$env:GITHUB_WORKSPACE/.ci/test_windows.ps1"
test-r-sanitizers:
name: r-sanitizers (ubuntu-latest, R-devel, ${{ matrix.compiler }} ASAN/UBSAN)
timeout-minutes: 60
runs-on: ubuntu-latest
container: wch1/r-debug
strategy:
fail-fast: false
matrix:
include:
- r_customization: san
compiler: gcc
- r_customization: csan
compiler: clang
steps:
- name: Checkout repository
uses: actions/[email protected]
with:
fetch-depth: 5
submodules: true
- name: Install packages
shell: bash
run: |
RDscript${{ matrix.r_customization }} -e "install.packages(c('R6', 'data.table', 'jsonlite', 'knitr', 'Matrix', 'rmarkdown', 'testthat'), repos = 'https://cran.r-project.org', Ncpus = parallel::detectCores())"
sh build-cran-package.sh --r-executable=RD${{ matrix.r_customization }}
RD${{ matrix.r_customization }} CMD INSTALL lightgbm_*.tar.gz || exit -1
- name: Run tests with sanitizers
shell: bash
run: |
cd R-package/tests
exit_code=0
RDscript${{ matrix.r_customization }} testthat.R >> tests.log 2>&1 || exit_code=-1
cat ./tests.log
exit ${exit_code}
test-r-debian-clang:
name: r-package (debian, R-devel, clang)
timeout-minutes: 60
runs-on: ubuntu-latest
container: rhub/debian-clang-devel
steps:
- name: Install Git before checkout
shell: bash
run: |
apt-get update --allow-releaseinfo-change
apt-get install --no-install-recommends -y git
- name: Checkout repository
uses: actions/[email protected]
with:
fetch-depth: 5
submodules: true
- name: Install packages and run tests
shell: bash
run: |
export PATH=/opt/R-devel/bin/:${PATH}
Rscript -e "install.packages(c('R6', 'data.table', 'jsonlite', 'knitr', 'Matrix', 'rmarkdown', 'testthat'), repos = 'https://cran.r-project.org', Ncpus = parallel::detectCores())"
sh build-cran-package.sh
R CMD check --as-cran --run-donttest lightgbm_*.tar.gz || exit -1
if grep -q -E "NOTE|WARNING|ERROR" lightgbm.Rcheck/00check.log; then
echo "NOTEs, WARNINGs, or ERRORs have been found by R CMD check"
exit -1
fi
# test-r-sanitizers:
# name: r-sanitizers (ubuntu-latest, R-devel, ${{ matrix.compiler }} ASAN/UBSAN)
# timeout-minutes: 60
# runs-on: ubuntu-latest
# container: wch1/r-debug
# strategy:
# fail-fast: false
# matrix:
# include:
# - r_customization: san
# compiler: gcc
# - r_customization: csan
# compiler: clang
# steps:
# - name: Checkout repository
# uses: actions/[email protected]
# with:
# fetch-depth: 5
# submodules: true
# - name: Install packages
# shell: bash
# run: |
# RDscript${{ matrix.r_customization }} -e "install.packages(c('R6', 'data.table', 'jsonlite', 'knitr', 'Matrix', 'rmarkdown', 'testthat'), repos = 'https://cran.r-project.org', Ncpus = parallel::detectCores())"
# sh build-cran-package.sh --r-executable=RD${{ matrix.r_customization }}
# RD${{ matrix.r_customization }} CMD INSTALL lightgbm_*.tar.gz || exit -1
# - name: Run tests with sanitizers
# shell: bash
# run: |
# cd R-package/tests
# exit_code=0
# RDscript${{ matrix.r_customization }} testthat.R >> tests.log 2>&1 || exit_code=-1
# cat ./tests.log
# exit ${exit_code}
# test-r-debian-clang:
# name: r-package (debian, R-devel, clang)
# timeout-minutes: 60
# runs-on: ubuntu-latest
# container: rhub/debian-clang-devel
# steps:
# - name: Install Git before checkout
# shell: bash
# run: |
# apt-get update --allow-releaseinfo-change
# apt-get install --no-install-recommends -y git
# - name: Checkout repository
# uses: actions/[email protected]
# with:
# fetch-depth: 5
# submodules: true
# - name: Install packages and run tests
# shell: bash
# run: |
# export PATH=/opt/R-devel/bin/:${PATH}
# Rscript -e "install.packages(c('R6', 'data.table', 'jsonlite', 'knitr', 'Matrix', 'rmarkdown', 'testthat'), repos = 'https://cran.r-project.org', Ncpus = parallel::detectCores())"
# sh build-cran-package.sh
# R CMD check --as-cran --run-donttest lightgbm_*.tar.gz || exit -1
# if grep -q -E "NOTE|WARNING|ERROR" lightgbm.Rcheck/00check.log; then
# echo "NOTEs, WARNINGs, or ERRORs have been found by R CMD check"
# exit -1
# fi
all-successful:
# https://github.community/t/is-it-possible-to-require-all-github-actions-tasks-to-pass-without-enumerating-them/117957/4?u=graingert
runs-on: ubuntu-latest
Expand Down