Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
[Processing] Optional parameters for script and model #2396
In processing core every parameters can be optional but in scripts there is no way to define a parameter as optional and in modeler only layers can be optional.
For script, I propose a notation like output, if a parameter token starts with optional the parameter is optional.
For model, I propose to add the required combobox to all parameters.
This proposition does not change the value setter.
This proposition can fix the issue http://hub.qgis.org/issues/5488.
The PR looks fine, it wont break anything and it will allow script to have optional layers. That is good.
However, the rest of the changes are rather useless. With this change, you can define an optional parameter of type number or string (by makin param.optional = True)...but that will have no effect. The optional variable is only checked for layers, and Processing wont let you add that script in a model if there is not a value for that parameter, because it now ignores the optional property
So, in shor, this loks good, but the core of Processing will require more changes to make this effective.
I would suggest merging the changes for the scripts, but don't add the "required" combo box for models parameters until all those other changes have been implemented
I will be happy to help on that if needed
Let me know you opinion
H @volaya, thanks for your review.
I'd like to update the core of Processing to have optional in models. Which changes do you think I have to do ?
I have noticed that if parameter value is set to None and the parameter is optional, the value will be:
I have time to make some changes, just let me know what I have to do.
ACtually, I am seeing that most parameters have an optional parameter, so should be easy to do this
Basically, you have to make sure that the setValue method of all parameters accepts a None value and does not complain in case they are optional (but returns False if the parameter is not optional)
see for instance here
Let me know if you have questions (here or by email)