Skip to content

Commit 43018b1

Browse files
authored
Merge pull request #268 from hwpang/fix_installation
Attempting to Fix the `juliacall` Overhaul on RMG
2 parents c15ad5a + cf83540 commit 43018b1

29 files changed

+17556
-215
lines changed

.github/workflows/CI.yml

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,19 @@ jobs:
1111
test:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v2
15-
- uses: julia-actions/setup-julia@v1
14+
- uses: actions/checkout@v4
15+
16+
- name: Setup Juliaup
17+
uses: julia-actions/install-juliaup@v2
1618
with:
17-
version: 1.8
18-
- uses: actions/cache@v1
19-
env:
20-
cache-name: cache-artifacts
21-
with:
22-
path: ~/.julia/artifacts
23-
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
24-
restore-keys: |
25-
${{ runner.os }}-test-${{ env.cache-name }}-
26-
${{ runner.os }}-test-
27-
${{ runner.os }}-
28-
- uses: conda-incubator/setup-miniconda@v2
29-
with:
30-
environment-file: environment.yml
31-
python-version: 3.7
32-
activate-environment: rms_env
33-
- name: Fix PyCall linking
34-
run: |
35-
julia -e 'ENV["PYTHON"]=ENV["CONDA"] * "/envs/rms_env/bin/python"; using Pkg; Pkg.add("PyCall"); Pkg.build("PyCall")'
36-
- uses: julia-actions/julia-buildpkg@v1
37-
- name: Build
38-
run: |
39-
julia -e 'using Pkg; Pkg.develop(PackageSpec(path="../ReactionMechanismSimulator.jl")); Pkg.build("ReactionMechanismSimulator");'
40-
- name: Run tests
19+
channel: '1.10'
20+
21+
- name: Build and Test
4122
run: |
42-
julia -e 'using Pkg; Pkg.test("ReactionMechanismSimulator";coverage=true)'
23+
julia -e 'using Pkg; Pkg.develop(Pkg.PackageSpec(path="../ReactionMechanismSimulator.jl/")); Pkg.build("ReactionMechanismSimulator"); Pkg.test("ReactionMechanismSimulator"; coverage=true)'
24+
4325
- uses: julia-actions/julia-processcoverage@v1
26+
4427
- uses: codecov/codecov-action@v1
4528
with:
4629
file: lcov.info

.github/workflows/documentation.yml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,24 @@ jobs:
1313
contents: write
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: actions/checkout@v2
17-
- uses: julia-actions/setup-julia@latest
18-
with:
19-
version: 1.8
20-
- uses: conda-incubator/setup-miniconda@v2
16+
- uses: actions/checkout@v4
17+
18+
- name: Setup Juliaup
19+
uses: julia-actions/install-juliaup@v2
2120
with:
22-
environment-file: environment.yml
23-
python-version: 3.7
24-
activate-environment: rms_env
25-
- name: Install dependencies
21+
channel: '1.10'
22+
23+
- uses: julia-actions/cache@v2
24+
25+
- uses: julia-actions/julia-buildpkg@v1
26+
27+
- name: Build
2628
run: |
27-
julia -e 'ENV["PYTHON"]=ENV["CONDA"] * "/envs/rms_env/bin/python"; using Pkg; Pkg.add("PyCall"); Pkg.build("PyCall")'
28-
julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate();'
29-
- name: Build and deploy
29+
julia -e 'using Pkg; Pkg.develop(Pkg.PackageSpec(path="../ReactionMechanismSimulator.jl/")); Pkg.build("ReactionMechanismSimulator"); Pkg.instantiate();'
30+
31+
- name: Build and deploy Documentation
3032
env:
3133
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # For authentication with GitHub Actions token
3234
DOCUMENTER_DEBUG: true
33-
run: julia --color=yes --project=docs docs/make.jl
35+
run: |
36+
julia --color=yes --project=docs docs/make.jl

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,8 @@
33
*.dot
44
docs/build/
55
.DS_Store
6-
deps/build.log
6+
deps/build.log
7+
.CondaPkg/
8+
rms_env/
9+
*.cov
10+
Manifest.toml

