Failed: Failed to run function : : No DSS URL or API key found from any location

Options
ssuhas76
ssuhas76 Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Registered Posts: 31

Hi i am getting an error while doing the TESTING QUERIES on the API designer for python function endpoint.

Failed: Failed to run function : class 'Exception' : No DSS URL or API key found from any location

Best Answer

  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 1,708 Neuron
    Answer ✓
    Options

    You should use the Dataiku API package since you are going to call the Dataiku API from the API node and that's considered outside DSS:

    import dataikuapidataiku_url = 'https://dss_url/'dataiku_api_key = 'API key'external_client = dataikuapi.DSSClient(dataiku_url, dataiku_api_key)# Only needed if you are using SSL and need to ignore the SSL cert validation# external_client._session.verify = Falseproject_handle = external_client.get_project('your_project_key')project_variables = project_handle.get_variables()

    Also once you are outside DSS you need to set a project key first before you can retrieve the project variables since things don't run inside a project like recipes, jobs and scenarios do in DSS. Finally your incorrectly named method getcustom_variables() (the correct name is get_custom_variables()) is called get_variables() in the dataikuapi package.

Answers

  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 1,708 Neuron
    Options

    What does your Python function do? Is it trying to use the Dataiku API? Test with a simple function:

    def api_py_function(param1, param2, param3):return param1 + param2 * param3

    Screenshot 2023-09-22 at 08.32.00.png

  • ssuhas76
    ssuhas76 Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Registered Posts: 31
    Options

    My function is trying to read from a sharepoint link. It is using some global variables to conctsruct the URL and get the data. The same fucntion is working in a normal python recipe and a notebook within Dataiku flow. But it is not working in the API Designer testing queries

  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 1,708 Neuron
    Options

    A Python API function in the API node runs in a complete different context than Python recipes and Notebooks in the Designer or Automation node. I don't believe you have access to global variables nor plugins like Sharepoint from the API node. Having said that you could use the Dataiku external API to access Dataiku from the outside world:

    import dataikuapidataiku_url = 'https://dss_url/'dataiku_api_key = 'API key'client = dataikuapi.DSSClient(dataiku_url, dataiku_api_key)all_variables = client.get_global_variables()

    This however adds a level of depedency in the API node to the Designer/Automation node which might be undesirable since the API node can be deployed in HA mode but Designer/Automation nodes can't.

  • ssuhas76
    ssuhas76 Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Registered Posts: 31
    Options

    Hi , many thanks for your replies.

    what should i give the values for the below. I still have not deployed the API.

    dataiku_url = 'https://dss_url/'

    dataiku_api_key = 'API key

  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 1,708 Neuron
    Options

    Your Designer Node URL and your Designer Node API key that you should create in your Designer Node. Even though you haven't deployed the API it still runs in the context of the embedded API node that comes with the Designer node, which doesn't know anything about your Designer node.

  • ssuhas76
    ssuhas76 Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Registered Posts: 31
    Options

    We create the API key in the API Designer itself right? I did that and also the code you gave as well. Still not able to test the query.

    Failed: Failed to run function : class 'requests.exceptions.ConnectionError' : [Errno None] None: 'None'

  • ssuhas76
    ssuhas76 Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Registered Posts: 31
    Options

    one more question - The API key is a project level API key or Global level key?

  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 1,708 Neuron
    Options

    Please post your API function code.

  • ssuhas76
    ssuhas76 Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Registered Posts: 31
    Options

    This is my API code

    import dataiku
    from requests import Session
    import json
    import base64
    import os
    import pandas as pd

    variables = dataiku.getcustom_variables()

    def load_data(a,b):

    return a+b+variables['c']

  • ssuhas76
    ssuhas76 Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Registered Posts: 31
    Options

    What about the API key? Where is this set?

  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 1,708 Neuron
    Options

    Administration => Security => either Global or Personal API keys.

  • TH99
    TH99 Registered Posts: 4
    Options

    Hi @ssuhas76
    ,

    Got same error. Were u able to solve this?

Setup Info
    Tags
      Help me…