Skip to content

Commit 4381db7

Browse files
authored
Merge pull request #2754 from ReactionMechanismGenerator/py39/juliacall-fix
fix `juliacall` implementation (primarily just getting it to 'see' the correct conda environment)
2 parents 24f140f + 8276f7e commit 4381db7

File tree

14 files changed

+236
-412
lines changed

14 files changed

+236
-412
lines changed

.github/workflows/CI.yml

Lines changed: 98 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -49,32 +49,28 @@ 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-13 # GitHub's runners just aren't up to the task of installing Julia
62+
include-rms: 'with RMS'
6063
runs-on: ${{ matrix.os }}
61-
name: ${{ matrix.os }} Build and Test Python ${{ matrix.python-version }}
64+
name: Python ${{ matrix.python-version }} ${{ matrix.os }} Build and Test ${{ matrix.include-rms }}
6265
# skip scheduled runs from forks
6366
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' }}
6767
defaults:
6868
run:
6969
shell: bash -l {0}
7070
steps:
7171
- name: Checkout RMG-Py
7272
uses: actions/checkout@v4
7373

74-
- name: Compel Arm-based Mac to use x86
75-
if: matrix.os == 'macos-latest'
76-
run: echo "CONDA_SUBDIR=osx-64" >> $GITHUB_ENV
77-
7874
- name: Setup Miniforge Python ${{ matrix.python-version }}
7975
uses: conda-incubator/setup-miniconda@v3
8076
with:
@@ -83,73 +79,126 @@ jobs:
8379
miniforge-version: latest
8480
python-version: ${{ matrix.python-version }}
8581
activate-environment: rmg_env
86-
use-mamba: true
82+
auto-update-conda: true
8783
show-channel-urls: true
88-
channels: conda-forge,cantera,rmg
84+
conda-remove-defaults: "true"
8985

9086
# list the environment for debugging purposes
91-
- name: mamba info
87+
- name: conda info
9288
run: |
93-
mamba info
94-
mamba list
89+
conda info
90+
conda list
9591
9692
# Clone RMG-database
9793
- name: Clone RMG-database
9894
run: |
9995
cd ..
10096
git clone -b $RMG_DATABASE_BRANCH https://github.com/ReactionMechanismGenerator/RMG-database.git
10197
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-
10998
# 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
99+
- run: make install
128100

129101
- name: Setup Juliaup
102+
if: matrix.include-rms == 'with RMS'
130103
uses: julia-actions/install-juliaup@v2
131104
with:
132105
channel: '1.9'
133106

134-
- name: Check Julia version
135-
run: julia --version
107+
- name: Set some env vars
108+
if: matrix.include-rms == 'with RMS'
109+
run: |
110+
# https://juliapy.github.io/PythonCall.jl/stable/pythoncall/#If-you-already-have-Python-and-required-Python-packages-installed
111+
echo "JULIA_CONDAPKG_BACKEND=Null" >> $GITHUB_ENV
112+
echo "JULIA_PYTHONCALL_EXE=$CONDA_PREFIX/bin/python" >> $GITHUB_ENV
136113
137114
# RMS installation and linking to Julia
138115
- name: Install and link Julia dependencies
116+
if: matrix.include-rms == 'with RMS'
139117
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.
118+
run: . install_rms.sh
119+
120+
- name: Set some other env vars
121+
if: matrix.include-rms == 'with RMS'
141122
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'
123+
# 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
124+
echo "PYTHON_JULIAPKG_EXE=$(which julia)" >> $GITHUB_ENV
125+
echo "PYTHON_JULIAPKG_PROJECT=$HOME/.julia/packages" >> $GITHUB_ENV
144126
145127
- name: Install Q2DTor
146128
run: echo "" | make q2dtor
147129

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