CondaPkg.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
channels = ["mjohnson541", "rmg", "conda-forge", "cantera"]

Project.toml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ version = "1.0.0"
66
[deps]
77
Calculus = "49dc2e85-a5d0-5ad3-a950-438e2897f1b9"
88
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
9-
Conda = "8f4d0f93-b110-5947-807f-2305c1781a2d"
9+
CondaPkg = "992eb4ea-22a4-4c89-a5bb-47a3300528ab"
1010
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
1111
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
1212
FastGaussQuadrature = "442a2c76-b920-505d-bb47-c5924d526838"
@@ -21,8 +21,8 @@ ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
2121
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
2222
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
2323
PreallocationTools = "d236fae5-4411-538c-8e31-a6e3d9e00b46"
24-
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
25-
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"
24+
PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d"
25+
PythonPlot = "274fc56d-3b97-40fa-a1cd-1b4a50311bf9"
2626
QuartzImageIO = "dca85d43-d64c-5e67-8c65-017450d5d020"
2727
RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
2828
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
@@ -39,12 +39,11 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
3939
Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c"
4040
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
4141
YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6"
42-
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
4342

4443
[compat]
4544
Calculus = "0.4,0.5"
4645
Colors = "0.11,0.12"
47-
Conda = "1"
46+
CondaPkg = "0"
4847
CSV = "0.10"
4948
DataFrames = "1"
5049
SciMLSensitivity = "^7"
@@ -58,8 +57,8 @@ ModelingToolkit = "8"
5857
OrdinaryDiffEq = "^6"
5958
Parameters = "0.12"
6059
PreallocationTools = "0.4"
61-
PyCall = "1"
62-
PyPlot = "2"
60+
PythonCall = "0"
61+
PythonPlot = "1"
6362
QuartzImageIO = "0.7"
6463
RecursiveArrayTools = "2.17"
6564
ReverseDiff = "1.9"
@@ -72,5 +71,4 @@ Symbolics = "4"
7271
Tracker = "0.2"
7372
Unitful = "^1.3"
7473
YAML = "0.4"
75-
Zygote = "0.5,0.6"
7674
julia = "^1.6"

deps/build.jl

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
1-
using PyCall
2-
using Conda
3-
packages = Conda._installed_packages()
4-
if !("rmg" in packages) && !("rmgmolecule" in packages) && (PyCall.pyversion.major != 3 || PyCall.pyversion.minor != 7)
5-
const Pkg = Base.require(Base.PkgId(Base.UUID("44cfe95a-1eb2-52ea-b672-e2afdf69b78f"), "Pkg"))
6-
Conda.rm("mamba")
7-
Conda.add("conda=4")
8-
Conda.add("mamba")
9-
Conda.update()
10-
Conda.add("python=3.7")
11-
try
12-
Conda.rm("numpy") #get around MKL problem
13-
catch e
1+
using CondaPkg
2+
using PythonCall
3+
4+
has_rmgpy = true
5+
has_rmgmolecule = true
6+
try
7+
PythonCall.pyimport("rmgpy")
8+
catch
9+
has_rmgpy = false
10+
end
11+
try
12+
PythonCall.pyimport("molecule")
13+
catch
14+
has_rmgmolecule = false
15+
end
16+
17+
if !has_rmgpy && !has_rmgmolecule
18+
19+
if !(v"3.7" <= PythonCall.C.python_version() && PythonCall.C.python_version() <= v"3.9")
20+
CondaPkg.add("python"; version=">=3.9")
1421
end
15-
Conda.add("nomkl")
16-
Conda.add("numpy")
17-
Conda.add_channel("mjohnson541")
18-
Conda.add_channel("hwpang")
19-
Conda.add("rmgmolecule")
20-
Pkg.build("PyCall")
21-
end
22+
CondaPkg.add("rmgmolecule"; version=">=0.3.0", channel="mjohnson541")
23+
CondaPkg.add("matplotlib", channel="conda-forge")
24+
CondaPkg.add("rdkit", channel="conda-forge")
25+
CondaPkg.add("pydot", channel="conda-forge")
26+
end
27+
28+
const Pkg = Base.require(Base.PkgId(Base.UUID("44cfe95a-1eb2-52ea-b672-e2afdf69b78f"), "Pkg"))
29+
Pkg.build("PythonCall")

