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!
Hello,
I would like to read the global variables of my project within an API endpoint implemented with a Python function.
I tried to use the REST API Dataiku to get the project variables. (DSSClient, get_project and get_variables)
Please, could you let me know if this is the right way to do it ?
If yes, which settings are required ? (I got an error of type 'No connection adapters were found ' when I use the get_variables method).
If no, what is the best way to read the project variables ?
Annie
Hello,
I found the reason of the issue : the host reference was not specified correctly with the method DDSClient.
Now it works fine with the following statements :
client = dataikuapi.DSSClient("http://host:port","api_key")
project_DSS=client.get_project('TEST')
proj_var=project_DSS.get_variables()['standard']
Thanks a lot for your help
Annie
Hi,
An API endpoint is completely isolated code that does not execute on DSS but on separate API nodes, and not within the context of a project. It does not natively have a concept of project, and thus not of project variables.
You can create an API client manually in your endpoint, using DSSClient(dss_host, api_key) but you will need to hardcode this dss_host and api_key in the endpoint code, which is not something you usually want.
What do you want to do more precisely?
Hello Clรฉment,
Thanks a lot for your VERY quick reply.
We are developing a web application calling DSS API endpoints developped in Python.
Most of the functions, used in these endpoints, are setup in the project libraries initialized from a git repository shared with another team.
Due to the project context, we want to use some project variables during the endpoints execution.
I used the DSSClient with the host and a global api_key to access to the project. The issue happens when I use the 'get_variables' from the project. It seems that there is an issue to read /projects/'project_name'/variables/.
I don't understand the error message about connection adapters. Please, could you help ?
Annie
Hello,
I found the reason of the issue : the host reference was not specified correctly with the method DDSClient.
Now it works fine with the following statements :
client = dataikuapi.DSSClient("http://host:port","api_key")
project_DSS=client.get_project('TEST')
proj_var=project_DSS.get_variables()['standard']
Thanks a lot for your help
Annie