Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overhaul RMG-RMS Python-Julia dependencies & Add tests for many testless Arkane network algorithms #2640

Closed
wants to merge 53 commits into from

Conversation

hwpang
Copy link
Contributor

@hwpang hwpang commented Mar 22, 2024

Motivation or Problem

PythonCall.jl, CondaPkg.jl, and PythonPlot.jl supersede PyCall.jl, Conda.jl, and PyPlot.jl packages. The latter have caused many troubles during RMS installation.

Some key differences between PythonCall and PyCall

  • PythonCall has a compatible JuliaCall package that provide symmetric interface going from Julia to Python and Python to Julia
  • "PythonCall by default never copies mutable objects when converting, but instead directly wraps the mutable object. This means that modifying the converted object modifies the original, and conversion is faster" (See here)

I put together a RMG-RMS twin PR at ReactionMechanismGenerator/ReactionMechanismSimulator.jl#256 to switch to use PythonCall.jl, CondaPkg.jl, and PythonPlot.jl from their old versions PyCall.jl, Conda.jl, and PyPlot.jl.

This PR makes necessary changes on the RMG end to keep the RMG-RMS compatibility.

Moreover, during working on this, I found that many new network algorithms in Arkane are not tested. I have added additional tests for them.

Description of Changes

Some major changes include

  • Use pyjuliacall instead of pyjulia to call Julia modules from Python.
  • Use juliaup to install Julia instead of using the julia binary from conda-forge. I have found that user the latter can cause many issues on the RMG end as it doesn't check package depedencies appropriately. juliaup is Julia's official version manager.
  • Get rid of unnecessary dependencies on pyrms and diffeqpy. We use diffeqpy to get CVODE_BDF and solve but that is unnecessary. Now we get CVODE_BDF from Sundials and solve from SciMLBase. This helps RMG to reduce package dependencies even more.

Testing

A clear and concise description of testing that you've done or plan to do.

Reviewer Tips

Suggestions for verifying that this PR works or other notes for the reviewer.

rmgpy/rmg/reactors.py Outdated Show resolved Hide resolved
@hwpang hwpang changed the title Testing PythonCall compatibility with RMG Overhaul RMG's Julia dependencies Apr 2, 2024
@hwpang hwpang changed the title Overhaul RMG's Julia dependencies Overhaul RMG-RMS Python-Julia dependencies Apr 2, 2024
@hwpang hwpang changed the title Overhaul RMG-RMS Python-Julia dependencies Overhaul RMG-RMS Python-Julia dependencies & Add tests for many testless Arkane explorer algorithms Apr 3, 2024
@hwpang hwpang changed the title Overhaul RMG-RMS Python-Julia dependencies & Add tests for many testless Arkane explorer algorithms Overhaul RMG-RMS Python-Julia dependencies & Add tests for many testless Arkane network algorithms Apr 3, 2024
@JacksonBurns
Copy link
Contributor

@hwpang also consider editing the Dockerfile:

ENV JULIA_CPU_TARGET="x86-64,haswell,skylake,broadwell,znver1,znver2,znver3,cascadelake,icelake-client,cooperlake,generic"

@hwpang
Copy link
Contributor Author

hwpang commented Apr 3, 2024

@hwpang also consider editing the Dockerfile:

ENV JULIA_CPU_TARGET="x86-64,haswell,skylake,broadwell,znver1,znver2,znver3,cascadelake,icelake-client,cooperlake,generic"

It doesn't seem that this can be removed by this PR. From here, it sees that is used to avoid compilation overhead

Copy link

codecov bot commented Apr 5, 2024

Codecov Report

Attention: Patch coverage is 54.54545% with 25 lines in your changes are missing coverage. Please review.

Project coverage is 55.45%. Comparing base (7519944) to head (4bec89e).
Report is 18 commits behind head on main.

Current head 4bec89e differs from pull request most recent head a7fe72f

Please upload reports for the commit a7fe72f to get more accurate results.

Files Patch % Lines
rmgpy/pdep/sls.py 22.22% 14 Missing ⚠️
rmgpy/rmg/reactors.py 70.27% 11 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2640      +/-   ##
==========================================
+ Coverage   54.88%   55.45%   +0.57%     
==========================================
  Files         125      125              
  Lines       37025    37057      +32     
==========================================
+ Hits        20321    20551     +230     
+ Misses      16704    16506     -198     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hwpang
Copy link
Contributor Author

