Possible to set importLibrariesFromProjects using Python

info-rchitect
info-rchitect Registered Posts: 191 ✭✭✭✭✭✭

Hi,

I need to be able to set importLibrariesFromProjects using Python, is this possible?

thx

Operating system used: Windows10

Best Answer

  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,162 Neuron
    Answer ✓

    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

Setup Info
    Tags
      Help me…