Change the import naming

Hello all,

We have a model that we get in a pickle format, and this model uses a library called mes_fonctions_pour_pickle, so in the pickle we have some imports like from mes_fonctions_pour_pickle import function1, now we want to use that model in palantir, and we want to be able to import the functions directly using the name “mes_fonctions_pour_pickle” ( if we create a library, and put the file that contains our code in the library, when we will want to import the lib, the import will be import from mes_fonctions_pour_pickle.name_of_the_file, we don’t want it like that because the imports already exists in the pickle, we want to be able to import the library directly with import from mes_fonctions_pour_pickle, otherwise the loading of the pickle fail) hope it was clear, does anyone know how can we do that ?
Your help in solving this issue or giving us some other ideas to achieve this use case will be greatly appreciate.

Thank you!
Soufiane

Hi Soufiance, the best way to integrate model into foundry for use case is to leverage model adapter and model serialization methods detailed in this public doc.
Integrate models • Model serialization • Palantir

Hello,

That’s what i already use, but as i said, when you load the model, it will try to do the following :
“import function1 from mes_fonctions_pour_pickle”
so i need to have a library called mes_fonctions_pour_pickle
i don’t see how can i get that, because if we assume i create a library and call it mes_fonctions_pour_pickle, i will need to put the code of the library in a file, let’s assume it’s called myfile.py, then the import to import function1 will be from mes_fonctions_pour_pickle.myfile import function1, and that will not resolve my issue, because the pickle try to do “from mes_fonctions_pour_pickle import function1”, hope it was clear.

Thank you!
Soufiane Lemrabet