Good morning everyone,
I am currently working on a project, and I need to write an API, by using the API designer in the API node.; the core of the API will be an R predict function which is going to be exposed.
The trained model are stored into managed folders, as I understood that this is the correct way to use R model in DSS; for this specific project I am going to have several managed folder and I need to retrieve the absolute path to them, in order to initialize the models and then use them in the predict R function.
From the on line documentation I have understood that the correct way to get the absolute paths to the resource folders by calling the dkuAPINodeGetResourceFolders() function; this function, as it is written in the on line documentation, should returns a vector of character vectors, each one being the absolute path to the folder.
Now my question is how to test this function, and how to understand which element of the resulting vector is associated with the different managed folders involved in the project and so I can map element of the resulting vector with my different managed folders.
I have tried to create a notebook, in the very same project, and call that function but I get the following error message
'Error in dkuAPINodeGetResourceFolders(): could not find function "dkuAPINodeGetResourceFolders"'
which is due, I suppose, to the fact that this function can be used only in the API Node.
So my question is; is there a way to test this function in the API node or alternatively, is there a way to retrieve the absolute path to the resource folders by calling a different function inside a Notebook?
Thanks everyone for your support.
In a notebook, you would retrieve the path to a managed folder using dkuManagedFolderPath("the_id_of_your_folder")
It is indeed slightly different in the API node where notions of DSS projects and objects don't exist anymore and you just get a list of paths, in the same order as the folders that you have declared in the endpoint settings.
Our recommendation for testing would be to write most of the code of your endpoint in project-level libraries (https://doc.dataiku.com/dss/latest/R/reusing-code.html).
This way, your test notebook would just grab the paths using dkuManagedFolderPath and then call your library code. The API node endpoint would grab the paths using dkuAPINodeGetResourceFolders and call the same library code.
When packaging your API endpoint, the libraries are sent with it.
Don't forget that you need to unload and reload the notebook when updating project-level code libraries (restarting the kernel is not enough)