Skip to content

Commit a7730a6

Browse files
committed
fix juliacall incompatibilities; see extended
- CI updates: run CI on all platforms with and without RMS, split regression tests into separate job after that so that regression is only checked on one platform - installation updates: make RMG-Py actually `pip`-installable as `reactionmechanismgenerator` to avoid having to set the `PYTHONPATH` variable, which breaks `juliacall`, add a convenience script for installing RMS - code changes: fix some small bugs in the new optional-rms setup (one missed `requires_rms` and one incorrect rebase)
1 parent 24f140f commit a7730a6

File tree

11 files changed

+230
-396
lines changed

11 files changed

+230
-396
lines changed

.github/workflows/CI.yml

Lines changed: 100 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,23 @@ env:
4949
# main with the name of the branch
5050
RMG_DATABASE_BRANCH: main
5151

52-
5352
jobs:
5453
build-and-test:
5554
strategy:
5655
fail-fast: false
5756
matrix:
5857
python-version: ["3.9"]
5958
os: [macos-13, macos-latest, ubuntu-latest]
59+
include-rms: ["", "with RMS"]
60+
exclude:
61+
- os: macos-latest # needs Cantera 3 b/c x86 emulation breaks with Julia
62+
include-rms: 'with RMS'
63+
- os: macos-13 # GitHub's runners just aren't up to the task of installing Julia
64+
include-rms: 'with RMS'
6065
runs-on: ${{ matrix.os }}
61-
name: ${{ matrix.os }} Build and Test Python ${{ matrix.python-version }}
66+
name: Python ${{ matrix.python-version }} ${{ matrix.os }} Build and Test ${{ matrix.include-rms }}
6267
# skip scheduled runs from forks
6368
if: ${{ !( github.repository != 'ReactionMechanismGenerator/RMG-Py' && github.event_name == 'schedule' ) }}
64-
env:
65-
# This is true only if this is a reference case for the regression testing:
66-
REFERENCE_JOB: ${{ github.ref == 'refs/heads/main' && github.repository == 'ReactionMechanismGenerator/RMG-Py' }}
6769
defaults:
6870
run:
6971
shell: bash -l {0}
@@ -83,73 +85,128 @@ jobs:
8385
miniforge-version: latest
8486
python-version: ${{ matrix.python-version }}
8587
activate-environment: rmg_env
86-
use-mamba: true
88+
auto-update-conda: true
8789
show-channel-urls: true
8890
channels: conda-forge,cantera,rmg
91+
conda-remove-defaults: "true"
8992

9093
# list the environment for debugging purposes
91-
- name: mamba info
94+
- name: conda info
9295
run: |
93-
mamba info
94-
mamba list
96+
conda info
97+
conda list
9598
9699
# Clone RMG-database
97100
- name: Clone RMG-database
98101
run: |
99102
cd ..
100103
git clone -b $RMG_DATABASE_BRANCH https://github.com/ReactionMechanismGenerator/RMG-database.git
101104
102-
# modify env variables as directed in the RMG installation instructions
103-
- name: Set Environment Variables
104-
run: |
105-
RUNNER_CWD=$(pwd)
106-
echo "PYTHONPATH=$RUNNER_CWD/RMG-Py:$PYTHONPATH" >> $GITHUB_ENV
107-
echo "$RUNNER_CWD/RMG-Py" >> $GITHUB_PATH
108-
109105
# RMG build step
110-
- name: make RMG
111-
run: |
112-
make clean
113-
make
114-
115-
# Setup Juliaup
116-
- name: Set Julia paths
117-
run: |
118-
# echo "JULIAUP_DEPOT_PATH=$CONDA/envs/rmg_env/.julia" >> $GITHUB_ENV
119-
# echo "JULIAUP_DEPOT_PATH=$CONDA/envs/rmg_env/.julia" >> $GITHUB_PATH
120-
# echo "JULIA_DEPOT_PATH=$CONDA/envs/rmg_env/.julia" >> $GITHUB_ENV
121-
# echo "JULIA_DEPOT_PATH=$CONDA/envs/rmg_env/.julia" >> $GITHUB_PATH
122-
# echo "JULIA_CONDAPKG_EXE=$CONDA/condabin/mamba" >> $GITHUB_ENV
123-
# echo "JULIA_CONDAPKG_EXE=$CONDA/condabin/mamba" >> $GITHUB_PATH
124-
# echo "JULIA_CONDAPKG_EXE=$CONDA/condabin/mamba" >> $GITHUB_ENV
125-
# echo "JULIA_CONDAPKG_EXE=$CONDA/condabin/mamba" >> $GITHUB_PATH
126-
echo "JULIA_CONDAPKG_BACKEND=Current" >> $GITHUB_ENV
127-
# echo "JULIA_CONDAPKG_BACKEND=Current" >> $GITHUB_PATH
106+
- run: make install
128107

