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

--[BE] Fix issues with bindings exposed by pybind11-stubgen #2430

Merged
merged 16 commits into from
Jul 21, 2024

Conversation

jturner65
Copy link
Contributor

@jturner65 jturner65 commented Jul 17, 2024

Motivation and Context

This PR adds missing bindings and fixes broken ones as exposed by pybind11-stubgen which is being introduced in this PR

How Has This Been Tested

All local c++ and python tests pass

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have completed my CLA (see CONTRIBUTING)
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@jturner65 jturner65 requested a review from aclegg3 July 17, 2024 19:50
@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Jul 17, 2024
@jturner65 jturner65 requested a review from 0mdc July 17, 2024 19:50
Copy link
Contributor

@0mdc 0mdc left a comment

Choose a reason for hiding this comment

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

Nice clean-up! LGTM!

[](Configuration& self, const std::string& key, const T val) {
self.set(key, val);
},
("Set the value specified by given string key to be specified " +
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 sure if this actually works, as far as I remember the reason def() accepted a plain const char* was because it just referenced it without actually copying anywhere. So when retrieving documentation of those, you'll get a crash due to a dangling pointer.

I might be wrong, but I personally hope it's not doing a string copy for every docstring. That'd be nasty.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mosra The __init__.pyi has an appropriate doc string listed :

    @typing.overload
    def set(self, key: str, value: str) -> None:
        """
        Set the value specified by given string key to be specified string value
        """

Would the problem be somewhere else?

__init__.pyi also has duplicate entries for the const char* and const str& versions. I going to get rid of the const char* specializations.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, alright, then it works. I wasn't sure.

@jturner65 jturner65 force-pushed the Bindings_AddMissingBindings branch from 5cc0927 to 0423a45 Compare July 18, 2024 20:01
@jturner65 jturner65 force-pushed the Bindings_AddMissingBindings branch from 0423a45 to a86c933 Compare July 19, 2024 15:21
@jturner65
Copy link
Contributor Author

Current Main's stubgen errors :

(habitat) john@john-kraken:~/Facebook/habitat-sim$ pybind11-stubgen habitat_sim._ext.habitat_sim_bindings -o src_python
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.AbstractObjectAttributes.shader_type. : Invalid expression 'esp::metadata::attributes::ObjectInstanceShaderType'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.ArticulatedObjectAttributes.render_mode. : Invalid expression 'esp::metadata::attributes::ArticulatedObjectRenderMode'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.ArticulatedObjectAttributes.shader_type. : Invalid expression 'esp::metadata::attributes::ObjectInstanceShaderType'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.BaseLightLayoutAttributesManager.create_new_template : Invalid expression 'esp::metadata::attributes::LightLayoutAttributes'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.BaseLightLayoutAttributesManager.create_template : Invalid expression 'esp::metadata::attributes::LightLayoutAttributes'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.BaseLightLayoutAttributesManager.filter_filepaths : Invalid expression 'esp::metadata::attributes::LightLayoutAttributes'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.BaseLightLayoutAttributesManager.get_first_matching_template_by_handle : Invalid expression 'esp::metadata::attributes::LightLayoutAttributes'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.BaseLightLayoutAttributesManager.get_template_by_handle : Invalid expression 'esp::metadata::attributes::LightLayoutAttributes'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.BaseLightLayoutAttributesManager.get_template_by_id : Invalid expression 'esp::metadata::attributes::LightLayoutAttributes'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.BaseLightLayoutAttributesManager.get_templates_by_handle_substring : Invalid expression 'esp::metadata::attributes::LightLayoutAttributes'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.BaseLightLayoutAttributesManager.register_template : Invalid expression 'esp::metadata::attributes::LightLayoutAttributes'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.BaseLightLayoutAttributesManager.remove_all_templates : Invalid expression 'esp::metadata::attributes::LightLayoutAttributes'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.BaseLightLayoutAttributesManager.remove_template_by_handle : Invalid expression 'esp::metadata::attributes::LightLayoutAttributes'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.BaseLightLayoutAttributesManager.remove_template_by_id : Invalid expression 'esp::metadata::attributes::LightLayoutAttributes'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.BaseLightLayoutAttributesManager.remove_templates_by_str : Invalid expression 'esp::metadata::attributes::LightLayoutAttributes'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.BaseLightLayoutAttributesManager.save_template_to_filepath : Invalid expression 'esp::metadata::attributes::LightLayoutAttributes'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.BaseSemanticAttributesManager.create_new_template : Invalid expression 'esp::metadata::attributes::SemanticAttributes'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.BaseSemanticAttributesManager.create_template : Invalid expression 'esp::metadata::attributes::SemanticAttributes'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.BaseSemanticAttributesManager.filter_filepaths : Invalid expression 'esp::metadata::attributes::SemanticAttributes'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.BaseSemanticAttributesManager.get_first_matching_template_by_handle : Invalid expression 'esp::metadata::attributes::SemanticAttributes'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.BaseSemanticAttributesManager.get_template_by_handle : Invalid expression 'esp::metadata::attributes::SemanticAttributes'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.BaseSemanticAttributesManager.get_template_by_id : Invalid expression 'esp::metadata::attributes::SemanticAttributes'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.BaseSemanticAttributesManager.get_templates_by_handle_substring : Invalid expression 'esp::metadata::attributes::SemanticAttributes'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.BaseSemanticAttributesManager.register_template : Invalid expression 'esp::metadata::attributes::SemanticAttributes'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.BaseSemanticAttributesManager.remove_all_templates : Invalid expression 'esp::metadata::attributes::SemanticAttributes'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.BaseSemanticAttributesManager.remove_template_by_handle : Invalid expression 'esp::metadata::attributes::SemanticAttributes'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.BaseSemanticAttributesManager.remove_template_by_id : Invalid expression 'esp::metadata::attributes::SemanticAttributes'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.BaseSemanticAttributesManager.remove_templates_by_str : Invalid expression 'esp::metadata::attributes::SemanticAttributes'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.BaseSemanticAttributesManager.save_template_to_filepath : Invalid expression 'esp::metadata::attributes::SemanticAttributes'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.LightInfo.__init__ : Invalid expression '<LightPositionModel.Global: 1>'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.LightInstanceAttributes.spot_inner_cone_angle. : Invalid expression 'Magnum::Math::Rad<float>'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.LightInstanceAttributes.spot_inner_cone_angle. : Invalid expression 'Magnum::Math::Rad<float>'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.LightInstanceAttributes.spot_outer_cone_angle. : Invalid expression 'Magnum::Math::Rad<float>'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.LightInstanceAttributes.spot_outer_cone_angle. : Invalid expression 'Magnum::Math::Rad<float>'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.ManagedArticulatedObject.get_link : Invalid expression 'esp::physics::ArticulatedLink'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.MetadataMediator.__init__ : Invalid expression 'esp::sim::SimulatorConfiguration'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.MetadataMediator.ao_template_manager. : Invalid expression 'esp::metadata::managers::AOAttributesManager'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.MetadataMediator.asset_template_manager. : Invalid expression 'esp::metadata::managers::AssetAttributesManager'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.MetadataMediator.lighting_template_manager. : Invalid expression 'esp::metadata::managers::LightLayoutAttributesManager'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.MetadataMediator.object_template_manager. : Invalid expression 'esp::metadata::managers::ObjectAttributesManager'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.MetadataMediator.physics_template_manager. : Invalid expression 'esp::metadata::managers::PhysicsAttributesManager'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.MetadataMediator.stage_template_manager. : Invalid expression 'esp::metadata::managers::StageAttributesManager'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.PathFinder.get_topdown_island_view : Can't find/import 'm'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.PathFinder.get_topdown_island_view : Can't find/import 'n'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.PathFinder.get_topdown_view : Can't find/import 'm'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.PathFinder.get_topdown_view : Can't find/import 'n'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.RedwoodNoiseModelGPUImpl.__init__ : Can't find/import 'm'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.RedwoodNoiseModelGPUImpl.__init__ : Can't find/import 'n'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.RedwoodNoiseModelGPUImpl.simulate_from_cpu : Can't find/import 'm'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.RedwoodNoiseModelGPUImpl.simulate_from_cpu : Can't find/import 'n'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.Renderer.bind_render_target : Invalid expression 'esp::sensor::VisualSensor'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.Renderer.bind_render_target : Invalid expression '<Flags.NONE: 0>'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.Renderer.draw : Invalid expression '<Flags.FRUSTUM_CULLING: 1>'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.Renderer.draw : Invalid expression 'esp::sensor::VisualSensor'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.Renderer.draw : Invalid expression 'esp::sim::Simulator'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.Renderer.enqueue_async_draw_job : Invalid expression 'esp::sensor::VisualSensor'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.Renderer.enqueue_async_draw_job : Invalid expression '<Flags.FRUSTUM_CULLING: 1>'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.ReplayRenderer.cuda_color_buffer_device_pointer : Can't find/import 'capsule'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.ReplayRenderer.cuda_depth_buffer_device_pointer : Can't find/import 'capsule'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.SceneNode.node_sensor_suite. : Invalid expression 'esp::sensor::SensorSuite'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.SceneNode.node_sensors. : Invalid expression 'esp::sensor::Sensor'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.SceneNode.subtree_sensor_suite. : Invalid expression 'esp::sensor::SensorSuite'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.SceneNode.subtree_sensors. : Invalid expression 'esp::sensor::Sensor'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.Sensor.get_observation : Invalid expression 'esp::sim::Simulator'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.SensorFactory.create_sensors : Invalid expression 'esp::sensor::Sensor'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.SensorFactory.delete_sensor : Invalid expression 'esp::sensor::Sensor'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.SensorSuite.add : Invalid expression 'esp::sensor::Sensor'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.SensorSuite.get : Invalid expression 'esp::sensor::Sensor'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.SensorSuite.get_sensors : Invalid expression 'esp::sensor::Sensor'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.SensorSuite.node. : Invalid expression 'esp::sensor::Sensor'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.SensorSuite.object. : Invalid expression 'esp::sensor::Sensor'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.SensorSuite.remove : Invalid expression 'esp::sensor::Sensor'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.Simulator.build_semantic_CC_objects : Invalid expression 'esp::scene::CCSemanticObject'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.Simulator.semantic_color_map. : Invalid expression 'Magnum::Math::Vector3<unsigned char>'
pybind11_stubgen - [WARNING] Enum-like str representations were found with no matching mapping to the enum class location.

The PR in its current state's errors :

(habitat) john@john-kraken:~/Facebook/habitat-sim$ pybind11-stubgen habitat_sim._ext.habitat_sim_bindings -o src_python
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.PathFinder.get_topdown_island_view : Can't find/import 'm'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.PathFinder.get_topdown_island_view : Can't find/import 'n'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.PathFinder.get_topdown_view : Can't find/import 'm'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.PathFinder.get_topdown_view : Can't find/import 'n'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.RedwoodNoiseModelGPUImpl.__init__ : Can't find/import 'm'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.RedwoodNoiseModelGPUImpl.__init__ : Can't find/import 'n'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.RedwoodNoiseModelGPUImpl.simulate_from_cpu : Can't find/import 'm'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.RedwoodNoiseModelGPUImpl.simulate_from_cpu : Can't find/import 'n'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.Renderer.bind_render_target : Invalid expression '<Flags.NONE: 0>'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.Renderer.draw : Invalid expression '<Flags.FRUSTUM_CULLING: 1>'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.Renderer.enqueue_async_draw_job : Invalid expression '<Flags.FRUSTUM_CULLING: 1>'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.ReplayRenderer.cuda_color_buffer_device_pointer : Can't find/import 'capsule'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.ReplayRenderer.cuda_depth_buffer_device_pointer : Can't find/import 'capsule'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.Sensor.get_observation : Invalid expression 'esp::sim::Simulator'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.Simulator.build_semantic_CC_objects : Invalid expression 'esp::scene::CCSemanticObject'
pybind11_stubgen - [  ERROR] In habitat_sim._ext.habitat_sim_bindings.Simulator.semantic_color_map. : Invalid expression 'Magnum::Math::Vector3<unsigned char>'
pybind11_stubgen - [WARNING] Enum-like str representations were found with no matching mapping to the enum class location.

@jturner65 jturner65 changed the title --[WIP][BE] Fix issues with bindings exposed by pybind11-stubgen --[BE] Fix issues with bindings exposed by pybind11-stubgen Jul 19, 2024
Copy link
Contributor

@0mdc 0mdc left a comment

Choose a reason for hiding this comment

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

Did another pass on the latest changes. LGTM! Thanks for doing this.

.value("LINK_VISUALS",
metadata::attributes::ArticulatedObjectRenderMode::LinkVisuals,
"Render the Articulated Object using urdf-defined "
"meshes/primitives to respresent each link.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: respresent

R"(Whether or not the asset described by this attributes supports texture-based semantics)")
.def_property_readonly(
"num_regions", &SemanticAttributes::getNumRegionInstances,
R"(The nmumber of semantic regions defined by this Semantic Attributes.)");
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: nmumber

* configuration is created on LightLayoutAttributes construction.
*/
std::shared_ptr<Configuration> lightInstConfig_{};

/**
* @brief Deque holding all released IDs to consume for light instances when
* @brief Deque holding all released IDs to consume for @ref LightInstanceAttributess when
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: LightInstanceAttributess

[semanticAttribs](bool has_semantic_textures) {
semanticAttribs->setHasSemanticTextures(has_semantic_textures);
});

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

// "'s articulated link specified by the passed "
// "link_id. Use link_id==-1 to get the base link.")
// .c_str(),
// "link_id"_a)
Copy link
Contributor

Choose a reason for hiding this comment

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

Unrelated: Is this planned?

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, @aclegg3 and I have been discussing a mechanism for this.

@jturner65 jturner65 merged commit 9d1fba2 into main Jul 21, 2024
9 of 10 checks passed
@jturner65 jturner65 deleted the Bindings_AddMissingBindings branch July 21, 2024 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants