Forum Discussion
How creating a Python custom library
- 3 months ago
Hi pmscorca,
That is correct. Here is an example of a custom workload with the extensibility toolkit: https://community.fabric.microsoft.com/t5/Extensibility-Toolkit-Gallery/Fabric-Job-Registry/m-p/5006346
Hi pmscorca, your question is multi-faceted and may require more than a single answer. You state two separate goals: create a custom Python library to use in a Notebook, and protect your propriatary code. The goals may be related but independent. Because code protection is absolutely outside of Fabric concers I will only share my thoughts about custom code in Notebooks.
You create a custom Python library as any other Python development project in your local Python development environment with your regular development process. Before you do this, you need to answer the following quesions:
- decide what execution environment in Fabric you'll be running your code in; you already stated a Notebook.
- make sure that your code is fully compatible with Fabric execution environment; you need to understand dependencies of your code and make sure those dependencies can be resolved in Fabric Notebook execution environment. You may wat to take a look at this guide Use Python experience on Notebook - Microsoft Fabric | Microsoft Learn
- decide how you install your code in your Fabric execution environment. There are two baseline methods in Fabric: install your code using pip command in your Notebook cell, or install your library in a Spark environment. You may want to check out this guide Manage libraries in Fabric environments - Microsoft Fabric | Microsoft Learn.
Once you have you library installed in a Fabric environment, test it by running some code in your Notebook that uses your library.
This is a relatively straightforward process and should let you go ahead with developing your custom Python code and running it in the Fabric Notebooks.
A thought about code protection. The rule of thumb is that Fabric does not provide any features of facilities to protect your code. Any Python code is interpreted and exists in your execution environment as text, so no help in this area. This is a common concern for Python development in general and not Fabric specific, so you need to research protection techniques regardless of where you deploy and run your code.
Hope this answer helps. If so, consider giving it kudos and mark as a solution to help other community members.