Ready for Dataiku 10? Try out the Crash Course on new features!GET STARTED

Plugin UI query

Solved!
rishabh1994
Level 1
Level 1
Plugin UI query

Hi folks,

I need to display the columns of one of the input datasets of my custom plugin , as a multiselect drop down list in the plugin UI.

Would appreciate any ideas.

Thanks!

0 Kudos
1 Solution
EliasH
Dataiker
Dataiker

 

 

Hi @rishabh1994 ,

I was able to accomplish displaying the columns from an input dataset by first creating a SELECT parameter (https://doc.dataiku.com/dss/latest/plugins/reference/params.html#multi-choice-parameters-and-presets) but instead of having a "selectChoices" field I used "getChoicesFromPython" and set that to true so that I could generate the list dynamically from my input dataset.

 

"paramsPythonSetup": "test.py"
"params": [
  {
    "type": "SELECT",
    "name": "Testing Column Names",
    "label": "Pick a Column"
    "getChoicesFromPython": true
  }
],

 

 
Following this part of the documentation (https://doc.dataiku.com/dss/latest/plugins/reference/params.html#dynamic-select-using-python)

I created a python file called "test.py" under the resource folder of the plugin (may have to create this folder manually if it is not there) and pointed to it by specifying "paramsPythonSetup" as I have done above.

Then in my "test.py" I have written the do() function like so

 

 

 

import dataiku

def do(payload, config, plugin_config, inputs):
    for i in inputs:
        if i['role'] == "input_dataset": #Must match what you've named the role to be
            input_dataset = i['fullName']

    dataset = dataiku.Dataset(input_dataset)
    schema = dataset.read_schema()
    schema_columns = [col['name'] for col in schema]
    
    choices = []
    for c in range(len(schema_columns)):
        choices.append({"value": schema_columns[c], "label": schema_columns[c]})
    return {"choices": choices}

 

 

View solution in original post

2 Replies
EliasH
Dataiker
Dataiker

 

 

Hi @rishabh1994 ,

I was able to accomplish displaying the columns from an input dataset by first creating a SELECT parameter (https://doc.dataiku.com/dss/latest/plugins/reference/params.html#multi-choice-parameters-and-presets) but instead of having a "selectChoices" field I used "getChoicesFromPython" and set that to true so that I could generate the list dynamically from my input dataset.

 

"paramsPythonSetup": "test.py"
"params": [
  {
    "type": "SELECT",
    "name": "Testing Column Names",
    "label": "Pick a Column"
    "getChoicesFromPython": true
  }
],

 

 
Following this part of the documentation (https://doc.dataiku.com/dss/latest/plugins/reference/params.html#dynamic-select-using-python)

I created a python file called "test.py" under the resource folder of the plugin (may have to create this folder manually if it is not there) and pointed to it by specifying "paramsPythonSetup" as I have done above.

Then in my "test.py" I have written the do() function like so

 

 

 

import dataiku

def do(payload, config, plugin_config, inputs):
    for i in inputs:
        if i['role'] == "input_dataset": #Must match what you've named the role to be
            input_dataset = i['fullName']

    dataset = dataiku.Dataset(input_dataset)
    schema = dataset.read_schema()
    schema_columns = [col['name'] for col in schema]
    
    choices = []
    for c in range(len(schema_columns)):
        choices.append({"value": schema_columns[c], "label": schema_columns[c]})
    return {"choices": choices}

 

 

View solution in original post

rishabh1994
Level 1
Level 1
Author

Thanks @EliasH , was really helpful..

I also wanted to know if there can be multiple dropdowns in the UI whose choices are coming from a python code, like the one mentioned above. For example , if in addition to the columns of one input dataset in one dropdown , we need to have the columns of the second input dataset in another.

And if that is possible how to uniquely specify the do() statements for each of them..

 

Thanks!

0 Kudos
A banner prompting to get Dataiku DSS