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

Feature/openeb updates #123

Merged
merged 17 commits into from
Oct 9, 2024

Conversation

coashby
Copy link
Contributor

@coashby coashby commented Jun 16, 2024

Commit Summary

  • Update to "opt-out" by default in CMake test and Python binding configuration options.
  • Build support for MacOSX
  • Updates to Readme and Docs

Notes

Tested Configurations

Platform OS [Container] Arch
Apple MacOS Monterey M1 pro chipset
Apple MacOS Monterey [Container - Ubuntu:latest 24.04 LTS] M1 pro chipset
Linux Ubuntu 23.10 AMD Ryzen 7 3700X 8-Core
Windows Window 10 Intel Core i7 7700 4-Core

coashby added 6 commits June 15, 2024 21:29
…lows for build requirements and instructions to be incrementally added.
…sed target two conditions explicitly: 1) Apple platforms NOT running Linux, and 2) platforms running Linux. No special considerations for Windows are made at this time.
…anges allow the apps to be built with a wider range of compatibility in the SW dependency versions maintained among Apple and Linux based package managers.
@lbristiel-psee
Copy link
Collaborator

Thanks for your contribution @coashby !
We're currently reviewing it and will get back to you shortly.

@coashby
Copy link
Contributor Author

coashby commented Jun 17, 2024

Thanks for your contribution @coashby ! We're currently reviewing it and will get back to you shortly.

Hey of course. You all have a great product and it's helping me get my business started. Hopefully the contributions work on your end and happy to engage in the review process as well.

Cheers

Copy link
Collaborator

@jthierry-psee jthierry-psee left a comment

Choose a reason for hiding this comment

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

Hello,

Thank you for your contribution. I do have a couple of remarks on the CMake/C++ part of things.

CMakeLists.txt Outdated
@@ -15,6 +15,9 @@ if(NOT CMAKE_BUILD_TYPE)
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif(NOT CMAKE_BUILD_TYPE)

option(COMPILE_PYTHON3_BINDINGS "Enable/Disable Python bindings. Python bindings are disabled by default." OFF)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This option is already defined on line 179 when not building on Android:
https://github.com/prophesee-ai/openeb/blob/main/CMakeLists.txt#L179

Also, is there a reason you set it to off by default? If building python bindings on MacOS is problematic, it can be disabled by default for this platform.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This option is already defined on line 179 when not building on Android

Hey, yeah I didn't catch that definition on line 179.

If building python bindings on MacOS is problematic, it can be disabled by default for this platform.

I am able to build the python bindings on MacOS.

Also, is there a reason you set it to off by default?

The main reason I thought to change this behavior is to present the simplest build case first. As I walked through the documentation trying to understand what was needed and what wasn't needed to build and use the C++ library, I realized gtest, pytest and pybind11 were all optional.
I think by giving users the option to ENABLE features like testing and python bindings empowers them to:

  • learn more about the product features incrementally
  • avoid having to install/remove packages that the don't actually need,

I added new documentation. I initially wrote it keeping the options ON be default. I personally found the documentation and build experience better with the options OFF by default so I went with it... but that's just my take.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@lbristiel-psee @ogeorget-psee what do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hi @coashby, thanks for your contrib and feedbacks !

I agree that anything related to testing the framework should be disabled by default to ease user experience. Even though CMake enable BUILD_TESTING by default, we can enforce to disable it and make sure that gtest and pytest are not required.

Regarding pybind and the python bindinds, it's a different story has they are entirely part of the API and must be provided to our Python end-users. There are legitimate cases where one would want to disable, that's where COMPILE_PYTHON3_BINDINGS should be set to false.

CMakeLists.txt Outdated
@@ -15,6 +15,9 @@ if(NOT CMAKE_BUILD_TYPE)
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif(NOT CMAKE_BUILD_TYPE)

option(COMPILE_PYTHON3_BINDINGS "Enable/Disable Python bindings. Python bindings are disabled by default." OFF)
option(BUILD_TESTING "Enable/Disable test applications." OFF)
Copy link
Collaborator

Choose a reason for hiding this comment

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

The BUILD_TESTING variable is already defined when including Ctest:
https://cmake.org/cmake/help/v3.30/module/CTest.html

Copy link
Collaborator

