Python Activity : Invoke Python Method

Hi again,

We do not know where your inpur csv is. My suggestion was just by looking at your Read File Location. If you know that the input csv location is correct then ignore what I said before. We want to you eliminate causes for failures.

Please read this post to see how to properly use methods from your python scripts.

Using class methods is not the same as using functions. Here you have a class method and not a function. UiPath can execute functions not class methods.
Invoke Python Method: Pipe is broken - Help / Activities - UiPath Community Forum


I would have simiplified your code like this. I cannot test this so you will have to check that this works outside UiPath first.

You are not using Pandas here so, ignore it.
Make sure you are using absolute path in model = joblib.load(‘finalized_model.sav’)

import joblib
import json

def predict(in_argument):
    """ 
    This function predicts (Something)
    in_argument : Your input argument
    Returns : Predicted json string to UiPath
    """

    with open(‘./creditcard.csv’, ‘rb’) as input_file:
    bytes = input_file.read()

    model = joblib.load(‘finalized_model.sav’)
    payload = json.loads(in_argument)
    result = model.predict_proba(payload)
    return json.dumps(result.tolist())

I also suggest you to refer to PEP 8 – Style Guide for Python Code | peps.python.org