Call python function on project level

Options
dhyadav79
dhyadav79 Dataiku DSS Core Designer, Dataiku DSS & SQL, Dataiku DSS ML Practitioner, Dataiku DSS Core Concepts, Registered Posts: 21 ✭✭✭✭

Hi,

I have created a function and added with library (within folder of python) but when I try to call the function , I am getting error like "No module named 'myfun'" , When I created same function outside of folder and try to call then getting error like "NameError: name 'fun_name' is not defined

As per my understanding:

(1) create python function

(2) Added into python library

Could you please help with example where I am doing the mistake.

Answers

  • Miguel Angel
    Miguel Angel Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 118 Dataiker
    Options

    Hi,

    The steps to create reusable python code are detailed with some working examples here: https://doc.dataiku.com/dss/latest/python/reusing-code.html

    The error message is letting us know it cannot find that module and the root cause could be because of several reasons, some of which are:

    • The project notebook/recipe where the module is being called is different from the project where the reusable script was created.
    • The extension of the reusable python file is not '.py', or if within a subfolder, it may be missing the __init__.py file.
    • The notebook kernel needs to be restarted to pick up the changes to the project library

    I'd recommend going through with the examples in the documentation. If those examples still fail for you, we'll need some details of your instance to further investigate. That conversation will be more effective over a support ticket, which you can create here: https://support.dataiku.com/support/home

Setup Info
    Tags
      Help me…