The Dataiku Frontrunner Awards are now accepting submissions until July 15 to recognize your achievements! ENTER YOUR SUBMISSION

exception for mandatory parameters in plugins and macros

Solved!
NN
Level 4
exception for mandatory parameters in plugins and macros

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

0 Kudos
1 Solution
AlexT
Dataiker
Dataiker

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. 

View solution in original post

0 Kudos
5 Replies
NN
Level 4
Author

Edited..

0 Kudos
AlexT
Dataiker
Dataiker

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.

0 Kudos
NN
Level 4
Author

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

0 Kudos
AlexT
Dataiker
Dataiker

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. 

View solution in original post

0 Kudos
NN
Level 4
Author

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

0 Kudos
A banner prompting to get Dataiku DSS
Public