Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

When specifying the location of a Python executable in the Python Manager(3.3) or in the Python Interpreter Profile (3.3), you can either use the path to the executable in the file system or use connection details to a Python daemon. If you choose to connect to a Python daemon, you can provide your own sidecar container for running Python processes.

The sidecar container is an extra container that you add to the ECD. To use the sidecar container, you must create your own Docker image and include the pythond.py script in your image. This script can be found in $MZ_HOMEthe /opt/mz/python/ directory on the platform container.

To connect to the Python daemon running in the sidecar container, you need to configure the Python Manager to connect using localhost:port, where port is the port that the daemon is listening to, for example, localhost:5454.

Here is an example of a Dockerfile that you can use to build your image:

Code Block
FROM python:3.12
RUN pip install pandas
COPY pythond.py .
CMD ["python", "pythond.py", "5454"]

In this example, we are using the python:3.12 base image is used and installing the pandas package is installed with pip. We then copy the The pythond.py script is then copied to the container and set the command is set to run the script with port 5454.

...

To add the container to your ECD, you can use a YAML snippet like this as shown below to apply your changes:

Code Block
languageyaml
spec:
  sidecars:
  - image: my-python-image:latest
    imagePullPolicy: IfNotPresent
    name: python-container

This YAML example specifies that we want to add a sidecar container named python-container with image my-python-image:latest and imagePullPolicy set to IfNotPresent.

Please note Note that you can choose any port number instead of 5454 as long as it is not already in use by another process.

If you want to use your sidecar container for code completion in the Python Code Editors Editor as described in the Python Manager tool documentation(3.3), you also need to add your sidecar to the Platform. You can add a YAML snippet like this as shown below to your values.yaml to achieve this:

...