Failed to run function : : Dataset (name) is specified with a relative name
Hello,
I'm working on a python function endpoint, and I need to call one of the datasets from the flow in the function.
however, when I try to run the test queries I get the following error:
Failed to run function : <class 'Exception'> : Dataset names is specified with a relative name, but no default project was found. Please use complete name
the code:
def api_py_function(features): code = get_city_code(features["name"]) return code def get_city_code(name: str): dataset = dataiku.Dataset("names") df = dataset.get_dataframe()
Operating system used: Windows 11
Best Answers
-
Hi,
It seems that your endpoint is running outside the context of a project. Then you should use:
project = client.get_project(<PROJECT_KEY>) dataset = project.get_dataset(<NAME>)
Best
-
Hey @rawan_mohammed
,Seems like you are accessing the dataset from outside DSS scope so in order to create the client object you would need to specifically point to the project.
import dataikuapi host = "http://localhost:11200" apiKey = "some_key" client = dataikuapi.DSSClient(host, apiKey) client._session.verify = False
project = client.get_project('project_name')You can refer to the official doc for more details - https://doc.dataiku.com/dss/latest/python-api/client.html?highlight=dssclient#dataikuapi.DSSClient
Hope this helps!
Regards,
Madhuleena
Answers
-
Thank you! however can you tell me how to define the client? i tried all methods i found online but none of them seems to work.
and i'm running the method in the API Designer of the same project with the dataset.
-
Hi,
did you try this one:
client = dataiku.api_client()
This is the usual way to get the client.
Best
-
I have but thanks again! the problem was actually the project key
-
Thank you! this worked but apparently what i had wrong all that time were the api and project keys.
I was using the api key of the api i was working on, and my personal api key.
and the problem with the project key was that it should be capitalized