-
Notifications
You must be signed in to change notification settings - Fork 253
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 stubs for rosbag2_py (#1459) #1569
Add Python stubs for rosbag2_py (#1459) #1569
Conversation
@MichaelOrlov this is initial PR not for review yet. .pyi files are autogenerated by pybind11-stubgen manually and I just merged generated files to git. I see two options:
|
This will only work if there is an Ubuntu .deb and RHEL .rpm package that contains stubgen. Without that, there is no way we could actually release this on the buildfarm. |
8d1278f
to
d0cdcba
Compare
@clalancette unfortunately there is no pybind11-stubgen in Ubuntu or RHEL repos. After reading pybind/pybind11#2350 , seems like For now I pushed manually generated files from mypy's stubgen. |
@christophebedard Your help will be appreciated with figuring out if can create a script for github actions to autogenerate |
Having CI generate files and commit them is possible, but probably annoying. The simpler solution (and the one I would recommend) is to set up CI to generate the files and then do |
1cc9234
to
b8f65f4
Compare
@christophebedard thanks, I added following to - name: Is regeneration of Python stubs required?
run: |
sudo apt update && sudo apt -y install mypy=0.942-1ubuntu1
source install/setup.sh
stubgen -p rosbag2_py -o src/ros2/rosbag2/rosbag2_py/rosbag2_py/stubs
git --git-dir src/ros2/rosbag2/.git --work-tree src/ros2/rosbag2 diff --exit-code
working-directory: ${{ steps.action-ros-ci.outputs.ros-workspace-directory-name }}
shell: bash However, it fails because seems |
c183602
to
6eaba9a
Compare
@MichaelOrlov @christophebedard could you please take a look? |
The CI code looks good to me. You could try to make a small manual change to one of the stubs files and push it to validate that the CI job catches it and fails, but that might be overkill given that it did "properly" fail before due to a different mypy version. |
@r7vme BTW. I've checked how hints work in CLion without This is one more point to start using CLion 😉
|
@r7vme @christophebedard I came across this discussion pybind/pybind11#2350 |
cool, seems it is worth the price.
I also saw this script. The problem that setup.py generated automatically by ament and I did not find an easy way to call build_pyi.py during that process. Also I was not able to find a way to call stubgen (mypy) before installing the module (i.e. module have to be installed to in order stubgen to work). |
7d5d48b
to
3b0a5f4
Compare
Validated. CI will fail if there are changes in pyi files (link) |
@MichaelOrlov ready for another look |
3b0a5f4
to
191c9b2
Compare
@r7vme As regards:
Sorry, I can't help here either. Maybe @christophebedard or @emersonknapp will have some ideas. |
Signed-off-by: Roman Sokolkov <[email protected]>
191c9b2
to
146f9cc
Compare
@MichaelOrlov There is one problem. stubgen works with compiled python module (i.e. requires |
I found a good idea on how to solve this problem here https://stackoverflow.com/questions/65876895/how-to-structure-and-distribute-pybind11-extension-with-stubs In this case, we can declare @r7vme What do you think about this idea? |
@MichaelOrlov I see one main issue, users have to install rosbag2_py-stubs manually. I suspect that average user won't get benefits in that case. |
Well, if it will be a separate package and The only case when need to manually rebuild and install In cases when need to build rosbag2 from sources we recommend to use a meta package rosbag2 for the build command to make sure that everything belonging to the rosbag2 will be built. i.e. run command |
@MichaelOrlov I agree that having fully-automated solution is better. However, before investing time into doing this in a separate package, I want to point out:
I personally prefer to keep current semi-automated solution, if smth won't work we can always invest more time and automate it fully. Also to fully satisfy original issue #1459, we have to make another PR that improves pybind type information (example #1459 (comment)) |
Signed-off-by: Roman Sokolkov <[email protected]>
Signed-off-by: Roman Sokolkov <[email protected]>
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.
@r7vme Tnanks for fixes during the review. LGTM!
Gist: https://gist.githubusercontent.com/MichaelOrlov/1de9b06fce7ec3ae4981f6bb56c1cad9/raw/dc192ddb97855f6ce0b3f43e057d61e94de66041/ros2.repos |
This pull request has been mentioned on ROS Discourse. There might be relevant details there: https://discourse.ros.org/t/ros-2-tsc-meeting-minutes-for-2024-03-21/36814/1 |
Fixes #1459 (related PR #1463)