-
Notifications
You must be signed in to change notification settings - Fork 46
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
[Binding/Sofa.Config] Add Sofa.future & Sofa.Config #184
base: master
Are you sure you want to change the base?
[Binding/Sofa.Config] Add Sofa.future & Sofa.Config #184
Conversation
To control if users want to activate news features in the binding.
…tures. The mechanisme is composed of three parts: - SofaPython3::Config (the c++ part) - SofaPython3::Binding::Config (the python binding) Activating an existing futurefeature: ------------------------------------- ```python import SofaPython3.__futurefeatures__ SofaPython3.__futurefeatures__.object_auto_init = True # To activate the auto init feature. ``` Adding a new futurefeature: --------------------------- In binding/Sofa/package/__futurefeatures__.py, add you feature at the end of the FeatureSet::__init__ constructor. In your c++ code you can test if the feature is activated by doing ```c++ if( sofapython3::config::futurefeatures::get("myFeature") ) .... ``` In your python code you can test if the feature is activated by doing ```python import Sofa.__futurefeatures__ if Sofa.__futurefeatures__.myFeature: print("The feature is activated") ``` Signed-off-by: Damien Marchal <[email protected]>
@hugtalbot here is the feature. I think it should be used at least in PR #173 and few other. |
…ture # Conflicts: # bindings/Sofa/tests/PythonModule_Sofa_test.cpp
…time.future To make that consistant with the "lifetime" namespace we already have in Sofa.
@damienmarchal you are changing the name in the latest commit right? Could you explain ? |
Oops, I missread "lifecycle" in the sofa code base (which is not related to componentState). Future is the common name in python...but as we already have a namespace for feature management and software lifecylce management in Sofa I think it is better to stick to the sofa namespace. |
@hugtalbot I now rename everything so it match the sofa naming convention: lifecycle. I also renamed the contextmanager EDIT: The CI is failing because we need to merge PR ##206 |
Hi @damienmarchal
Thanks. |
Nice day, I Have questions about a pending PR Adding features in lifecycle::featuresQ: Why? What is considered a "new feature" and thus should be registered in lifecycle::features? What are the criteria?
Apart from that I would not recommand to use this kind of mecanism for integration of new feature that are neither breaking nor fragile. Removing features from lifecycle::featuresQ: How? Are all lifecycle::features meant to be used as normal features at some point? ## I really want the new behavior.
with Sofa.lifecycle.__new_feature__("auto_init"):
createPartOfSceneNewStyle(root)
createPartOfSceneWithOldStyle(root) When the feature is integrated, there is no need for the with statement. If the with new_feature is used we can now emit a warning explainging this is not needed anymore as the feature is now a properly supported one. createPartOfSceneNewStyle(root) Finally, if the scene want to continue using some parts with the old behavior we can explicitly fall back to the old behavior. createPartOfSceneNewStyle(root)
## I'm to lazy to update my scene but I need to make it work now !
with Sofa.lifecycle.__deprecated_feature__("no_auto_init"):
createPartOfSceneWithOldStyle(root) Thanks to this kind of lifecyle mecanism we then have a the infrastructure to handle a smooth transition and api evolution (which compared to the no-effort we have done for python2 to pyton3 is a big improvement). Q: Why? What are the agreed reasons for removing features? The expiration date (if any)? Something else? Q: When? How long does a feature stay registered in lifecycle::features? Is there an expiration date? Q: Who? Who is supposed to do that? Who is in charge of maintaining the lifecycle::features list? Q: Could we have a message telling the user he is using a "new_feature"? He might not know if he runs the scene of someone else. |
This sounds to me like the master branch isn't it ? I would not really agree on this criteria.
Agreed here, but it sounds rather like something experimental, since unsure to be finally merged in master. Don't you think? Regarding #173, the question is rather to me do we really want this feature in SP3? |
(From SOFA dev) During the SOFA dev meeting, the team agreed on setting up:
TODO: add the deprecated mechanism + make sure we must set up dates when adding a new/deprecated feature + add the experimental feature |
Implement a control mecanism to activate/de-activate feature of the SofaPython3 binding so we have more freedom
to experiment.
Example of use (taken from PR #173):
The mechanisme is composed of three parts:
To add a new feature:
In binding/Sofa/package/lifecycle.py, add you feature at the begnining as indicated
in the file.
Then in your c++ code you can then test if the feature is activated by doing
Or in your python code you can also test if the feature is activated by doing