134+
regression-test:
135+
needs: build-and-test
136+
runs-on: ubuntu-latest
137+
name: Regression Test
138+
# skip scheduled runs from forks
139+
if: ${{ !( github.repository != 'ReactionMechanismGenerator/RMG-Py' && github.event_name == 'schedule' ) }}
140+
env:
141+
# This is true only if this is a reference case for the regression testing:
142+
REFERENCE_JOB: ${{ github.ref == 'refs/heads/main' && github.repository == 'ReactionMechanismGenerator/RMG-Py' }}
143+
defaults:
144+
run:
145+
shell: bash -l {0}
146+
steps:
147+
- name: Checkout RMG-Py
148+
uses: actions/checkout@v4
149+
150+
- name: Setup Miniforge Python 3.9
151+
uses: conda-incubator/setup-miniconda@v3
152+
with:
153+
environment-file: environment.yml
154+
miniforge-variant: Miniforge3
155+
miniforge-version: latest
156+
python-version: 3.9
157+
activate-environment: rmg_env
158+
auto-update-conda: true
159+
show-channel-urls: true
160+
conda-remove-defaults: "true"
161+
162+
# list the environment for debugging purposes
163+
- name: conda info
164+
run: |
165+
conda info
166+
conda list
167+
168+
# Clone RMG-database
169+
- name: Clone RMG-database
170+
run: |
171+
cd ..
172+
git clone -b $RMG_DATABASE_BRANCH https://github.com/ReactionMechanismGenerator/RMG-database.git
173+
174+
# RMG build step
175+
- run: make install
176+
177+
- name: Setup Juliaup
178+
uses: julia-actions/install-juliaup@v2
179+
with:
180+
channel: '1.9'
181+
182+
- name: Set some env vars
183+
run: |
184+
# https://juliapy.github.io/PythonCall.jl/stable/pythoncall/#If-you-already-have-Python-and-required-Python-packages-installed
185+
echo "JULIA_CONDAPKG_BACKEND=Null" >> $GITHUB_ENV
186+
echo "JULIA_PYTHONCALL_EXE=$CONDA_PREFIX/bin/python" >> $GITHUB_ENV
187+
188+
# RMS installation and linking to Julia
189+
- name: Install and link Julia dependencies
190+
timeout-minutes: 120 # this usually takes 20-45 minutes (or hangs for 6+ hours).
191+
run: . install_rms.sh
192+
193+
- name: Set some other env vars
194+
run: |
195+
# 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
196+
echo "PYTHON_JULIAPKG_EXE=$(which julia)" >> $GITHUB_ENV
197+
echo "PYTHON_JULIAPKG_PROJECT=$HOME/.julia/packages" >> $GITHUB_ENV
198+
199+
- name: Install Q2DTor
200+
run: echo "" | make q2dtor
201+
153202
# Regression Testing - Test Execution
154203
- name: Regression Tests - Execution
155204
id: regression-execution
@@ -322,14 +371,14 @@ jobs:
322371
323372
- name: Upload regression summary artifact
324373
# the annotate workflow uses this artifact to add a comment to the PR
325-
uses: actions/upload-artifact@v3
374+
uses: actions/upload-artifact@v4
326375
if : ${{ github.event_name == 'pull_request' }}
327376
with:
328377
name: regression_summary
329378
path: summary.txt
330379

331380
- name: Upload Comparison Results
332-
uses: actions/upload-artifact@v3
381+
uses: actions/upload-artifact@v4
333382
with:
334383
name: regression_test_comparison_results
335384
path: |
@@ -339,7 +388,7 @@ jobs:
339388
- name: Code coverage install and run
340389
if: success() || ( failure() && steps.regression-execution.conclusion == 'success' )
341390
run: |
342-
mamba install -y -c conda-forge codecov
391+
conda install -y -c conda-forge codecov
343392
codecov
344393
345394
build-and-push-docker:
@@ -349,7 +398,7 @@ jobs:
349398
# who knows ¯\_(ツ)_/¯
350399
#
351400
# taken from https://github.com/docker/build-push-action
352-
needs: build-and-test
401+
needs: regression-test
353402
runs-on: ubuntu-latest
354403
if: github.ref == 'refs/heads/main' && github.repository == 'ReactionMechanismGenerator/RMG-Py'
355404
steps:

.github/workflows/docs.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ jobs:
3636
activate-environment: rmg_env
3737
use-mamba: true
3838
show-channel-urls: true
39-
channels: conda-forge,cantera,rmg
4039

4140
- name: Install sphinx
4241
run: mamba install -y sphinx

.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)