Skip to content

C++ plugin registration - #331

Merged
Luthaf merged 2 commits into
metatomic-corefrom
rmeli-cxx-plugin
Sep 22, 2026
Merged

Luthaf merged 2 commits into
metatomic-corefrom
rmeli-cxx-plugin

Conversation

@RMeli

@RMeli RMeli commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

Implement C++ plugin registration with the MTA_REGISTER_CXX_PLUGIN macro.

The code in 1de850a was suggested by Kimi-2.7-Code during a code review and implemented using Opus 5, so that a throwing C++ plugin's exception now reaches the caller with its original type (something I originally overlooked).

📚 Download documentation for this pull-request

⚙️ Download Python wheels for this pull-request (you can install these with pip)

@RMeli
RMeli requested a review from Luthaf September 15, 2026 15:29
@Luthaf

Luthaf commented Sep 15, 2026

Copy link
Copy Markdown
Member

The code in 1de850a was suggested by Kimi-2.7-Code during a code review and implemented using Opus 5, so that a throwing C++ plugin's exception now reaches the caller with its original type (something I originally overlooked).

I don't think we need a custom status code for this, it works without one in the C++ API of metatensor. (but this could also be thanks to the different treatment of CallbackError in here vs metatensor, I'll triple check).

@EricBoittier EricBoittier left a comment

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.

LGTM

We want to re-throw exceptions we saved at the C <=> C++ boundary
@Luthaf

Luthaf commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

I did a bit of refactoring here while splitting the changes into two separate commits, mainly making extra parameters std::optional in load_model; and re-using the C macro for plugins inside the C++ one, to make sure we don't have to maintain both places.

Let me know if the changes are good for you, then we can merge!

@RMeli

RMeli commented Sep 22, 2026

Copy link
Copy Markdown
Member Author

I can't self-approve, but your changes LGTM, thanks!

@Luthaf
Luthaf merged commit 3856716 into metatomic-core Sep 22, 2026
78 checks passed
@Luthaf
Luthaf deleted the rmeli-cxx-plugin branch September 22, 2026 13:49
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.

3 participants