Unable to return project config

ben_p
ben_p Neuron 2020, Registered, Neuron 2021, Neuron 2022, Dataiku Frontrunner Awards 2021 Participant Posts: 143 ✭✭✭✭✭✭✭

Hi all,

I am writing a plugin which requires some user input, I am assigning the value of the input to a variable in my python code, like so:

key = get_recipe_config()['key']

However, when I run my recipe I get the error:

Job failed: Error in Python process: At line 23: <class 'KeyError'>: key

Line 23 the line I have shared above.

Here is the code from my plugins .json file where I define the key:

"params": [
            {
         "type": "SELECT",
         "name": "key",
         "label": "Authentication key",
         "description": "Select the required service authentication key.",
         "selectChoices": [
           { "value": "design/abd38200717c.json", "label": "design_717c"},
           { "value": "design/b3d42a4b33e5.json", "label": "design_33e5"},
           { "value": "automation/abd38200717c.json", "label": "automation_717c"},
           { "value": "automation/b3d42a4b33e5.json", "label": "automation_33e5"}                 
         ]
    },

I have used this approach previously without any issues, and I believe my code is correct - what am I missing that is causing "key" not to be found?

Ben

Best Answer

  • ben_p
    ben_p Neuron 2020, Registered, Neuron 2021, Neuron 2022, Dataiku Frontrunner Awards 2021 Participant Posts: 143 ✭✭✭✭✭✭✭
    Answer ✓

    You are quite right @Ignacio_Toledo
    - thankfully that was just a typo

    I eventually worked out what I was doing wrong here, I hadn't set a default value for the 'key' parameter - so it was in fact empty - duh!

    Ben

Answers

  • Ignacio_Toledo
    Ignacio_Toledo Dataiku DSS Core Designer, Dataiku DSS Core Concepts, Neuron 2020, Neuron, Registered, Dataiku Frontrunner Awards 2021 Finalist, Neuron 2021, Neuron 2022, Frontrunner 2022 Finalist, Frontrunner 2022 Winner, Dataiku Frontrunner Awards 2021 Participant, Frontrunner 2022 Participant, Neuron 2023 Posts: 415 Neuron

    Hi @ben_p
    .

    I might be completely lost here, but shouldn't the code be in the recipe.json file instead of the plugin.json one?

    Just a thought on what might be just a typo.

  • Ignacio_Toledo
    Ignacio_Toledo Dataiku DSS Core Designer, Dataiku DSS Core Concepts, Neuron 2020, Neuron, Registered, Dataiku Frontrunner Awards 2021 Finalist, Neuron 2021, Neuron 2022, Frontrunner 2022 Finalist, Frontrunner 2022 Winner, Dataiku Frontrunner Awards 2021 Participant, Frontrunner 2022 Participant, Neuron 2023 Posts: 415 Neuron

    I thought about that too. On one hand I thought "most probably it was not pasted". On the other, if it was that obvious I thought @ben_p
    would solve by himself after some sleep! I've fight against gigantic bugs for hours, than would be shown to be just small typos when waking up the next day...

  • ben_p
    ben_p Neuron 2020, Registered, Neuron 2021, Neuron 2022, Dataiku Frontrunner Awards 2021 Participant Posts: 143 ✭✭✭✭✭✭✭

    Haha glad to hear it is not just me that goes through this

Setup Info
    Tags
      Help me…