-
Notifications
You must be signed in to change notification settings - Fork 21
[Feature] Two-way python bridge with limited MAPL support in Python #4369
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
base: develop
Are you sure you want to change the base?
Conversation
|
We will have a meeting this afternoon to take a quick look. A deeper dive will wait until next week. |
Restrict it to known SIGFPE issue on numpy import
|
Python API updated to simplify retrieving memory. Now you can do MAPLPy = get_MAPLPy()
T = MAPLPy.get_pointer("T", state=import_state, dtype=np.float32, dims=MAPLPy.grid_dims)and you get Fortran memory mapping in |
|
Well, that coupled CI failure is weird. I'm re-running it. |
|
With the latest round of Python work I believe we have reached MVP - review away! |
|
I tested with NAG by hand and it's happy too. |
Replace GridComp by MaplComp
Add a larger bypass IEEE importer with other packages used in DSL
Types of change(s)
Checklist
make tests)Description
This PR aims at solving the "90%" case of Python integration has it as been seen lately at GMAO. The main features are:
The entire API is heavily
#ifdefby a flag at compile timeBUILD_PYTHONBRIDGE- by default the functions are passthroughs.Review points
@tclune / @atrayano: it was non-trivial for me to find a spot where I could initialize the system with the atmospheric grid. I ended up calling in
GEOSAgcm_GridComp(see sister PR). This is only needed because right now the bridge back to MAPL gives me the pointer "blind", without sizes and rank. So I am giving the GRID to users so we can tool down.A better version would be to augment the "MAPLpy" bridge to get shape and ranks, but I'd like to see that in a subsequent version so we can stress test this bridge first.
@mathomp4: I ended up not feeding the
add_definitionsupstream like we talked about. I kept it within theMAPL.python_bridgecmakelist and forwarded the API there. This looks cleaner and achieve the "opt-in by default" behavior we wanted.@pchakraborty: You should find the design quite familiar. It's a CFFI bridge, like we've done before. The trick relies in the
_get_code_object_from_package_namewhere I dynamically load the user given module and search for aCODEobject. The README spells it out with some code. The rest is marshalling up & down memory viavoid*.