Choose a reason for hiding this comment

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

@jthierry-psee If we want this, we'll need to ensure those are enable in our CI.

@@ -655,7 +655,11 @@ std::ostream &save_device(const Device &d, std::ostream &os) {

google::protobuf::util::JsonPrintOptions options;
options.add_whitespace = true;
#if (GOOGLE_PROTOBUF_VERSION >= 5027000)
options.always_print_fields_with_no_presence = true;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you have any documentation on this?
I don't see this field being part of the JsonPrintOptions:
https://protobuf.dev/reference/cpp/api-docs/google.protobuf.util.json_util/#JsonPrintOptions

I see the field mentionned here:
https://protobuf.dev/news/v26/#JSON
But it states that it is replacing always_print_default_values which is not the field we are using (always_print_primitive_fields)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In regards to this change, I faced two issues while trying to build on Mac.

  1. I couldn't easily come up with a package formula that allowed me to install a compatible version of Protobuf. If I can figure this out, I would remove the code changes and keep everything to < v26.
  2. Once I decided to keep the newer package version, replacing the deprecated function was not straightforward. The best clues I found were from looking at the blame for PrintOptions definition (protobuf/src/google/protobuf/json/json.h) in the latest release version. In particular, these two commits (2699579 and 7d43131 in the protobuf repo.

TBH, I didn't love making this change, since the Protobuf documentation around it wasn't the best IMO. However, I figured it'd start a discussion as how to best resolve. I didn't spend time trying to test the implications of the new struct field, BUT I did test that the version flag worked properly.

Again would love to make this change better. Perhaps just forcing a specific version of protobuf would be best? but that also doesn't seem ideal as time goes on (right?) Just thinking out loud (please don't read anything negative in my comments!)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry for the delay on this topic, it looks like you are right. I opened a issue on protobuf side so they would update the documentation:
protocolbuffers/protobuf#17437

So your change seems ok. However, the renaming of the field seems to have taken place in v26.0 of protobuf, so the version number to check should be 5026000

#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <OpenGL/gl3.h>
#elif defined(__linux__)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We still want to include the below files for windows.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TLDR;

  • Should GL/gl.h be part of windows? I found this to break on my end.
  • GL/glew.h needs to be included as well but only for linux and windows. If GL/gl.h should NOT be part of the windows build then I suggest the following replacement logic:
...
#if defined(__APPLE__) && !defined(__linux__)
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <OpenGL/gl3.h>
#elif defined(__linux__)
#include <GL/glew.h>
#include <GL/gl.h>
#elif defined(WIN32)
#include <GL/glew.h>
#endif
...

Yes, I found this area a bit problematic.
On my windows build the installed vcpkg version ofGL/gl.h was causing the build to break.
I then looked at the include files packaged with the Windows installer for the Prophesee SDK. There the GL library does NOT include GL/gl.h. So I decided to try removing it from my build as well and it worked. So that's why I put the preprocessor directives for linux only.

It could be my windows dependencies are not set up correctly?
I wasn't able to get th Metavision::UI lib to build on Windows from the main branch. I ended up having to make some adjustments regardless.

I agree GL/glew.h needs to be included as well. That's why in my cryptic commit message I mentioned no explicit handling for windows (I apologize for that). I figured it would need to be added in, but I also wanted to address the GL/gl.h issue.
I also didn't want three separate #if defined rules if that could be avoided.
I should have just added it since I knew it was needed. Bad call on my part.

Copy link
Contributor Author

@coashby coashby Jun 20, 2024

Choose a reason for hiding this comment

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

I believe my most recent commit addresses most of your OpenGL related concerns.
I was also able to validate a working build on Windows. Thanks for your inputs. Hopefully it's improved and headed in the right direction.

@@ -46,11 +46,11 @@ struct GLFWContext {
throw std::runtime_error("Impossible to create a glfw window");

glfwMakeContextCurrent(window);

#if defined(__linux__)
if (glewInit() != GLEW_OK) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reason this function is not available for MacOS?
Anyway, we still want to call this on windows.

The best way to do what you want is to mimic what we did for GLES:
https://github.com/prophesee-ai/openeb/blob/main/sdk/modules/ui/cpp/include/metavision/sdk/ui/utils/opengl_api.h#L20
And provide a dummy implementation of glewInit() only for MacOS. It will avoid too much #if in actual implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! This makes a lot more sense now. In the midst of tackling the initial barrage of compiler errors, I missed this implementation hidden under GLES.
I also didn't realize that once I added #include <OpenGL/gl3.h> I didn't need the APPLE specific versions of the OpenGL calls anymore!

Easy changes to make and the MacOS build is still working. Same for the comments below.

sdk/modules/ui/cpp/src/base_window.cpp Outdated Show resolved Hide resolved
sdk/modules/ui/cpp/src/base_window.cpp Outdated Show resolved Hide resolved
…sequently, removing extraneous Apple and Linux preprocessor directives throughout the various metavision::sdk::ui implementation files.
@lbristiel-psee
Copy link
Collaborator

@coashby I let @jthierry-psee discuss the programming aspects of this PR with you. On my side, I plan to review your proposition around documentation and will see what/how to integrate them.

@coashby
Copy link
Contributor Author

coashby commented Jun 21, 2024

@coashby I let @jthierry-psee discuss the programming aspects of this PR with you. On my side, I plan to review your proposition around documentation and will see what/how to integrate them.

Ok, cool. Thank you! I appreciate your consideration and look forward to your feedback.

#else // OpenGL
#if defined(__APPLE__) && !defined(__linux__)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not very familiar with MacOS environments, are there cases where both __APPLE__ and __linux__ are defined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I came across this issue during development. This helps anyone that is doing containerized development work. It allows the intended code paths when doing local development of linux containers on Apple silicon.

#else // OpenGL
#if defined(__APPLE__) && !defined(__linux__)
#define GL_SILENCE_DEPRECATION
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not necessarily an action request, but do you remember what is the deprecated thing we are using?

#define GL_SILENCE_DEPRECATION
#include <OpenGL/gl3.h>
#else
#if defined(WIN32)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: #elif

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 believe I can change the logic here. I would end up having to write a separate case for linux and including #include <GL/glew.h> and #include <GL/gl.h> in both logic branches for WIN32 and linux.

I was able to collapse the first #else to and #elif.

@jthierry-psee
Copy link
Collaborator

@coashby Sorry for the delay on this review. Most of the changes on the code look ok. Just a few remarks/questions on the GL code.
Also, not convinced BUILD_TESTING should be redefined you our CMakeLists.txt

@coashby
Copy link
Contributor Author

coashby commented Jul 12, 2024

@jthierry-psee No worries. Thanks for the most recent review. I agree with your suggestions and I should be able to resolve them by monday of next week.

As far as the OpenGL deprecation note, I believe most of the issues are related to OSX. Apple has discontinued support for OpenGL in their Mojave 10.14 updated. This just ignores all the warnings that pop up in response.

@jthierry-psee
Copy link
Collaborator

@jthierry-psee No worries. Thanks for the most recent review. I agree with your suggestions and I should be able to resolve them by monday of next week.

Great, thanks. I'll be quicker for the next review/approval.

As far as the OpenGL deprecation note, I believe most of the issues are related to OSX. Apple has discontinued support for OpenGL in their Mojave 10.14 updated. This just ignores all the warnings that pop up in response.

Thanks for the info. If you can add just a small comment about this so we remember why it's here, it would be great.

coashby added 2 commits July 13, 2024 19:31
…E_DEPRECATION directive is used to supress warninngs on OSX platforms related to the deprecation of OpenGL on Apple silicon. On MacOS this began with update 10.14.
CMakeLists.txt Outdated
@@ -15,6 +15,9 @@ if(NOT CMAKE_BUILD_TYPE)
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif(NOT CMAKE_BUILD_TYPE)

option(COMPILE_PYTHON3_BINDINGS "Enable/Disable Python bindings. Python bindings are disabled by default." OFF)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hi @coashby, thanks for your contrib and feedbacks !

I agree that anything related to testing the framework should be disabled by default to ease user experience. Even though CMake enable BUILD_TESTING by default, we can enforce to disable it and make sure that gtest and pytest are not required.

Regarding pybind and the python bindinds, it's a different story has they are entirely part of the API and must be provided to our Python end-users. There are legitimate cases where one would want to disable, that's where COMPILE_PYTHON3_BINDINGS should be set to false.

CMakeLists.txt Outdated
@@ -15,6 +15,9 @@ if(NOT CMAKE_BUILD_TYPE)
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif(NOT CMAKE_BUILD_TYPE)

option(COMPILE_PYTHON3_BINDINGS "Enable/Disable Python bindings. Python bindings are disabled by default." OFF)
option(BUILD_TESTING "Enable/Disable test applications." OFF)
Copy link
Collaborator

Choose a reason for hiding this comment

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

@jthierry-psee If we want this, we'll need to ensure those are enable in our CI.

CMakeLists.txt Outdated
@@ -15,6 +15,9 @@ if(NOT CMAKE_BUILD_TYPE)
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif(NOT CMAKE_BUILD_TYPE)

option(COMPILE_PYTHON3_BINDINGS "Enable/Disable Python bindings. Python bindings are disabled by default." OFF)
option(BUILD_TESTING "Enable/Disable test applications." OFF)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
option(BUILD_TESTING "Enable/Disable test applications." OFF)
option(BUILD_TESTING "Build OpenEB's test suite" OFF)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you @ogeorget-psee for the clarifications.
@jthierry-psee , Yes I agree tremendously. I know changing the default behavior would have down steam affects, so I understand and appreciate that these decisions are not taken lightly.

I'll update the docs to include pybindings as part of the required build components.

I'll also work to resync this branch with main.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ogeorget-psee, @jthierry-psee, finished making those changes.
Obviously it'll take some time to review but always grateful for the feedback once you have time.

Cheers.

CMakeLists.txt Outdated Show resolved Hide resolved
coashby and others added 3 commits July 15, 2024 21:59
Updating option comment for BUILD_TESTING

Co-authored-by: Olivier Georget <116826255+ogeorget-psee@users.noreply.github.com>
…. Python binding are enabled by default to satisfy API requirements. The default ON behavior is defined for all NON-Android platforms. Documentation has also been updated to reflect this behavior.
@lbristiel-psee
Copy link
Collaborator

@coashby coming back to you about this PR, sorry for the delay.
Thanks again for the contribution!
Let's try to get as much possible merged into the repo.
The modifications/additions you have done on the README and docs folder are a bit complicated for us to merge for multiple reasons (we don't want to document the Mac install as we don't have the resources to test/maintain/support this platform, we are focussing on improving the Open Install in our SDK online doc rather than the README etc.).
So in order for us to merge this PR, could you remove the documentation part (README and "docs" folder)?
Thanks in advance

@coashby
Copy link
Contributor Author

coashby commented Aug 23, 2024

@coashby coming back to you about this PR, sorry for the delay. Thanks again for the contribution! Let's try to get as much possible merged into the repo. The modifications/additions you have done on the README and docs folder are a bit complicated for us to merge for multiple reasons (we don't want to document the Mac install as we don't have the resources to test/maintain/support this platform, we are focussing on improving the Open Install in our SDK online doc rather than the README etc.). So in order for us to merge this PR, could you remove the documentation part (README and "docs" folder)? Thanks in advance

Sure, I completely understand. I'll try and get that done today or over the weekend.

Regards

…see's end and documenting the process introduces added complexity for both maintainers and end-users.
@coashby
Copy link
Contributor Author

coashby commented Oct 1, 2024

Sorry for the long delay on my end as well. I forgot what happened that week, but clearly I did not get back to this as I planned (T_T).
I removed the docs folder and updated the readme to its original contents. LMK if everything appears good on your end!
Cheers

@jthierry-psee jthierry-psee merged commit b93c18f into prophesee-ai:main Oct 9, 2024
3 of 6 checks passed
@jthierry-psee
Copy link
Collaborator

@coashby finally merged it. Sorry it took a bit of time.
Thanks again for your contribution!

@coashby
Copy link
Contributor Author

coashby commented Oct 9, 2024

@coashby finally merged it. Sorry it took a bit of time. Thanks again for your contribution!

No worries. That's how it goes with community contributions sometimes. Grateful for the interactions and feedback.
The SDK has been helpful for my company so happy to give back what I can.

Cheers

@coashby coashby deleted the feature/openeb-updates branch October 9, 2024 16:45
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.

4 participants