Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
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.
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
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
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.
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
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.
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'
one more question - The API key is a project level API key or Global level key?
Please post your API function code.
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']
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.
What about the API key? Where is this set?
Administration => Security => either Global or Personal API keys.