-
Notifications
You must be signed in to change notification settings - Fork 74
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
Road map for migrating to PyBind11 and Python3.x support. #81
Comments
Thanks for rethinking this, David! And great to see you back in full force! 👍 I've just returned from an internship, so I'm catching up with all the news here.
|
We've also discussed utilising c++17 (namely TS Filesystem & TS Parallel) to also avoid boost at all, although there were some (build flags) problems getting it work. Also compiler support is on edge. What c++ version do we settle at? I'd suggest 17, even though new, as before this repo matures, the support should be more common-place (?)
Just tag me and I'll do the review ASAP
At that point we should reintroduce the Windows CI too, #69 |
I think it best to stay with C++11 until APR is removed. Then replace any remaining parts of Boost with std::. There are some things that don't have a direct std:: replacement...Graphic Algorithms in particular. So lets take it in smaller steps. |
I'll comment/review on your summary from PR #79
we could do this now.
Done (with changes), Boost is in master, linking to it fails. We'll need to fix that first.
avoid, if possible
I'd use either, or, but not both. Decide for one approach and we'll stick with it.
That way we'll be able to later swith with just a few line-changes.
👍
👍
we can switch to, at least c++14, where shared_ptr is, imho
👍
👍
ok, if needed
omit this, as we don't plan MinGW for the future?
that's great
skip formatting changes? Unless it's some nice cleanup of the code |
Well, maybe rather than doing this a file per PR, I could do PR's in these 15 steps.
|
yep, agree, just suggested that elsewhere.
Boost may need fixing. When actually using it in PR #79 , I got it to compile, but have link errors. The ordering sounds good to me, then we can do the remaining steps. |
As for C++11, C++14 or C++17
Otherwise it is just filesystem that is the problem.
|
Let's remove that. The class is not used anywhere in our codebase, even its doc says it's not used in production.
Does it mean OSX cannot support c++17+fs? Or XCode is just an IDE and ppl could install clang7? In my view the decision is: "c++11 + Boost" / "C++17 pure"
TL;DR: If OSX can get c++17+filesystem to work, I'd vote for pure c++17, and we can even get rid off Boost! Otherwise, go with c++17 & Boost for now. |
|
Talking about things to get rid of, here are some more candidates:
|
Ok, let's stick to it:
|
Thing is, do you want to deal with #115 now (smart pointers in Region etc), or proceed straight with 4,5,6 (pybind/swig) and leave pointers for later, as those are not necessarily important for that? |
I don't think SparseBinaryMatix would by much impact or be impacted by the PyBind11. So that could be done in parallel I would think. I am tempted to finish the Region and Link pointers now but that could end up being a rabbit hole. Perhaps I should proceed to the PyBind part. |
Great
Entirely up to you, I'm lost in Engine,Regions,Links the same way you feel about Random :) |
I have a small problem with one of the websites that I maintain and I need to go work on that but when that is finished I will start in on PyBind. I don't expect it to be more than a couple of days. @chhenning has already done most of the work for PyBind so I will be just merging in his code mostly. This will be a large number of changes again. I was looking at this to see if there was some way to break it up but there does not seem to be much we could isolate. We could build the PyBind part in parallel with SWIG in one PR and then remove SWIG in a second. However there could be some conflict between the two if we tried to build both in one module. For one thing, how would we tell the Python code which interface to use. So lets just do the whole thing in one go. I will need to go back and re-read the documentation on PyBind11 again so I can understand all of the py_xxx.cpp interface files. They don't look complicated but I am sure there will be complications once I start putting it together. Maybe @chhenning can help us out if we get stuck. |
Ok, let me go take care of my website then I can get started on the PyBind.
…On Sun, Nov 25, 2018 at 7:06 AM breznak ***@***.***> wrote:
So that could be done in parallel I would think.
Great
the Region and Link pointers now but that could end up being a rabbit
hole. Perhaps I should proceed to the PyBind part.
Entirely up to you, I'm lost in Engine,Regions,Links the same way you feel
about Random :)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#81 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFBa_37ezkyVNzQQU4chb72woXVB5KSKks5uyrHlgaJpZM4YO6XC>
.
|
There's no hurry, finish your work.
this is what I worry too. We've already disabled Win CI, if some deep problems occur, we'd be stuck with half-working repository.
|
Ok, sounds good. |
I am starting to look at the PyBind11 PR. I am considering adding a new sub-directory 'py_interface' which is parallel with 'src'. This will contain all Python related code and a CMakeLists.txt. The top CMakeLists.txt would refer to this new CMakeList.txt with:
The structure would be something like: Any comment on this? Should I call them something else? Where should we put the python3 code that was ported from the 'nupic' repository? Probably not here. |
An alternative might be |
On Mon, 26 Nov 2018 at 16:31, David Keeney ***@***.***> wrote:
I am starting to look at the PyBind11 PR. I am considering adding a new
sub-directory 'py_interface' which is parallel with 'src'. This will
contain all Python related code and a CMakeLists.txt. The top
CMakeLists.txt would refer to this new CMakeList.txt with:
+1 for a separate dir for each language interface, with its cmake
I would place that in src/nupic/bindings/xxx
if (NUPIC_BUILD_PYEXT_MODULES)
add_subdirectory(py_interface)
endif()
The structure would be something like:
py_interface
'--bindings (all of the binding code for pybind11)
tthat means the pybind headers? If not, I’ll also add a local include/ dir
'--plugin (source for Plugin components: PyRegionImpl.cpp/.hpp,
RegisteredRegionImplPy.hpp, etc)
'--test
Any comment on this? Should I call them something else?
Where should we put the python3 code that was ported from the 'nupic'
repository? Probably not here.
is it needed? If not, let’s just do bindings now.
Later I’d drop python 2 and support only 3
|
What I was trying to do was isolate all of the Python components in their own directory which is not under src/CMakeList.txt but rather under their own parallel CMakeList.txt. I think of the src subdirectory as being the core C++ library component and would rather not put python stuff in there. But do you think they really should be there?
Perhaps an another layout:
What I think you are saying is something like this:
Is that really what you want? Obviously the nupic .py code for Python3 (and perhaps Python2) would be someplace else. CSharp code that is a port of the python code would also go someplace else. Eventually we would have C++ components that are not part of the nupic C++ library; ports of the nupic .py code for running C++ only applications. Those also would go someplace else. What I show as bindings in the previous message is manually written mappings for the interface (written in C++ but are similar in function to the python helper routines used with SWIG). This is not the PyBind11 header files. The header files are part of the dependency stuff. The plugin files are the parts of the Network framework that are required so that the Python interface can be a plugin. |
Oh, and I was NOT going to build the python interface modules inside the nupic C++ statuc library. Each language interface would have their own static or dynamic libraries (or whatever they use) to connect in the language. Do you have a different vision? |
@chhenning I am in the process of creating a CMakeLists.txt file that can build PyBind11. I was going to use your repository at https://github.com/chhenning/nupic as a template. But I don't see the .sln file. If it was in the 'build' folder, that folder is not uploaded. I would like to see that to see how you put together the binding libraries and installed them. |
Hi David, you can find the solution file here: https://github.com/chhenning/nupic/tree/master/external/vs2017/nupic |
Perfect. I must have looked right at it and somehow missed it. |
@breznak I am hoping we can continue this discussion about the directory layout. We all need to be happy with how this is structured because it would be difficult to change later. My arguments are
So, my thinking is that the language interfaces should be parallel directories. They are dependent on the core but the core is not dependent on them. Perhaps put all languages under a bindings directory. This might better convey what we are trying to do.
Actually I like this arrangement better. What do you think? |
Sorry @dkeeney , I posted my answer in the morning...but it actually didn't send.
I was just suggesting this 👍 It's a layout I find the most intuitive and modular. I minor issue is with Pybind's location. Is it like SWIG and can offer interface to many languages? (then external), or only for PY (fine 👍 ), then maybe bindings/py/external/ ? My reasoning is that all the interface/module codebase would be self-contained. |
PyBind is just for Python. So it should be in the py folder.
By the way, I am building this initially using MSVC so when I finish it should build under MSVC, linux, and OSx. |
💯 That's pretty cool! So we'll be able to enable full Win support soon. #69 |
Another big step was #136 pybind11 !
Couple of small things that might/not be done:
|
@breznak you could go change the Spec structure in TestNode, lines 291 and 300 to populate the sparse flag to false (and perhaps move TestNode to test folder). Then the LinkTests could be turned back on. But this issue still needs to be resolved. gtest is a Third party module and as such should be in external. It also should be downloaded and installed rather than having included files. It must be updated before we can use C++17. |
How is the python generator step going? |
Going quite well actually. Some minor complications.
|
With big fanfare! 🎉 🎉 👏 I'd like to thank @dkeeney , our now official "master of pulling large PRs and revamps successfully!" for finishing port from SWIG to PyBind! Based on @chhenning 's work, so big thank you to both! 👍 There are a few things in pybind migration that are TODO, but our migration is successfully over! This is now closed 💯 👍 |
Here is what I propose:
I am going to abandon issue #74 (Replace APR) and PR #79. I was trying to do this in too large of a chunk. I also messed up and ended up with massive whitespace change due to line ending changes (working on windows trying to get MinGW to work). lets break up the effort into smaller parts.
New PR to replace existing header only Boost with Boost with filesystem and system modules.
A new PR for each file, or very small groups of files, to replace the APR calls to std:: or boost:: calls.
This will be a lot of PR's so I will need help in getting these reviewed. The work is already done, just need to open the PR and copy my changes on a file by file bases.
A new PR to remove the APR libraries...delete only
Then we can look at removing SWIG and replacing it with PyBind11.
4) Change some coupling in RegionImplFactory so that the Python related code can be isolated.
Build PyBind11 interface module (based on work by @chhenning). Might not be able to run both PyBind11 and SWIG in the same module but maybe we could just disable SWIG for this PR.
Remove SWIG.
At this point we can look at Porting more modules from Python code into the core such that it can be used as a stand-alone C++ library. Specifically SPRegion and TMRegion as well as lots of encoders.
The text was updated successfully, but these errors were encountered: