Skip to content

Commit 4fd0f93

Browse files
author
Thierry RAMORASOAVINA
committed
Refactor the github conda workflow to only test the released package
- 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 4fd0f93

3 files changed

Lines changed: 220 additions & 32 deletions

File tree

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