docs/src/Installation.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ The above instructions will automatically handle Julia-Python linking. However,
3737

3838
```
3939
import Pkg
40-
Pkg.add("PyCall")
41-
ENV["CONDA_JL_HOME"] = PATH_TO_YOUR_ENV
42-
Pkg.build("Conda")
43-
ENV["PYTHON"] = PATH_TO_PYTHON
44-
Pkg.build("PyCall")
40+
ENV["JULIA_CONDAPKG_BACKEND"] = "Null"
41+
ENV["JULIA_PYTHONCALL_EXE"] = "/path/to/python"
42+
Pkg.add("CondaPkg")
43+
Pkg.build("CondaPkg")
44+
Pkg.add("PythonCall")
45+
Pkg.build("PythonCall")
4546
```

environment.yml

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

iJulia/Automatic Mechanism Analysis Example.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"outputs": [],
99
"source": [
1010
"using Sundials\n",
11-
"using PyPlot\n",
11+
"using PythonPlot\n",
1212
"using ReactionMechanismSimulator"
1313
]
1414
},

iJulia/ConstantPH2Combustion.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"outputs": [],
3030
"source": [
3131
"using DifferentialEquations\n",
32-
"using PyPlot\n",
32+
"using PythonPlot\n",
3333
"using ReactionMechanismSimulator"
3434
]
3535
},

iJulia/ConstantTPH2Combustion.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"using DiffEqBase\n",
1010
"using Sundials\n",
1111
"using DiffEqSensitivity\n",
12-
"using PyPlot\n",
12+
"using PythonPlot\n",
1313
"using ReactionMechanismSimulator"
1414
]
1515
},

iJulia/ConstantTVOctaneOxidation.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"outputs": [],
88
"source": [
99
"using DifferentialEquations\n",
10-
"using PyPlot\n",
10+
"using PythonPlot\n",
1111
"using ReactionMechanismSimulator"
1212
]
1313
},

iJulia/ConstantVH2Combustion.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"outputs": [],
88
"source": [
99
"using DifferentialEquations\n",
10-
"using PyPlot\n",
10+
"using PythonPlot\n",
1111
"using ReactionMechanismSimulator"
1212
]
1313
},

iJulia/Gas-Catalyst Interface.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"outputs": [],
88
"source": [
99
"using ReactionMechanismSimulator\n",
10-
"using PyPlot\n",
10+
"using PythonPlot\n",
1111
"using DifferentialEquations\n",
1212
"using Sundials"
1313
]

iJulia/ParametrizedTConstantVOctaneOxidation.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"outputs": [],
88
"source": [
99
"using DifferentialEquations\n",
10-
"using PyPlot\n",
10+
"using PythonPlot\n",
1111
"using ReactionMechanismSimulator"
1212
]
1313
},

iJulia/ParametrizedTPH2Combustion.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"outputs": [],
88
"source": [
99
"using DifferentialEquations\n",
10-
"using PyPlot\n",
10+
"using PythonPlot\n",
1111
"using ReactionMechanismSimulator"
1212
]
1313
},

iJulia/ParametrizedVH2Combustion.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"outputs": [],
88
"source": [
99
"using DifferentialEquations\n",
10-
"using PyPlot\n",
10+
"using PythonPlot\n",
1111
"using ReactionMechanismSimulator"
1212
]
1313
},