129108
- name: Setup Juliaup
109+
if: matrix.include-rms == 'with RMS'
130110
uses: julia-actions/install-juliaup@v2
131111
with:
132112
channel: '1.9'
133113

134-
- name: Check Julia version
135-
run: julia --version
114+
- name: Set some env vars
115+
if: matrix.include-rms == 'with RMS'
116+
run: |
117+
# https://juliapy.github.io/PythonCall.jl/stable/pythoncall/#If-you-already-have-Python-and-required-Python-packages-installed
118+
echo "JULIA_CONDAPKG_BACKEND=Null" >> $GITHUB_ENV
119+
echo "JULIA_PYTHONCALL_EXE=$CONDA_PREFIX/bin/python" >> $GITHUB_ENV
136120
137121
# RMS installation and linking to Julia
138122
- name: Install and link Julia dependencies
123+
if: matrix.include-rms == 'with RMS'
139124
timeout-minutes: 120 # this usually takes 20-45 minutes (or hangs for 6+ hours).
140-
# JULIA_CONDAPKG_EXE points to the existing conda/mamba to avoid JuliaCall from installing their own. See https://juliapy.github.io/PythonCall.jl/stable/pythoncall/#If-you-already-have-a-Conda-environment.
125+
run: . install_rms.sh
126+
127+
- name: Set some other env vars
128+
if: matrix.include-rms == 'with RMS'
141129
run: |
142-
mamba install conda-forge::pyjuliacall
143-
julia -e 'using Pkg; Pkg.add(Pkg.PackageSpec(name="ReactionMechanismSimulator", url="https://github.com/hwpang/ReactionMechanismSimulator.jl.git", rev="fix_installation")); using ReactionMechanismSimulator'
130+
# ensure that juliacall in Python uses the correct julia executable and packages: https://github.com/JuliaPy/PyJuliaPkg?tab=readme-ov-file#which-julia-gets-used
131+
echo "PYTHON_JULIAPKG_EXE=$(which julia)" >> $GITHUB_ENV
132+
echo "PYTHON_JULIAPKG_PROJECT=$HOME/.julia/packages" >> $GITHUB_ENV
144133
145134
- name: Install Q2DTor
146135
run: echo "" | make q2dtor
147136

148137
# non-regression testing
149138
- name: Run Unit, Functional, and Database Tests
150-
# aggregate into one command so we only have to eat the collection time once
151139
run: make test-all
152140

