Get_input_names_from_role 'NoneType' object has no attribute '__getitem__'

gblack686
Level 4
Get_input_names_from_role 'NoneType' object has no attribute '__getitem__'

In my plugin I'm trying to use a select parameter. I have a resource folder and select-columns.py file with a do() function as follows.

import dataiku
import logging
from dataiku.customrecipe import *

def do(payload, config, plugin_config, inputs):
  input_A_names = get_input_names_for_role('input_A_role')

  # Retrieve input dataset names and create list of dataset objects
  column_list = []

  for dataset in input_A_datasets:
    for x in dataset.cols:
      index = 0
      column_name = str(x['name'])
      column_list.append({'value':column_name,'label':column_name})
      # { "value": "scrambled", "label": "Scrambled"}
      choices = column_list

  return {"choices":choices}

 

However, in the settings (UI) of the plugin, I'm getting an error: 'NoneType' object has no attribute '__getitem__' .  The input roll is as follows:

"inputRoles": [
{
"name": "input_A_role",
"label": "input_A_role",
"description": "input_A_role",
"arity": "UNARY",
"required": true,
"acceptsDataset": true
}

 

I'm not sure what I could be missing. 

0 Kudos
2 Replies
Clément_Stenac
Dataiker

Hi,

It looks like you are missing the line:

input_A_datasets = [dataiku.Dataset(name) for name in input_A_names]

before your for loop

0 Kudos
gblack686
Level 4
Author

Hi Clement, 

I did accidentally remove that, however, the error is occurring on the line above. 

File "/mnt1/dataiku/dataiku-dss-6.0.3/python/dataiku/customrecipe/__init__.py",
line 14, in get_input_names_for_role

return [x[full and "fullName" or "smartName"] for x in flow_spec["in"] if x["role"] == role]
TypeError: 'NoneType' object has no attribute '__getitem__'

 Is my folder tree arranged correctly? See attached. 

0 Kudos