Skip to content

Commit 68f6798

Browse files
authored
Refactor the github conda workflow to only test the released package (#563)
- the github workflow does not build any longer a conda package (even if the instructions and files to build locally are kept) - this workflow fetches the released package from conda-forge - this workflow is launched manually on demand
1 parent f70cdd9 commit 68f6798

File tree

3 files changed

+204
-32
lines changed

3 files changed

+204
-32
lines changed
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
---
2+
name: Test the released Conda Package
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
khiops-core-version:
7+
default: 11.0.0
8+
description: khiops-core version for testing
9+
khiops-samples-version:
10+
default: 11.0.0
11+
description: khiops-samples version
12+
khiops-python-version:
13+
default: 11.0.0.3
14+
description: khiops-python version for testing
15+
defaults:
16+
run:
17+
shell: bash -el {0}
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
20+
cancel-in-progress: true
21+
jobs:
22+
# Test Conda package on brand new environments
23+
test:
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
28+
env:
29+
- {os: ubuntu-22.04, json-image: '{"image": "ubuntu:20.04"}'}
30+
- {os: ubuntu-22.04, json-image: '{"image": null}'}
31+
- {os: ubuntu-24.04, json-image: '{"image": null}'}
32+
- {os: ubuntu-22.04, json-image: '{"image": "rockylinux:8"}'}
33+
- {os: ubuntu-22.04, json-image: '{"image": "rockylinux:9"}'}
34+
- {os: windows-2022, json-image: '{"image": null}'}
35+
- {os: windows-2025, json-image: '{"image": null}'}
36+
- {os: macos-14, json-image: '{"image": null}'}
37+
- {os: macos-15, json-image: '{"image": null}'}
38+
- {os: macos-15-intel, json-image: '{"image": null}'}
39+
runs-on: ${{ matrix.env.os }}
40+
container: ${{ fromJSON(matrix.env.json-image) }}
41+
steps:
42+
- name: Install Miniforge
43+
uses: conda-incubator/setup-miniconda@v3
44+
with:
45+
miniforge-version: 24.11.0-0
46+
python-version: ${{ matrix.python-version }}
47+
conda-remove-defaults: true
48+
- name: Install the Khiops Conda package
49+
run: |
50+
# Add the Conda `rc` label for alpha or RC pre-releases
51+
if [[ $(echo ${{ inputs.khiops-core-version }} | grep -E ".*(a|rc)\.[0-9]+") ]]; then
52+
RC_LABEL="conda-forge/label/rc::"
53+
else
54+
RC_LABEL=""
55+
fi
56+
conda install "${RC_LABEL}"khiops-core==${{ inputs.khiops-core-version }}
57+
conda install khiops==${{ inputs.khiops-python-version }}
58+
- name: Test Khiops Installation Status
59+
run: kh-status
60+
- name: Test Khiops Installation Status (Conda-Based Environments)
61+
run: |
62+
# Set `python` to the current Conda Python executable
63+
PYTHON="$(type -P python)"
64+
65+
# Remove $CONDA_PREFIX/bin from PATH
66+
PATH=$(echo $PATH | sed "s#$CONDA_PREFIX/bin:##g")
67+
68+
# Unset *CONDA* environment variables
69+
# As a corollary, CONDA_PREFIX is unset
70+
# Note: There is no way to remove these variables from GITHUB_ENV
71+
# (see https://github.com/actions/runner/issues/1126)
72+
for CONDA_VAR in $(env | grep CONDA)
73+
do
74+
unset $(echo $CONDA_VAR | cut -d '=' -f 1)
75+
done
76+
77+
# Note: kh-status is not reachable as it is not in PATH
78+
$PYTHON -c \
79+
"import sys; import khiops.core as kh; return_code = kh.get_runner().print_status(); sys.exit(return_code)"
80+
- name: Download Sample Datasets
81+
run: |
82+
kh-download-datasets \
83+
--version ${{ inputs.khiops-samples-version }}
84+
- name: Run Samples
85+
env:
86+
# Force > 2 CPU cores to launch mpiexec
87+
KHIOPS_PROC_NUMBER: 4
88+
run: |
89+
kh-samples core -i deploy_model -e
90+
kh-samples core -i deploy_coclustering -e
91+
kh-samples core -i train_predictor_error_handling -e
92+
kh-samples sklearn -i khiops_classifier -e
93+
kh-samples sklearn -i khiops_coclustering -e
94+
- name: Run Samples (Conda-Based Environments)
95+
env:
96+
# Force > 2 CPU cores to launch mpiexec
97+
KHIOPS_PROC_NUMBER: 4
98+
run: |
99+
# Set `python` to the current Conda Python executable
100+
PYTHON="$(type -P python)"
101+
102+
# Remove $CONDA_PREFIX/bin from PATH
103+
PATH=$(echo $PATH | sed "s#$CONDA_PREFIX/bin:##g")
104+
105+
# Unset *CONDA* environment variables
106+
# As a corollary, CONDA_PREFIX is unset
107+
# Note: There is no way to remove these variables from GITHUB_ENV
108+
# (see https://github.com/actions/runner/issues/1126)
109+
for CONDA_VAR in $(env | grep CONDA)
110+
do
111+
unset $(echo $CONDA_VAR | cut -d '=' -f 1)
112+
done
113+
114+
# Run samples
115+
# Note: kh-samples is not reachable as it is not in PATH
116+
$PYTHON -m khiops.samples.samples -i deploy_model -e
117+
$PYTHON -m khiops.samples.samples -i deploy_coclustering -e
118+
$PYTHON -m khiops.samples.samples -i train_predictor_error_handling -e
119+
$PYTHON -m khiops.samples.samples_sklearn -i khiops_classifier -e
120+
$PYTHON -m khiops.samples.samples_sklearn -i khiops_coclustering -e
121+
# Checkout the sources to obtain the tests
122+
# Note: The `sparse-checkout` option of this action is bugged so we checkout all the sources
123+
# See https://github.com/actions/checkout/issues/1628
124+
- name: Checkout Sources
125+
uses: actions/checkout@v4
126+
with:
127+
fetch-depth: 1
128+
# This is needed so python does not retrieve the khiops module from PWD
129+
- name: Remove the khiops Module from the Sources
130+
run: rm -rf khiops
131+
- name: Install the Test Requirements
132+
run: conda install -y --file test-requirements.txt
133+
- name: Run the Runner Initialization Integration Test
134+
run: |
135+
python -m unittest -v \
136+
tests.test_khiops_integrations.KhiopsRunnerEnvironmentTests.test_runner_environment_initialization
137+
- name: Run the Runner Initialization Integration Test (Conda-Based Environments)
138+
run: |-
139+
# Set `python` to the current Conda Python executable
140+
PYTHON="$(type -P python)"
141+
142+
# Remove $CONDA_PREFIX/bin from PATH
143+
PATH=$(echo $PATH | sed "s#$CONDA_PREFIX/bin:##g")
144+
145+
# Unset *CONDA* environment variables
146+
# As a corolary, CONDA_PREFIX is unset
147+
# Note: There is no way to remove these variables from GITHUB_ENV
148+
# (see https://github.com/actions/runner/issues/1126)
149+
for CONDA_VAR in $(env | grep CONDA)
150+
do
151+
unset $(echo $CONDA_VAR | cut -d '=' -f 1)
152+
done
153+
154+
# Execute the runner initialization integration test
155+
$PYTHON -m unittest -v \
156+
tests.test_khiops_integrations.KhiopsRunnerEnvironmentTests.test_runner_environment_initialization

packaging/conda/README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# Khiops Conda Packaging Scripts
22

3+
## Purpose
4+
The current folder helps you build locally a conda package from the sources.
5+
36
## How to Build
4-
You'll need `conda-build` installed in your system. The environment variable `KHIOPS_REVISION` must
5-
be set to a Git tag of the `khiops` repository.
7+
You'll need the package `conda-build` installed in your conda environment.
8+
Optionally if installed, the package `conda-verify` will find obvious packaging bugs.
69

710
```bash
8-
# At the root of the repo
9-
# These commands will leave a ready to use conda channel in `./khiops-conda-build`
10-
KHIOPS_REVISION=10.2.0
11+
# At the root of the project repository
1112

1213
# Windows
1314
conda build --output-folder ./khiops-conda-build packaging/conda
@@ -16,3 +17,11 @@ conda build --output-folder ./khiops-conda-build packaging/conda
1617
# Note: We use the conda-forge channel so the khiops-core package obtains the pinned MPICH versions
1718
conda build --channel conda-forge --output-folder ./khiops-conda-build packaging/conda
1819
```
20+
21+
## How to Install
22+
23+
The freshly built package can be installed in your conda environment
24+
25+
```bash
26+
conda install --channel ./khiops-conda-build khiops
27+
```

packaging/conda/meta.yaml

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,59 @@
1-
{% set name = load_file_data('../../pyproject.toml', from_recipe_dir=True).get('project').get('name') %}
1+
# This file SHOULD be as close as the conda-forge khiops-feedstock recipe
2+
# See https://github.com/conda-forge/khiops-feedstock/tree/main/recipe
3+
4+
{% set name = "khiops" %}
5+
{% set version = "11.0.0.3" %}
6+
# The minimal Python version as supported by the conda-forge CI
7+
{% set python_min = "3.10" %}
8+
29
package:
3-
name: {{ name }}
4-
# The Conda version cannot contain the '-' character, so we eliminate it
5-
version: "11.0.0.3"
10+
name: {{ name|lower }}
11+
version: {{ version }}
612

713
source:
814
path: ../../
915

1016
build:
11-
number: 0
12-
noarch: python
1317
entry_points:
14-
- kh-status = khiops.tools:kh_status_entry_point
15-
- kh-samples = khiops.tools:kh_samples_entry_point
16-
- kh-download-datasets = khiops.tools:kh_download_datasets_entry_point
17-
script: |
18-
{{ PYTHON }} -m pip install . --no-deps --ignore-installed --no-cache-dir --no-build-isolation -vvv
18+
- kh-status=khiops.tools:kh_status_entry_point
19+
- kh-samples=khiops.tools:kh_samples_entry_point
20+
- kh-download-datasets=khiops.tools:kh_download_datasets_entry_point
21+
noarch: python
22+
script: {{ PYTHON }} -m pip install . --no-deps --ignore-installed --no-cache-dir --no-build-isolation -vvv
23+
number: 0
1924

2025
requirements:
2126
host:
22-
- python
27+
- python {{ python_min }}
28+
- pip
2329
- setuptools
2430
run:
25-
- python
31+
- python >={{ python_min }}
2632
- khiops-core =11.0.0
2733
- pandas >=2.3.3,<4.0.0
28-
- scikit-learn>=1.7.2,<1.9.0
34+
- scikit-learn >=1.7.2,<1.9.0
2935
run_constrained:
3036
# do not necessary use the latest version
3137
# to avoid undesired breaking changes
3238
- boto3 >=1.17.39,<=1.35.69
3339
- google-cloud-storage >=1.37.0
34-
# an open issue on boto3 (https://github.com/boto/boto3/issues/3585) forces a min version of pyopenssl
35-
- pyopenssl>=24.0.0,<25.0.0
3640

37-
outputs:
38-
- name: {{ name }}
39-
test:
40-
commands:
41-
- kh-status
42-
imports:
43-
- khiops.core.api
44-
- khiops.sklearn.estimators
41+
test:
42+
imports:
43+
- khiops
44+
commands:
45+
- pip check
46+
- kh-status
47+
- kh-samples --help
48+
- kh-download-datasets --help
49+
requires:
50+
- python {{ python_min }}
51+
- pip
4552

4653
about:
4754
home: https://khiops.org
48-
license: BSD+3-clause
55+
summary: Python library for the Khiops AutoML suite
56+
license: BSD-3-Clause
4957
license_file: LICENSE.md
50-
summary: Khiops is an AutoML suite for supervised and unsupervised learning
51-
doc_url: https://khiopsml.github.com/khiops-python
58+
doc_url: https://khiops.org
5259
dev_url: https://github.com/khiopsml/khiops-python

0 commit comments

Comments
 (0)