Skip to content

[Draft] better handling of shamrock python submodules with pybind11 (instense c++ sorcery)#1806

Draft
tdavidcl wants to merge 10 commits into
Shamrock-code:mainfrom
tdavidcl:better_py_submodule
Draft

[Draft] better handling of shamrock python submodules with pybind11 (instense c++ sorcery)#1806
tdavidcl wants to merge 10 commits into
Shamrock-code:mainfrom
tdavidcl:better_py_submodule

Conversation

@tdavidcl
Copy link
Copy Markdown
Member

No description provided.

tdavidcl added 6 commits May 13, 2026 10:49
Add epstein_stopping_time and epstein_supersonic_correction functions
to shamphys, implementing the Epstein drag stopping time formula with
a supersonic correction factor from Kwok 1975.

Assisted-by: claude-code
@github-actions
Copy link
Copy Markdown
Contributor

Thanks @tdavidcl for opening this PR!

You can do multiple things directly here:
1 - Comment pre-commit.ci run to run pre-commit checks.
2 - Comment pre-commit.ci autofix to apply fixes.
3 - Add label autofix.ci to fix authorship & pre-commit for every commit made.
4 - Add label light-ci to only trigger a reduced & faster version of the CI (need the full one before merge).
5 - Add label trigger-ci to create an empty commit to trigger the CI.

Once the workflow completes a message will appear displaying informations related to the run.

Also the PR gets automatically reviewed by gemini, you can:
1 - Comment /gemini review to trigger a review
2 - Comment /gemini summary for a summary
3 - Tag it using @gemini-code-assist either in the PR or in review comments on files

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new submodule registry system and macros for pybind11 module registration, along with a call_lambda utility for static initialization. It also implements Epstein drag physics for spherical dust grains and exposes these calculations to the Python API. Review feedback highlights the need for missing standard library includes in the registry header to ensure it is self-contained, a correction to a file documentation tag, and the removal of redundant or commented-out code in the physics bindings.

Comment on lines 27 to +29
#include <pybind11/pybind11.h>
#include <map>
#include <optional>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The header is missing several standard library includes required by the registry_t template and the build_all_modules function. Specifically, it needs , <string_view>, , , , , and to be self-contained and avoid compilation errors in different translation units.

Suggested change
#include <pybind11/pybind11.h>
#include <map>
#include <optional>
#include <pybind11/pybind11.h>
#include <algorithm>
#include <functional>
#include <map>
#include <memory>
#include <optional>
#include <stdexcept>
#include <string>
#include <string_view>
#include <vector>

#pragma once

/**
* @file print.hpp
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The @file documentation tag is incorrect. It should refer to call_lambda.hpp instead of print.hpp.

Suggested change
* @file print.hpp
* @file call_lambda.hpp

Comment thread src/shampylib/src/pyShamphys.cpp Outdated
.def_submodule("phys", "Physics Library");
}

Register_pybind() {}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

This empty Register_pybind() call is redundant and should be removed to keep the code clean.

Comment thread src/shampylib/src/pyShamphys.cpp Outdated
py::module &shamphys_module = shambindings::submodules::modules().get("shamrock.phys");

py::module shamphys_module = m.def_submodule("phys", "Physics Library");
// py::module shamphys_module = m.def_submodule("phys", "Physics Library");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Remove this commented-out line to maintain code cleanliness. The new registration system replaces this manual submodule definition.

@github-actions
Copy link
Copy Markdown
Contributor

Workflow report

workflow report corresponding to commit 8ba7eea
Commiter email is timothee.davidcleris@proton.me

Light CI is enabled. This will only run the basic tests and not the full tests.
Merging a PR require the job "on PR / all" to pass which is disabled in this case.

Pre-commit check report

Some failures were detected in base source checks checks.
Check the On PR / Linting / Base source checks (pull_request) job in the tests for more detailed output

Suggested changes

Detailed changes :
diff --git a/src/shambindings/include/shambindings/pybindaliases.hpp b/src/shambindings/include/shambindings/pybindaliases.hpp
index 29e24d89..c1147c41 100644
--- a/src/shambindings/include/shambindings/pybindaliases.hpp
+++ b/src/shambindings/include/shambindings/pybindaliases.hpp
@@ -199,7 +199,6 @@ void register_pybind_init_func(fct_sig);
     _internal_register_pybind_init(                                                                \
         __shamrock_unique_name(pybind_), __shamrock_unique_name(pybind_class_obj_), root_module)
 
-
 #define Register_pymodsubmodule_int(path, funcname, lambda_name)                                   \
     py::module funcname();                                                                         \
     shambase::call_lambda lambda_name([]() {                                                       \

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant