[Contributor Guide - Plugin] which code should I contribute?

Dear Dr. Van Mele, Gonzalo,

I have a question about the PLUGIN development.

Taking the following document as an example compas/src/compas/geometry/trimesh/curvature.py, which option is more appropriate to contribute?

A. Kill the NotImplementedError, complete the code under the pluggable decorator.
B. Contribute to compas_cgal instead
C. A&B are both ok

For your convenience, your latest commit on this is here [commit].

Thanks!

Xingxin

Dear Xingxin

Great that you’re contributing code!

One small clarification: the NotImplemented errors are actually correct, they mean that the “core” of the library leaves that implementation open to other plugins, hence, that should not be killed.
Other plugins can add implementations for those @pluggable methods simply adding the @plugin decorator to them (as is the case of compas_cgal).

There can be multiple implementations of the same @pluggable methods, the boolean operations are one such case, in which both compas_rhino and compas_cgal implement them, each using their respective tooling (Rhino SDK and CGAL respectively), and as a user, you just need to call the pluggable and compas will automatically select the one that fits best based on the environment you are running: if you are inside Rhino, then it will use compas_rhino implementation, because CGAL doesn’t run in there, and if you are in a CPython environment, it will use compas_cgal (with the obvious prerequisite that it is installed).

If more implementations of the same thing are available for any given environment, the implementations can hint at whether they should be defaults or not using attributes on the decorator, but it is entirely up to compas to pick one.

In the future, there will be a way for a user to also actively select an implementation in these cases.

Cheers
Gonzalo

1 Like

Hi Gonzalo,

thanks for the prompt reply and clarification! This is a very meaningful architecture I think.

So… taking the curvature as an example, what I can contribute is to
A. contribute to compas_cgal, write code to generate CGAL binding
B. contribute to compas_rhino, write code using Rhino_SDK

Correct me if I understand wrong.:sweat_smile:

Best,

Xingxin

Yes, perfect! Sounds like a plan!!