Skip to content

Commit

Permalink
add environment files
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb committed Mar 22, 2024
1 parent 5b4685f commit f6a8d99
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 35 deletions.
Empty file added .ci/conda-envs/README.md
Empty file.
56 changes: 56 additions & 0 deletions .ci/conda-envs/ci-core-py37.txt
@@ -0,0 +1,56 @@
# [description]
#
# Similar to ci-core.txt, but specific to Python 3.7.
#
# Unlike ci-core.txt, this includes a Python version and uses
# `=` and `<=` pins to make solves faster and prevent against
# issues like https://github.com/microsoft/LightGBM/pull/6370.
#
# [usage]
#
# conda create \
# --name test-env \
# --file ./.ci/conda-envs/ci-core-py37.txt
#

# python
python=3.7.12

# direct imports
cffi=1.15.*
# older versions of Dask are incompatible with pandas>=2.0, but not all conda packages' metadata accurately reflects that
#
# ref: https://github.com/microsoft/LightGBM/issues/6030
dask=2022.2.*
distributed=2022.2.*
joblib=1.3.*
matplotlib-base=3.5.*
numpy=1.21.*
pandas=1.3.*
pyarrow=9.0.*
# python-graphviz 0.20.2 is not compatible with Python 3.7
# ref: https://github.com/microsoft/LightGBM/pull/6370
python-graphviz=0.20.1
scikit-learn=1.0.*
scipy=1.7.*

# testing-only dependencies
cloudpickle=2.2.*
pluggy=1.0.*
psutil=5.9.3
pytest=7.4.*

# other recursive dependencies, just
# pinned here to help speed up solves
bokeh=2.4.*
fsspec=2023.1.*
msgpack-python=1.0.*
pluggy=1.0.*
pytz=2024.1
setuptools=59.8.*
snappy=1.1.*
tomli=2.0.*
tornado=6.1.*
wheel=0.43.*
zict=2.2.*
zipp=3.15.*
40 changes: 40 additions & 0 deletions .ci/conda-envs/ci-core.txt
@@ -0,0 +1,40 @@
# [description]
#
# Core dependencies used across most LightGBM continuous integration (CI) jobs.
#
# 'python' constraint is intentionally omitted, so this file can be reused across
# Python versions.
#
# These floors are not the oldest versions LightGBM supports... they're here just to make conda
# solves faster, and should generally be the latest versions that work for all CI jobs using this.
#
# [usage]
#
# conda create \
# --name test-env \
# --file ./.ci/conda-envs/ci-core.txt \
# python=3.10
#

# direct imports
conda-forge::cffi>=1.16
dask>=2023.5.0
joblib>=1.3.2
matplotlib-base>=3.7.3
numpy>=1.24.4
pandas>2.0
pyarrow>=6.0
python-graphviz>=0.20.3
scikit-learn>=1.3.2
scipy>=1.1

# testing-only dependencies
cloudpickle>=3.0.0
psutil>=5.9.8
pytest>=8.1.1

# other recursive dependencies, just
# pinned here to help speed up solves
pluggy>=1.4.0
setuptools>=69.2
wheel>=0.43
31 changes: 9 additions & 22 deletions .ci/test.sh
Expand Up @@ -36,6 +36,7 @@ if [[ "$TASK" == "cpp-tests" ]]; then
exit 0
fi

# including python=version[build=*cpython] to ensure that conda doesn't fall back to pypy
CONDA_PYTHON_REQUIREMENT="python=$PYTHON_VERSION[build=*cpython]"

if [[ $TASK == "if-else" ]]; then
Expand Down Expand Up @@ -121,32 +122,18 @@ if [[ $TASK == "check-docs" ]] || [[ $TASK == "check-links" ]]; then
exit 0
fi

# older versions of Dask are incompatible with pandas>=2.0, but not all conda packages' metadata accurately reflects that
#
# ref: https://github.com/microsoft/LightGBM/issues/6030
CONSTRAINED_DEPENDENCIES="'dask>=2023.5.0' 'distributed>=2023.5.0' 'pandas>=2.0' 'python-graphviz>=0.20'"
if [[ $PYTHON_VERSION == "3.7" ]]; then
CONSTRAINED_DEPENDENCIES="'dask' 'distributed' 'python-graphviz<0.20.2' 'pandas<2.0'"
CONDA_REQUIREMENT_FILES="--file ${BUILD_DIRECTORY}/.ci/conda-envs/ci-core-py37.txt"
else
CONDA_REQUIREMENT_FILES="--file ${BUILD_DIRECTORY}/.ci/conda-envs/ci-core.txt"
fi

# notes:
# * including python=version[build=*cpython] to ensure that conda doesn't fall back to pypy
# * these floors are not the oldest versions LightGBM supports... they're here just to make conda
# solves faster, and should generally be the latest versions that work for all CI jobs using
# this script
mamba create -y -n $CONDA_ENV \
${CONSTRAINED_DEPENDENCIES} \
'cffi>=1.16' \
'cloudpickle>=3.0.0' \
'joblib>=1.3.2' \
'matplotlib-base>=3.7.3' \
'numpy>=1.24.4' \
'psutil>=5.9.8' \
'pyarrow>=6.0' \
'pytest>=8.1.1' \
mamba create \
-y \
-n $CONDA_ENV \
${CONDA_REQUIREMENT_FILES} \
${CONDA_PYTHON_REQUIREMENT} \
'scikit-learn>=1.3.2' \
'scipy>=1.10' || exit 1
|| exit 1

source activate $CONDA_ENV

Expand Down
25 changes: 12 additions & 13 deletions .ci/test_windows.ps1
Expand Up @@ -49,20 +49,19 @@ conda config --set always_yes yes --set changeps1 no
conda install "brotlipy>=0.7"

conda update -q -y conda
conda create -y -n $env:CONDA_ENV `
"cffi>=1.16" `
"cloudpickle>=3.0" `
"joblib>=1.3.2" `
"matplotlib-base>=3.7.3" `
"numpy>=1.24.4" `
"pandas>=1.5" `
"psutil>=5.9.8" `
"pyarrow>=12.0" `
"pytest>=8.1.1" `

if ($env:PYTHON_VERSION -eq "3.7") {
$env:CONDA_REQUIREMENT_FILES = "--file $env:BUILD_SOURCESDIRECTORY/.ci/ci-core-py37.txt"
} else {
$env:CONDA_REQUIREMENT_FILES = "--file $env:BUILD_SOURCESDIRECTORY/.ci/ci-core.txt"
}

conda create `
-y
-n $env:CONDA_ENV `
$env:CONDA_REQUIREMENT_FILES `
"python=$env:PYTHON_VERSION[build=*cpython]" `
"python-graphviz>=0.20" `
"scikit-learn>=1.3.2" `
"scipy>=1.10" ; Check-Output $?
; Check-Output $?

if ($env:TASK -ne "bdist") {
conda activate $env:CONDA_ENV
Expand Down

0 comments on commit f6a8d99

Please sign in to comment.