Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Added on May 6, 2021 5:31PM
Likes: 0
Replies: 9
Hi All.
Editing my question to help better understand.
In a custom recipe or custom macro
We have the option to define a parameter as mandatory "mandatory":true
Can someone please help check if this option works properly for them in their custom recipe/macro.
i.e. a value for the parameter must be supplied in order to use the recipe/macro.
I am trying to check for v 8.0.5 and above.
Thanks
Testing this "required": true works for inputRoles/outputRoles.
However, for params using mandatory or required has no effect within recipe component. You could handle this in recipe code directly when reading the parameters here is an example of how this is done from another Plugin recipe
text_column_name = recipe_config.get('text_column_name', None) if text_column_name is None: raise ValueError("You did not choose a text column.") n_sentences = recipe_config.get('n_sentences', None) if n_sentences is None: raise ValueError("You did not set a number of sentences.") method = recipe_config.get('method', None) if method is None: raise ValueError("You did not choose a summarization method.")
Let me know if this helps.
Edited..
The "mandatory" flag does not apply to macros and it will only be used with other plugin components. We have captured this use case and the desire to make certain macro params/fields mandatory and is under review by our product team.
Thanks @AlexT
One Request, Just to help me out can you please check if the Mandatory option is working properly in other plugin components like a Component Recipe?
I faced an issue where it didnt work even on a custom recipe on V9
Thanks @AlexT
With so many parameter examples and documents mentioning that option i somehow always assumed that it works.
We shall change all our codes to raise exceptions instead
I have the same question. The documentation says it can also be used for parameters. But I can still use a plugin recipe without supplying a field that is set to mandatory.
https://doc.dataiku.com/dss/latest/plugins/reference/params.html#describing-parameters
hi @jvijayakumar2
& @akshaykatre
If i remember correctly i think that the mandatory = True will just just show some indication in red if a parameter is mandatory and has not been defined. But it still allows the recipe to run even if a value has not been passed to a mandatory parameter.
I think the way it works now does make sense
as Alex suggested it is better to keep checks for mandatory fields in the recipes code so that you can have complex conditions if needed.
You are right that we can add checks for the mandatory field in the recipe code like @AlexT
has written.
But the documentation seems to say that the component can't be used without supplying the mandatory fields. Also, the red indication doesn't happen unless I enter a value in a mandatory field and remove it.