Survey banner
Share your feedback on the Dataiku documentation with this 5 min survey. Thanks! TAKE THE SURVEY

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

Solved!
ssuhas76
Level 3
Failed: Failed to run function : <class 'Exception'> : No DSS URL or API key found from any location

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

0 Kudos
1 Solution

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 dataikuapi

dataiku_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 = False

project_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.

 

View solution in original post

0 Kudos
12 Replies
Turribeach

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

 

0 Kudos
ssuhas76
Level 3
Author

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

0 Kudos

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 dataikuapi

dataiku_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.

 

 

0 Kudos
ssuhas76
Level 3
Author

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

0 Kudos

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.

0 Kudos
ssuhas76
Level 3
Author

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'

0 Kudos
ssuhas76
Level 3
Author

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

0 Kudos

Please post your API function code.

0 Kudos
ssuhas76
Level 3
Author

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']

 

0 Kudos

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 dataikuapi

dataiku_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 = False

project_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.

 

0 Kudos
ssuhas76
Level 3
Author

What about the API key? Where is this set?

0 Kudos

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

0 Kudos

Labels

?
Labels (1)
A banner prompting to get Dataiku