recipe.get_inputs() gets TypeError: 'NoneType' object is not subscriptable

Options
RYoung
RYoung Registered Posts: 2
edited July 16 in Using Dataiku

import dataiku
from dataiku import recipe

# simply copy the first recipe input dataset
# to the first recipe output dataset, with the schema

ds_input = recipe.get_inputs()[0]
df_input = ds_input.get_dataframe()

when run in jupiter notebook I get the following error

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-7-53db26cb82aa> in <module>
      7 # to the first recipe output dataset, with the schema
      8 
----> 9 ds_input = recipe.get_inputs()[0]
     10 df_input = ds_input.get_dataframe()
     11 

/opt/dataiku/python/dataiku/recipe/__init__.py in get_inputs(index, role, object_type, as_type)
     69 def get_inputs(index=None, role=None, object_type=None, as_type='object'):
     70     flow_spec = flow.FLOW
---> 71     return [_get_typed_recipe_input_output(x, as_type) for x in flow_spec["in"] if _recipe_input_output_matches(x, index, role, object_type)]
     72 
     73 def get_input(index=None, role=None, object_type=None, as_type='object'):

TypeError: 'NoneType' object is not subscriptable

Answers

  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 1,716 Neuron
    edited 4:20PM
    Options

    In a Notebook you first need to establish proper context and point to the project/recipe you want to look at:

    import dataiku
    client_handle = dataiku.api_client()
    project_handle = client_handle.get_project('some_project_key')
    recipe_handle = project_handle.get_recipe('some_recipe_id')
    recipe_settings = recipe_handle.get_settings()
    recipe_settings.get_recipe_inputs()

  • RYoung
    RYoung Registered Posts: 2
    edited 4:20PM
    Options

    Hi Turribeach,

    tested your code and got.

    NameError: name 'recipe_settings' is not defined
  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 1,716 Neuron
    Options

    My bad, I missed a line of code. Updated the code above now.

Setup Info
    Tags
      Help me…