Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

When specifying the location of a Python executable in the Python Manager or in the Python Interpreter Profile, 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_HOME/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:

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 and installing the pandas package with pip. We then copy the pythond.py script to the container and set the command to run the script with port 5454.

To use this Dockerfile, you need to create a new directory and place both the Dockerfile and pythond.py script in that directory. You can then build the image using docker build -t my-python-image:latest .. This will create a new Docker image with the name my-python-image and tag latest.

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

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 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 as described in the Python Manager tool documentation, you also need to add your sidecar to the Platform. You can add a YAML snippet like this to your values.yaml to achieve this:

platform:
  sidecars:
  - image: my-python-image:latest
    imagePullPolicy: IfNotPresent
    name: python-container

When you use a sidecar container, you can install additional Python packages that are not included in the standard installation. You can also choose which version of Python to use when running your code.

  • No labels

0 Comments

You are not logged in. Any changes you make will be marked as anonymous. You may want to Log In if you already have an account.