iJulia/Quasi-Steady State Assumptions and Isomer Lumping.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"source": [
1010
"using ReactionMechanismSimulator\n",
1111
"using ReactionMechanismSimulator.Sundials\n",
12-
"using ReactionMechanismSimulator.PyPlot"
12+
"using ReactionMechanismSimulator.PythonPlot"
1313
]
1414
},
1515
{

iJulia/Vapor-Liquid Two-Phase Low-Temperature Pyrolysis.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1429,7 +1429,7 @@
14291429
"source": [
14301430
"using ReactionMechanismSimulator\n",
14311431
"using ReactionMechanismSimulator.Sundials\n",
1432-
"using ReactionMechanismSimulator.PyPlot"
1432+
"using ReactionMechanismSimulator.PythonPlot"
14331433
]
14341434
},
14351435
{

src/EdgeAnalysis.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,8 +1037,10 @@ function selectobjects(react,edgereact,coreedgedomains,coreedgeinters,domains,in
10371037
dydt,rts,frts,rrts,cs,corespeciesrates,charrate,edgespeciesrates,edgereactionrates,edgerxnradrateratios,
10381038
corespeciesrateratios,edgespeciesrateratios,corereactionrates,corespeciesconcentrations,
10391039
corespeciesproductionrates,corespeciesconsumptionrates = processfluxes(sim,corespcsinds,corerxninds,edgespcsinds,edgerxninds)
1040-
@inbounds ind = edgespcsinds[argmax(edgespeciesrates)]
1041-
@inbounds invalidobjects = [sim.species[ind]]
1040+
if !isempty(edgespeciesrates)
1041+
@inbounds ind = edgespcsinds[argmax(edgespeciesrates)]
1042+
@inbounds invalidobjects = [sim.species[ind]]
1043+
end
10421044
return (terminated,true,invalidobjects,unimolecularthreshold,
10431045
bimolecularthreshold,trimolecularthreshold,maxedgespeciesrateratios,t,conversion)
10441046
end

src/Parse.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Unitful
22
using YAML
3-
using PyCall
3+
using PythonCall
44
using StaticArrays
55

66
module Calc
@@ -131,7 +131,7 @@ function getatomdictfromrdkit(mol)
131131
atmD = Dict{String,Int64}()
132132
molecularweight = 0.0
133133
for atm in mol.GetAtoms()
134-
v = elementdict[atm.GetAtomicNum()]
134+
v = elementdict[PythonCall.pyconvert(Int64, atm.GetAtomicNum())]
135135
if v in keys(atmD)
136136
atmD[v] += 1
137137
else
@@ -140,9 +140,9 @@ function getatomdictfromrdkit(mol)
140140
end
141141
nbonds = length(mol.GetBonds())
142142
try
143-
molecularweight = Desc.MolWt(mol)/1000.0
144-
catch
145-
@warn("unable to compute molecular weight")
143+
molecularweight = PythonCall.pyconvert(Float64, Desc.MolWt(mol)) / 1000.0
144+
catch e
145+
@warn("unable to compute molecular weight: $e")
146146
end
147147
return atmD,nbonds,molecularweight
148148
end
@@ -151,15 +151,15 @@ export getatomdictfromrdkit
151151
function getatomdictfromrmg(mol)
152152
atmD = Dict{String,Int64}()
153153
for atm in mol.atoms
154-
v = elementdict[atm.element.number]
154+
v = elementdict[PythonCall.pyconvert(Int64, atm.element.number)]
155155
if v in keys(atmD)
156156
atmD[v] += 1
157157
else
158158
atmD[v] = 1
159159
end
160160
end
161161
nbonds = length(mol.get_all_edges())
162-
molecularweight = mol.get_molecular_weight()
162+
molecularweight = PythonCall.pyconvert(Float64, mol.get_molecular_weight())
163163
return atmD,nbonds,molecularweight
164164
end
165165
function getatomdictsmiles(smiles)

0 commit comments

Comments
 (0)