FileNotFoundError when trying to get predictions from Python Function API deployed

sujayramaiah Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 5 ✭✭✭

We have a model which should predict in real time.
Since we have a lot of custom data pre-processing steps in the flow, we have included all the steps as scripts in the library and have imported the scripts using a python function.
We have deployed an API service with a python function end point.

When trying to get a prediction from a model which has been deployed to the flow, we are seeing this error.

Failed: Failed to run function : <class 'FileNotFoundError'> : [Errno 2] No such file or directory: '/data/dataiku/data_dir/saved_models/ML_EDA/<ModelID>/versions/16635986036/core_params.json'

Can we include the model in the Deployer node?
We are not seeing the model export option to possibly add the model into a managed folder.
Can you please suggest an alternative way to achieve this?



I was not able to post a reply to this thread.

We were able to resolve this issue by deploying the model as a prediction end point under the same parent service and invoking the prediction service from the python code of the other end point using the code snippet shown below:

from dataiku.apinode import utils

apinodeclient = utils.get_self_client()
prediction = apinodeclient.predict_record("<EndPoint>","<features>", with_explanations=True)

Operating system used: Linux



  • carlhyde
    carlhyde Registered Posts: 2 ✭✭✭✭

    When you specify the file name "filename.ext" while read file, you are providing the open() function with a relative path. This means that the file you want to read is located in the current working directory.

    file = open('filename.ext') //relative path

    In the above code, you are not giving the full path to a file to the open() function, just its name - a relative path. The error “FileNotFoundError: [Errno 2] No such file or directory” is telling you that there is no file of that name in the working directory. So, try using the exact, or absolute path.

    file = open(r'C:\path\to\your\filename.ext') //absolute path

    In the above code, all of the information needed to locate the file is contained in the path string - absolute path.

    If the full path to the file is not provided, the python file path is interpreted relative to the current working directory. This is the directory from which the program was started. For this to work, the directory containing the python executable must be in the PATH environment variable, which contains directories automatically searched for executables when a command is entered. To access a file in a different directory, you must either specify a relative path between the files or use an absolute path for one of them.

Setup Info
      Help me…