Discover this year's submissions to the Dataiku Frontrunner Awards and give kudos to your favorite use cases and success stories!READ MORE

Multi dataset input role for custom plugin in

Solved!
tNbre
Level 2
Multi dataset input role for custom plugin in

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

0 Kudos
1 Solution
ZachM
Dataiker
Dataiker

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:

image.png

 

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

View solution in original post

0 Kudos
2 Replies
ZachM
Dataiker
Dataiker

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:

image.png

 

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

0 Kudos
tNbre
Level 2
Author

@ZachMthanks it works perfectly!