Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create python libraries and how to import it in palantir foundry

In order to generalize the python functions, I wanted to add functions to python libraries so that I can use these function across the multiple repositories. Anyone please answer the below questions.

1) How to create our own python libraries 2) how to import those libraries across multiple repositories

like image 634
Gavisha BN Avatar asked Oct 13 '20 09:10

Gavisha BN


2 Answers

  1. How to create python libraries in Palantir Foundry?

To create a new library, you can do so by creating a new repository. When prompted to initialise the repository, you should have an option that reads:

Python Library
Template for publishing a Python library package. Consuming new libraries has changed,
please read README in library repository.

The readme will contain instructions on how to publish a library. It is recommended you understand how conda publishing channels work for this.

A note, avoid using _ in the library name, since it can cause problems. - is safe to use though.


  1. How to import a library in code authoring?

Once your library is publishing, you can add it to your conda recipe of the repository you want to consume the library in. You can find this in: transforms-python/conda_recipe/meta.yaml

Afterwards just add it to the list of under

requirements:
  run:
    - python
    - pandas
    - your-library-name

like image 154
fmsf Avatar answered Oct 20 '22 14:10

fmsf


In addition to fmsf's answer, in the second step you might have to add the following content to the build.gradle of your transforms-python directory:

transformsPython { 
    sharedChannels "libs" 
} 
like image 1
nicornk Avatar answered Oct 20 '22 14:10

nicornk