5B. [Repositories] Publishing and Using Shared Libraries in Code Repositories9. Replace Code References

9 - Replace Code References

This content is also available at learn.palantir.com ↗ and is presented here for accessibility purposes.

📖 Task Introduction

In this task, you’ll replace the dependency on the local cleaning files with references to the cleaning library you created in the previous exercise.

🔨 Task Instructions

  1. Return to the Files view in your left-hand panel and expand all contents.

  2. Your .../preprocessed folder contains 3 code files, each of which imports the local cleaning utils on line 3. In each of the three preprocessed files, replace the "old" import statement with the "new" one:

    • Old: from myproject.datasets import type_utils as types, cleaning_utils as clean

    • New: from cleaning_functions import type_utils as types, cleaning_utils as clean

      If your repository is underlining your new import statement in red, try opening your meta.yml file and clicking the Refresh Code Assist dependencies link in the top of the code editor window.

  3. Right click on each of the *_utils.py files in your repository and choose Delete file. In the pop-up confirmation, click the red Yes, delete button.

  4. Using the Preview button in the top right, confirm that your preprocessed transforms work with the new library reference (i.e., the category column values don'e appear with extra spaces, like delay••).

  5. Commit your code with a message like, “refactor: replace local cleaning with shared lib.

  6. Once CI checks have passed on your commit, choose one of your preprocessed code files and build it on your branch to confirm it works with the new library reference.

  7. Create a PR and merge your branch into Master if your build was successful.