简体   繁体   中英

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

  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

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" 
} 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM