Multi dataset input role for custom plugin in
![tNbre](https://us.v-cdn.net/6038231/uploads/Dataiku/nAvatar21.png)
Hello,
i'm currently writting a plugin based on a python recipe. The plugin aims is to calculate quantiles for each columns of the input dataset.
Is there a way to have a dynamic number of input ? I'm trying to avoid to replicate the use of the pluggin but i can't be sure about the number of dataset to take in account. My plugin works when i'm setting myself the number of input role but i would love to be flexible.
Today it can be 2 input tomorrow it can be 10. I'm trying to replicate the Add button of dataiku's existing recipe.
Regards,
Operating system used: linux
Best Answer
-
Hi @tNbre
,You can do this by setting the arity of the dataset input role to NARY. This will allow you to set any number of datasets as the input.
Here's an example input role in recipe.json:
"inputRoles": [ { "name": "input_datasets", "label": "input datasets", "description": "Select multiple input datasets", "arity": "NARY", "required": true, "acceptsDataset": true } ],
Here's a screenshot of what it looks like:
You can access the datasets within your plugin code as follows:
import dataiku from dataiku.customrecipe import * input_dataset_names = get_input_names_for_role('input_datasets') for dataset_name in input_dataset_names: dataset = dataiku.Dataset(dataset_name) # Do stuff with each dataset here print('Dataset:', dataset.name)
Thanks,
Zach
Answers
-
@ZachM
thanks it works perfectly!