The Custom Python job provides user the ability to run Python code via Lucidworks Search.Documentation Index
Fetch the complete documentation index at: https://doc.lucidworks.com/llms.txt
Use this file to discover all available pages before exploring further.
The Python version required depends on your Spark version:
- Spark 3.4.1 (default in Lucidworks Search 5.9.10 and later): Requires Python 3.10
- Spark 3.2.2 (Lucidworks Search 5.9.9 and configurable in 5.9.12 and later): Supports Python 3.7.3
Usage
Python code can be entered directly in the job configuration editor or you can reference a script that has been uploaded to the blob store. Additional Python libraries or files can be supplied via a Python files configuration.Examples
Example Python script that indexes data from parquet to Solr via a Lucidworks Search index pipeline:script variable of the job config and several arguments are passed via the submitArgs configuration key:
Configuration
Apache Arrow is installed to the image and the two settings below are enabled by default. If you want to disable arrow optimization, set these properties to false in the job config or in job-launcher config map:Available libraries
These libraries are available in the Lucidworks Search Spark image:numpyscipymatplotlibpandasscikit-learn
Adding libraries
If you need to add extra libraries to run your code, you can upload the Python egg files to the blob store and reference their blob IDs in the job configuration. However, machine learning libraries (liketensorflow, keras, and pytorch) are not easy to install with that approach. To install those libraries, follow this approach instead:
-
Use this example
Dockerfileto extend from the base image: - Build the Docker image and publish it to your own Docker registry.
-
Once the image is built, the custom image can be specified in the Spark settings via
spark.kubernetes.driver.container.imageandspark.kubernetes.executor.container.image.
ImportantIf you upload
.zip files to add libraries, use the Other blob type for binary files instead of the File blob type. If the File blob type is used, the custom Python job fails.