-
Notifications
You must be signed in to change notification settings - Fork 2
268 lines (257 loc) · 10.8 KB
/
conda.yml
File metadata and controls
268 lines (257 loc) · 10.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
---
name: Conda Package
env:
# Note: The default Khiops version must never be an alpha release as they are
# ephemeral. To test alpha versions run the workflow manually.
DEFAULT_KHIOPS_CORE_VERSION: 11.0.0
DEFAULT_SAMPLES_VERSION: 11.0.0
on:
workflow_dispatch:
inputs:
khiops-core-version:
default: 11.0.0
description: khiops-core version for testing
khiops-samples-version:
default: 11.0.0
description: khiops-samples version
push:
tags: ['*']
pull_request:
paths:
- pyproject.toml
- LICENSE.md
- packaging/conda/**,
- '!packaging/conda/README.md'
- .github/workflows/conda.yml
defaults:
run:
shell: bash -el {0}
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Checkout Sources
uses: actions/checkout@v4
with:
# Checkout the full repository to have the tags so versioneer works properly
# See issue https://github.com/actions/checkout/issues/701
fetch-depth: 0
- name: Install Miniforge
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: 24.11.0-0
python-version: '3.12'
conda-remove-defaults: true
- name: Install Dependency Requirements for Building Conda Packages
run: conda install -y conda-build
- name: Build the Conda Package
run: |
conda build --output-folder ./khiops-conda ./packaging/conda
- name: Upload Conda Package Artifact
uses: actions/upload-artifact@v4
with:
name: khiops-conda
path: ./khiops-conda
retention-days: 7
# Test Conda package on brand new environments
test:
needs: build
strategy:
fail-fast: false
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
env:
- {os: ubuntu-22.04, json-image: '{"image": "ubuntu:20.04"}'}
- {os: ubuntu-22.04, json-image: '{"image": null}'}
- {os: ubuntu-24.04, json-image: '{"image": null}'}
- {os: ubuntu-22.04, json-image: '{"image": "rockylinux:8"}'}
- {os: ubuntu-22.04, json-image: '{"image": "rockylinux:9"}'}
- {os: windows-2022, json-image: '{"image": null}'}
- {os: windows-2025, json-image: '{"image": null}'}
- {os: macos-14, json-image: '{"image": null}'}
- {os: macos-15, json-image: '{"image": null}'}
- {os: macos-15-intel, json-image: '{"image": null}'}
runs-on: ${{ matrix.env.os }}
container: ${{ fromJSON(matrix.env.json-image) }}
steps:
- name: Install Miniforge
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: 24.11.0-0
python-version: ${{ matrix.python-version }}
conda-remove-defaults: true
- name: Download Conda Package Artifact
uses: actions/download-artifact@v4
with:
name: khiops-conda
path: ./khiops-conda
- name: Put the khiops-core Version in the Environment
run: |
KHIOPS_CORE_VERSION="${{ inputs.khiops-core-version || env.DEFAULT_KHIOPS_CORE_VERSION }}"
echo "KHIOPS_CORE_VERSION=$KHIOPS_CORE_VERSION" >> "$GITHUB_ENV"
- name: Install the Khiops Conda package
run: |
# Add the Conda `rc` label for alpha or RC pre-releases
if [[ $(echo ${KHIOPS_CORE_VERSION} | grep -E ".*(a|rc)\.[0-9]+") ]]; then
RC_LABEL="conda-forge/label/rc::"
else
RC_LABEL=""
fi
conda install "${RC_LABEL}"khiops-core==$KHIOPS_CORE_VERSION
conda install --channel ./khiops-conda/ khiops
- name: Install JQ test dependency (Linux / MacOS)
if: runner.os != 'Windows'
run: conda install jq
- name: Test Conda / Python Package Version Coherence
run: |
PACKAGE_VERSION=$(python -c "import khiops; print(khiops.__version__)")
CONDA_VERSION=$(conda list ^khiops$ --json | jq ".[].version")
# Fail if CONDA_VERSION is not identical to $PACKAGE_VERSION
echo $CONDA_VERSION | grep -wq $PACKAGE_VERSION
if [[ $? -ne 0 ]]
then
echo "::error::Conda package version $CONDA_VERSION does not match Python package version $PYTHON_VERSION"
false
fi
- name: Test Khiops Installation Status
run: kh-status
- name: Test Khiops Installation Status (Conda-Based Environments)
run: |
# Set `python` to the current Conda Python executable
PYTHON="$(type -P python)"
# Remove $CONDA_PREFIX/bin from PATH
PATH=$(echo $PATH | sed "s#$CONDA_PREFIX/bin:##g")
# Unset *CONDA* environment variables
# As a corollary, CONDA_PREFIX is unset
# Note: There is no way to remove these variables from GITHUB_ENV
# (see https://github.com/actions/runner/issues/1126)
for CONDA_VAR in $(env | grep CONDA)
do
unset $(echo $CONDA_VAR | cut -d '=' -f 1)
done
# Note: kh-status is not reachable as it is not in PATH
$PYTHON -c \
"import sys; import khiops.core as kh; return_code = kh.get_runner().print_status(); sys.exit(return_code)"
- name: Download Sample Datasets
run: |
kh-download-datasets \
--version ${{ inputs.khiops-samples-version || env.DEFAULT_SAMPLES_VERSION }}
- name: Run Samples
env:
# Force > 2 CPU cores to launch mpiexec
KHIOPS_PROC_NUMBER: 4
run: |
kh-samples core -i deploy_model -e
kh-samples core -i deploy_coclustering -e
kh-samples core -i train_predictor_error_handling -e
kh-samples sklearn -i khiops_classifier -e
kh-samples sklearn -i khiops_coclustering -e
- name: Run Samples (Conda-Based Environments)
env:
# Force > 2 CPU cores to launch mpiexec
KHIOPS_PROC_NUMBER: 4
run: |
# Set `python` to the current Conda Python executable
PYTHON="$(type -P python)"
# Remove $CONDA_PREFIX/bin from PATH
PATH=$(echo $PATH | sed "s#$CONDA_PREFIX/bin:##g")
# Unset *CONDA* environment variables
# As a corollary, CONDA_PREFIX is unset
# Note: There is no way to remove these variables from GITHUB_ENV
# (see https://github.com/actions/runner/issues/1126)
for CONDA_VAR in $(env | grep CONDA)
do
unset $(echo $CONDA_VAR | cut -d '=' -f 1)
done
# Run samples
# Note: kh-samples is not reachable as it is not in PATH
$PYTHON -m khiops.samples.samples -i deploy_model -e
$PYTHON -m khiops.samples.samples -i deploy_coclustering -e
$PYTHON -m khiops.samples.samples -i train_predictor_error_handling -e
$PYTHON -m khiops.samples.samples_sklearn -i khiops_classifier -e
$PYTHON -m khiops.samples.samples_sklearn -i khiops_coclustering -e
# Checkout the sources to obtain the tests
# Note: The `sparse-checkout` option of this action is bugged so we checkout all the sources
# See https://github.com/actions/checkout/issues/1628
- name: Checkout Sources
uses: actions/checkout@v4
with:
fetch-depth: 1
# This is needed so python does not retrieve the khiops module from PWD
- name: Remove the khiops Module from the Sources
run: rm -rf khiops
- name: Install the Test Requirements
run: conda install -y --file test-requirements.txt
- name: Run the Runner Initialization Integration Test
run: |
python -m unittest -v \
tests.test_khiops_integrations.KhiopsRunnerEnvironmentTests.test_runner_environment_initialization
- name: Run the Runner Initialization Integration Test (Conda-Based Environments)
run: |
# Set `python` to the current Conda Python executable
PYTHON="$(type -P python)"
# Remove $CONDA_PREFIX/bin from PATH
PATH=$(echo $PATH | sed "s#$CONDA_PREFIX/bin:##g")
# Unset *CONDA* environment variables
# As a corolary, CONDA_PREFIX is unset
# Note: There is no way to remove these variables from GITHUB_ENV
# (see https://github.com/actions/runner/issues/1126)
for CONDA_VAR in $(env | grep CONDA)
do
unset $(echo $CONDA_VAR | cut -d '=' -f 1)
done
# Execute the runner initialization integration test
$PYTHON -m unittest -v \
tests.test_khiops_integrations.KhiopsRunnerEnvironmentTests.test_runner_environment_initialization
# Release is only executed on tags
# Note: For this job to work the secret variable KHIOPS_DEV_ANACONDA_CHANNEL_TOKEN
# must be set with a valid anaconda.org access token
release:
if: github.ref_type == 'tag'
needs: test
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
- name: Download package artifacts
uses: actions/download-artifact@v4
with:
# See the upload-artifact step in the build job for the explanation of this pattern
name: khiops-conda
path: ./khiops-conda
- name: Check Conda package / Git tag version coherence
run: |
# Don't exit on first error: print relevant error message
set +e
# Extract Conda package version from the package artifact
PACKAGE_VERSION=$( \
unzip -p ./khiops-conda/noarch/*.conda info-*.tar.zst \
| tar --zstd -axf - info/index.json -O \
| jq -r ".version" \
)
# Convert pre-release version specification in the Git tag to the
# Conda format and check that it matches the Conda package version
echo ${{ github.ref_name }} | tr -d '-' | grep -wq $PACKAGE_VERSION
if [[ $? -ne 0 ]]
then
echo "::error::Conda package version $PACKAGE_VERSION does not match Git tag ${{ github.ref_name }}"
false
fi
- name: Install Miniforge
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: 24.11.0-0
python-version: '3.12'
conda-remove-defaults: true
- name: Install Requirement Packages
run: conda install -y anaconda-client conda-index
- name: Reindex the package directory
run: python -m conda_index ./khiops-conda
- name: Upload the Package to anaconda.org
run: |-
# Override versions, as the packages are pushed to a dev channel
anaconda --token "${{ secrets.KHIOPS_DEV_ANACONDA_CHANNEL_TOKEN }}" upload \
--user khiops-dev --force ./khiops-conda/noarch/*.conda