-
Notifications
You must be signed in to change notification settings - Fork 23
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
Add python bindings #35
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like where this is going. Thanks for the efforts. The TODO-list seems reasonable to me.
I had some concerns originally of whether the binding should be an external tool in a separate repository which simply uses mmtf-cpp. But actually, the way you are implementing it is very nicely separated anyways and it makes sense the way it is included here. So as long as everything stays in the separate "bindings" folder and is only included if requested in cmake, it's all good.
CMakeLists.txt
Outdated
# set(PYTHON_INCLUDE_DIR_A python_include_A) | ||
# set(PYTHON_INCLUDE_DIR_B python_include_B) | ||
|
||
target_include_directories(mmtf_py PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Picky observation: there's a mix of tabs and spaces here. It would be preferred to stick to one style at least within the same file.
@gtauriello thanks for your comments! I think it will be a relatively minor addition to the library when it's all said and done, hopefully totaling in at under 1000 lines (of course there's a lot of python init boilerplate that baloons that), but it's all quite simple. |
@gtauriello and @speleo3 could you review this when you get a chance? I think this is ready for a 1-4 week trial run in master, and then once we are happy with it I can publish it to pip. what are your thoughts? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to split this into several pull requests
- submodule reorganization
const
API changes- fix for Segmentation fault with -march=native #36
- actual python bindings feature
Can you add a README for the Python usage? It's not obvious what the suggested usage pattern is, the tests are the only hints.
The wrapping looks tedious and very explicit, I assume there is no way to do it automated? I hope this complexity is no burden for the long-term maintainability of mmtf-cpp
.
[submodule "submodules/msgpack-c"] | ||
path = submodules/msgpack-c | ||
url = https://github.com/msgpack/msgpack-c.git | ||
[submodule "submodules/Catch2"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Catch2
listed twice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will fix this once the other two PRs are merged
.gitmodules
Outdated
[submodule "submodules/--force"] | ||
path = submodules/--force | ||
url = https://github.com/msgpack/msgpack-c.git |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
submodules/--force
? Looks like an accident
.travis.yml
Outdated
addons: *linux64 | ||
- os: linux | ||
compiler: clang | ||
addons: *linux64 | ||
- os: linux | ||
compiler: gcc | ||
env: ARCH=x86 CMAKE_EXTRA=-DHAVE_LIBM=/lib32/libm.so.6 | ||
env: ARCH=x86 CMAKE_EXTRA=-DHAVE_LIBM=/lib32/libm.so.6 TEST_COMMAND=$TRAVIS_BUILD_DIR/ci/build_and_run_tests.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TEST_COMMAND
redundant with global value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TEST_COMMAND environment variable is a way to run two different tests. I could not find a better way to run two different test suites. If you have any examples of repos that do this in a nicer way, I would be happy to learn a more efficient way and refactor this.
in this case TEST_COMMAND is not redundant because the env:
block is overwriting the global value.
.travis.yml
Outdated
compiler: gcc | ||
addons: *linux64cpp17py36 | ||
dist: bionic | ||
env: TEST_COMMAND=$TRAVIS_BUILD_DIR/ci/build_and_run_python_tests.sh CC=gcc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add a global TEST_COMMAND_PYTHON
and use
env : TEST_COMMAND=$TEST_COMMAND_PYTHON
And is CC
needed? Looks redundant with compiler: gcc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tested this, and apparently... yes it is required for some reason, even though you would think otherwise..
@@ -163,7 +163,7 @@ struct StructureData { | |||
std::string title; | |||
std::string depositionDate; | |||
std::string releaseDate; | |||
std::vector<std::vector<float> > ncsOperatorList; | |||
std::vector<std::vector<float>> ncsOperatorList; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is C++11 syntax. As far as I know this project is still C++03 (but you have my vote for dropping that).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing you meant to comment this somewhere else?
self.sourcedir = os.path.abspath(sourcedir) | ||
|
||
|
||
class CMakeBuild(build_ext): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the advantages of using cmake
here? Can't setuptools
build an extension directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose we could, but we already have cmake baked into this repo and it was relatively simple to set it up to use cmake. If you are aware of some pitfalls of using this type of workflow (setup.py -> cmake) I'm open to changing it, but I found this method relatively painleses.
long_description=open("README.md").read(), | ||
packages=find_packages("python_src", exclude=["tests", "python_src/tests"]), | ||
package_dir={"": "python_src"}, | ||
ext_modules=[CMakeExtension("mmtf_cppy/")], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name mmtf_cppy
is a bit odd. How about dropping the y
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's possible we could just kill the python implementation with this one too and just use mmtf. but that would make them incompatible with eachother
@speleo3 Thank you for taking the time to review! I'll split this out into 3 requests and then I can address your concerns |
Thanks to both of you for your efforts here and sorry if I've been quiet lately. At SWISS-MODEL, we are currently involved in some modeling efforts for SARS-CoV-2 which makes it hard for me to look at this code. That being said, I'll try to contribute what I can... |
@@ -1,57 +1,96 @@ | |||
--- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I 'linted' this file using yamllint, sorry for the noise
done
I actually did use https://github.com/RosettaCommons/binder to generate the initial bindings. but in this case binder is not a great fit because
it was actually very easy to do most of the bindings. char related data was the only difficult thing to use. |
reminder bump! |
Hi all, |
Ciao all. I am so sorry that I left this pending for so long. I now merged the other 2 PRs and did a 3rd one for the segfault issue (as @speleo3 had suggested). Also: honestly, I simply don't find time for this project any more. Can one of you @danpf or @speleo3 take it over? I think I can pass admin rights to one (or both) of you for this... @danpf for the code itself: Comments on the README:
|
@danpf One more thing for after the PR and master merges. Can you add an item to the CHANGELOG about the python bindings? |
this may not ever be merged, but here I recreate the basics of mmtf-py using this library only.
it is currently significantly faster than the mmtf-py implementation.
the only 'question' that is really left to solve is how to handle the templating of the mapdecoder. But I think that will not be too difficult. Once i get some time to look at it.
not to get ahead of myself -- but TODO: