cancel
Showing results for 
Search instead for 
Did you mean: 

File path in custom python operator

Cocquerel
Active Contributor
0 Kudos

Hello,

Let's say I create a custom python operator named com.mycompany.myoperator
In the folder /files/vflow/subengines/com/sap/python36/operators/com/mycompany/myoperator , I have uploaded a file named mymodel.joblib

I'm trying to open this file from my python script with a coding that looks like this

with open('<filepath>', 'rb') as f:
   model=load(f)

but it always fails with error message "No such file or directory".

Here are the different values I tried for <filepath>:
/files/vflow/subengines/com/sap/python36/operators/com/mycompany/myoperator/mymodel.joblib
/vflow/subengines/com/sap/python36/operators/com/mycompany/myoperator/mymodel.joblib
operators/com/mycompany/myoperator/mymodel.joblib
./operators/com/mycompany/myoperator/mymodel.joblib
../operators/com/mycompany/myoperator/mymodel.joblib
mymodel.joblib
Thanks for your help
Regards,
Michael

Accepted Solutions (0)

Answers (1)

Answers (1)

mike_dehart
Explorer
0 Kudos

Hi Michael,

If you're using a custom dockerfile for your custom operator you should be able to copy the file to the local home dir within the dockerfile. Adding a line like...

COPY mymodel.joblib /home/vflow/mymodel.joblib

Cocquerel
Active Contributor
0 Kudos

Thanks for your answer. I have found an other solution that is to upload the file using the File Reader operator and then provide the file as input port for my custom python operator. That is working fine.