Running Python code in Library from Dataiku Application

williamwirono
williamwirono Partner, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 11 Partner

Hi! I am interested in understanding if it is possible to call a Python script in a Library that I linked with my GitHub, and call a module within that script to run it on a Dataiku Application.

In other words, how do you call a Python script defined in a Project Library to the interface below which is defined in the Dataiku Application designer:


Any help is appreciated! Thanks in advance!

Best Answer

  • williamwirono
    williamwirono Partner, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 11 Partner
    Answer ✓

    Got this to work by adding this code block in the Application designer Python code block:

    project_name = dataiku.get_custom_variables()["projectKey"]
    dip_home = dataiku.get_custom_variables()["dip.home"]
    libraries_path = os.path.join(dip_home, 'config/projects/' + project_name + '/lib/python')

    os.chdir(libraries_path)
    sys.path.insert(0, libraries_path)

    Then, do not forget to click 'Create or update test instance (full)' to make sure changes in both your Python code and Code library are detected

Setup Info
    Tags
      Help me…