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

Variants: allow registering callbacks for variant changes #1367

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

merlinND
Copy link
Member

Description

As discussed with @njroussel.

Currently, upon each variant change, we explicitly reload the custom Python integrators shipped in mitsuba.python.ad.integrators.
Users don't have access to such a mechanism.

By allowing users to register callbacks, they can now implement module loading & reloading for their custom Python plugins.
In the future, there may be a higher-level way for users to register plugins that will automatically create such a reload callback.

I also added an alias scoped_set_variant to variant_context so that it matches dr.scoped_set_flag().

Testing

Added a unit test check.

Checklist

  • My code follows the style guidelines of this project
  • My changes generate no new warnings
  • My code also compiles for cuda_* and llvm_* variants. If you can't test this, please leave below
  • I have commented my code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I cleaned the commit history and removed any "Merge" commits
  • I give permission that the Mitsuba 3 project may redistribute my contributions under the terms of its license

@@ -178,17 +210,24 @@ NB_MODULE(mitsuba_alias, m) {
/// Only used for variant-specific attributes e.g. mi.scalar_rgb.T
m.def("__getattr__", [](nb::handle key) { return get_attr(key); });

// `mitsuba.detail` submodule
nb::module_ mi_detail = m.def_submodule("detail");
Copy link
Member Author

Choose a reason for hiding this comment

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

@wjakob At first I tried to nb::module_::import_("mitsuba.detail"); but there was no such module, please let me know if this is not the proper way.

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.

1 participant