Multiple SELECT parameters using getChoicesFromPython ?

MGad
MGad Registered Posts: 14 ✭✭✭✭

Hi,

I'm currently writing the parameters in my recipe's JSON. I would like to add 2 SELECT choices, both created via python but with different methods. However, I only see one field (paramsPythonSetup) to insert my python script's name. If I try to implement 2 Do functions in it, both SELECT parameters display the choice list corresponding to the last Do function

So... How can I write 2 python codes to generate 2 choices lists in one parameters' JSON ?

Thx for your help

Best Answer

  • duphan
    duphan Dataiker, Registered Posts: 32 Dataiker
    Answer ✓

    Hi,

    You will only need 1 function do, and then inside it you do a check on the payload parameter to define which SELECT choice you are dealing with.

    Something like this:

    def do(payload, config, plugin_config, inputs):
    if payload.get('parameterName') == 'parameter2':
    choices = [
    { "value" : "val1", "label" : 'value of parameter2 -1'},
    { "value" : "val2", "label" : "Value of parameter 2 - 2"}
    ]
    return {"choices": choices}

    if payload.get('parameterName') == 'parameter3':
    choices = [
    { "value" : "val1", "label" : "Value of parameter 3 - 1"},
    { "value" : "val2", "label" : "Value of parameter 3 - 2"}
    ]
    return {"choices": choices}

Answers

Setup Info
    Tags
      Help me…