Custom libraries

If you need to use the Python libraries that are not pre-installed on the platform (see Python libs for built-in libraries), you can manually install them in the Libraries tab.
notion image
To install the library you need to configure:
  • Source - the source of installation - pypi
  • Name - the name of the library
  • Version (optional) - the version of the library. If not selected, the latest version of the library is installed.
 
After that, click the Add button. We will validate whether the library can be installed and check for conflicts.
You can get the validation status from the Installation logs window. If the library has been validated successfully, you receive a notification and it appears in the My Libraries section. You can delete the library from My Libraries by clicking on the 🗑️ icon.
When you press Save we will finalize the installation and save the custom code brick.

Example

Let’s have a look at the example of library installation in Custom Code brick.
We can install the latest version of the nltk library with the following settings:
notion image
 
Next, we click on the Add button. And the 3.7 version of the library was added successfully to the list of libraries for further installation. The version of the library will not be automatically updated to ensure no problems in your pipeline appears due to the version mismatch.
notion image
 
If we try to add the library or version that doesn’t exist, we get the error.
notion image
 
notion image
Also, we don’t need to install the library, which is already pre-installed on the platform. See Python libs for Datrics built-in libraries.
notion image
 
To change an existing library’s version - nltk in this example, first we have to delete it from the list and then reinstall it with a specified new version:
Delete the library
Delete the library
 
Install a different version
Install a different version
After configuring the libraries, click the Save button to complete the installation. The process may take some time.
 

Copy custom code brick

Copy the brick
Note that after copying the brick to the same or different project, libraries are installed automatically.
notion image
 
Copy pipeline with custom code
When you are copying the pipeline with the custom code bricks, the new custom code brick is created without libraries installed. You will be informed on the pipeline scene and custom code brick editor. To install the libraries on the brick, open custom code editor and press the Save and Install button.
Step 1
notion image
Step 2
notion image
Step 3
notion image
 
 
Installed libraries can be imported and used within the brick’s Code tab by following the standard Python library import convention.