hwpang commented Apr 5, 2024

All tests have passed 🥳🥳🥳 @mjohnson541 Could you review before I clean up the commits? @JacksonBurns Let's work out a plan on the merge sequence with your other PRs

Copy link
Contributor

@mjohnson541 mjohnson541 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heroic effort!

Sorry, about the missing pdep algorithm tests, that's my bad.

I have a few questions about how these changes work, but it looks pretty good.

environment.yml Show resolved Hide resolved
path_rms = dirname(dirname(dirname(abspath(__file__))))
from julia.api import Julia

jl = Julia(sysimage=join(path_rms, "rms.so")) if exists(join(path_rms, "rms.so")) else Julia(compiled_modules=False)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we breaking workflows for people that use system images to avoid compilation?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also curious about this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean by using a (global) Julia binary instead of the one come with the conda environment?

Copy link
Contributor

@mjohnson541 mjohnson541 Apr 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this tool: https://github.com/MichaelHatherly/SystemImageLoader.jl allows adding of system images to juliaup.

This implies we could imagine later using some of these new tools like: https://julialang.github.io/PackageCompiler.jl/dev/index.html to generate a system image with RMS already precompiled and use the other tool to add it to juliaup during installation. The caveat being if you ever want to modify RMS you have to remove that image. However, the process doesn't look particularly difficult anymore. PackageCompiler looks pretty straightforward. Not as sure about the other package.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think any of us is using this function, and I have also never used this. I don't think we should get ahead of ourselves to provide a service that maybe no one will use. I prefer to wait till someone complains about not having this option anymore, or just let them figure it out rather than doing their work for them.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Contributor

@JacksonBurns JacksonBurns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're a wizard! Thanks for taking this on. A number of small-ish comments throughout.

Overall comment - I did a quick search all for python-jl and found nothing, so I think you totally caught them all (thanks!).

.github/workflows/CI.yml Outdated Show resolved Hide resolved
.github/workflows/CI.yml Show resolved Hide resolved
.github/workflows/CI.yml Outdated Show resolved Hide resolved
Dockerfile Outdated Show resolved Hide resolved
documentation/source/users/rmg/releaseNotes.rst Outdated Show resolved Hide resolved
rmgpy/rmg/reactors.py Show resolved Hide resolved
rmgpy/rmg/reactors.py Outdated Show resolved Hide resolved
rmgpy/rmg/reactors.py Outdated Show resolved Hide resolved
rmgpy/rmg/reactors.py Outdated Show resolved Hide resolved
rmgpy/rmg/reactors.py Show resolved Hide resolved
@hwpang hwpang force-pushed the test_rms branch 2 times, most recently from 95ad95c to a8b42d1 Compare April 25, 2024 20:57
@hwpang
Copy link
Contributor Author

hwpang commented Apr 25, 2024

@JacksonBurns @mjohnson541 I've addressed most of the comments and have a couple of clarifying questions

@hwpang
Copy link
Contributor Author

hwpang commented May 14, 2024

@mjohnson541 @JacksonBurns I have addressed all the comments. Please review/approve. Thanks.

@hwpang
Copy link
Contributor Author

hwpang commented Jun 7, 2024

The CI is failing because PythonCall.jl has recently added a requirement for python version to be >=3.8 here. During RMG subgroup discussion, we have decided to wait to merge this PR after #2635.

@JacksonBurns
Copy link
Contributor

@hwpang I'm revisiting this following some of the discussion in #2684 - I realize now that using the conda binary for juliaup might not be the best idea and that we would be better off using their official installation instructions. I say this because there are already reports on the juliaup conda feedstock that it is installing packages in the incorrect conda environment: conda-forge/juliaup-feedstock#62

The official juliaup installation instructions say to use a shell script (https://github.com/JuliaLang/juliaup?tab=readme-ov-file#mac-and-linux) and provide a GitHub actions step for our CI (https://github.com/JuliaLang/juliaup?tab=readme-ov-file#continuous-integration-ci) - your thoughts?

@mjohnson541
Copy link
Contributor

I just tested setting JULIAUP_DEPOT_PATH to a path inside the env before telling juliaup to install julia, without setting it it installs .julia etc in the default location for julia (not ideal for conda), with it defined it installs it where I told it to, so we probably need to set that to a path we choose inside the conda environment.

@JacksonBurns
Copy link
Contributor

Development moved to #2687

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants