Possible to set importLibrariesFromProjects using Python
Hi,
I need to be able to set importLibrariesFromProjects
using Python, is this possible?
thx
Operating system used: Windows10
Best Answer
-
Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,162 Neuron
Here you go:
import dataiku import json client = dataiku.api_client() project = client.get_default_project() library = project.get_library() # Read external-libraries.json external_libraries_json = json.loads(library.get_file("/external-libraries.json").read()) # Append project key into importLibrariesFromProjects property external_libraries_json['importLibrariesFromProjects'].append('PROJECT_KEY') # Write external-libraries.json library.get_file("/external-libraries.json").write(json.dumps(external_libraries_json, indent=2))
Answers
-
Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,162 Neuron
What are you tryign to achive? Is it this?
https://doc.dataiku.com/dss/latest/python/reusing-code.html#importing-libraries-from-other-projects
-
When I clone a project, I want to be able to set a specifc project (different from the cloned project) to inherit code library from.
-
Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,162 Neuron
Well as per the documentation you can do so on the external-libraries.json fil ein the Library Editor:
-
Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,162 Neuron
PS: If you are loading libraries in a Jupyter Notebook you have to "Force Reload" to see the new libraries (restarting the Jupyter Kernel is not enough).
-
Yes, sorry about not being clearer. I know about the external-libraries.json file. I am asking how I can use Python to set the value for the
importLibrariesFromProjects
key, in that file.