141+
regression-test:
142+
needs: build-and-test
143+
runs-on: ubuntu-latest
144+
name: Regression Test
145+
# skip scheduled runs from forks
146+
if: ${{ !( github.repository != 'ReactionMechanismGenerator/RMG-Py' && github.event_name == 'schedule' ) }}
147+
env:
148+
# This is true only if this is a reference case for the regression testing:
149+
REFERENCE_JOB: ${{ github.ref == 'refs/heads/main' && github.repository == 'ReactionMechanismGenerator/RMG-Py' }}
150+
defaults:
151+
run:
152+
shell: bash -l {0}
153+
steps:
154+
- name: Checkout RMG-Py
155+
uses: actions/checkout@v4
156+
157+
- name: Setup Miniforge Python 3.9
158+
uses: conda-incubator/setup-miniconda@v3
159+
with:
160+
environment-file: environment.yml
161+
miniforge-variant: Miniforge3
162+
miniforge-version: latest
163+
python-version: 3.9
164+
activate-environment: rmg_env
165+
auto-update-conda: true
166+
show-channel-urls: true
167+
channels: conda-forge,cantera,rmg
168+
conda-remove-defaults: "true"
169+
170+
# list the environment for debugging purposes
171+
- name: conda info
172+
run: |
173+
conda info
174+
conda list
175+
176+
# Clone RMG-database
177+
- name: Clone RMG-database
178+
run: |
179+
cd ..
180+
git clone -b $RMG_DATABASE_BRANCH https://github.com/ReactionMechanismGenerator/RMG-database.git
181+
182+
# RMG build step
183+
- run: make install
184+
185+
- name: Setup Juliaup
186+
uses: julia-actions/install-juliaup@v2
187+
with:
188+
channel: '1.9'
189+
190+
- name: Set some env vars
191+
run: |
192+
# https://juliapy.github.io/PythonCall.jl/stable/pythoncall/#If-you-already-have-Python-and-required-Python-packages-installed
193+
echo "JULIA_CONDAPKG_BACKEND=Null" >> $GITHUB_ENV
194+
echo "JULIA_PYTHONCALL_EXE=$CONDA_PREFIX/bin/python" >> $GITHUB_ENV
195+
196+
# RMS installation and linking to Julia
197+
- name: Install and link Julia dependencies
198+
timeout-minutes: 120 # this usually takes 20-45 minutes (or hangs for 6+ hours).
199+
run: . install_rms.sh
200+
201+
- name: Set some other env vars
202+
run: |
203+
# ensure that juliacall in Python uses the correct julia executable and packages: https://github.com/JuliaPy/PyJuliaPkg?tab=readme-ov-file#which-julia-gets-used
204+
echo "PYTHON_JULIAPKG_EXE=$(which julia)" >> $GITHUB_ENV
205+
echo "PYTHON_JULIAPKG_PROJECT=$HOME/.julia/packages" >> $GITHUB_ENV
206+
207+
- name: Install Q2DTor
208+
run: echo "" | make q2dtor
209+
153210
# Regression Testing - Test Execution
154211
- name: Regression Tests - Execution
155212
id: regression-execution
@@ -322,14 +379,14 @@ jobs:
322379
323380
- name: Upload regression summary artifact
324381
# the annotate workflow uses this artifact to add a comment to the PR
325-
uses: actions/upload-artifact@v3
382+
uses: actions/upload-artifact@v4
326383
if : ${{ github.event_name == 'pull_request' }}
327384
with:
328385
name: regression_summary
329386
path: summary.txt
330387

331388
- name: Upload Comparison Results
332-
uses: actions/upload-artifact@v3
389+
uses: actions/upload-artifact@v4
333390
with:
334391
name: regression_test_comparison_results
335392
path: |
@@ -339,7 +396,7 @@ jobs:
339396
- name: Code coverage install and run
340397
if: success() || ( failure() && steps.regression-execution.conclusion == 'success' )
341398
run: |
342-
mamba install -y -c conda-forge codecov
399+
conda install -y -c conda-forge codecov
343400
codecov
344401
345402
build-and-push-docker:

.github/workflows/pure_python_ci.yml

Lines changed: 0 additions & 93 deletions
This file was deleted.

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@
44
#
55
################################################################################
66

7+
# build dir
8+
reactionmechanismgenerator.egg-info/
9+
710
# MacOS files
811
.DS_Store
912

1013
# Compiled Python modules
1114
*.pyc
1215
*.so
1316
*.pyd
17+
# and intermediate source files
18+
*.c
1419

1520
# Image files generated by RMG
1621
*.png

Makefile

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,13 @@
77
CC=gcc
88
CXX=g++
99

10-
.PHONY : all minimal main solver check pycheck arkane clean install decython documentation test q2dtor
10+
.PHONY : all check clean install decython documentation test q2dtor
1111

12-
all: pycheck main solver check
13-
14-
minimal:
15-
python setup.py build_ext minimal --inplace --build-temp .
16-
17-
main:
18-
python setup.py build_ext main --inplace --build-temp .
19-
20-
solver:
21-
@ python utilities.py check-pydas
22-
python setup.py build_ext solver --inplace --build-temp .
23-
24-
arkane:
25-
python setup.py build_ext arkane --inplace --build-temp .
12+
all: check install check
2613

2714
check:
2815
@ python utilities.py check-dependencies
29-
30-
pycheck:
31-
@ python utilities.py check-python
16+
@ python utilities.py check-pydas
3217

3318
documentation:
3419
$(MAKE) -C documentation html
@@ -42,7 +27,7 @@ clean-solver:
4227

4328
install:
4429
@ python utilities.py check-pydas
45-
python setup.py install
30+
python -m pip install -vv --no-cache-dir -e .
4631

4732
q2dtor:
4833
@ echo -e "\nInstalling Q2DTor...\n"

0 commit comments

Comments
 (0)