Building promptflow as docker has missing dependencies that cause llm node to fail

Bart Bachniak 0 Reputation points
2025-02-18T18:39:57.3666667+00:00

I followed this tutorial in order to dockerize my prompt flow.
Error occurs both in vs code plugin GUI https://techcommunity.microsoft.com/t5/s/gxcuf89792/images/bS00MDA0MzA3LTUzMzE0NmlBOTE0NjI0MkQ1NEE4M0NB?revision=15 as well as in CLI when one tries to build a flow as docker:

pf flow build --source ./strategy-pollster --output ./build/strategy-pollster --format docker

The output folder with Dockerfile has missing dependencies in requirements.txt, and in Dockerfile it installs only these:

RUN conda create -n promptflow-serve python=3.9.16 pip=23.0.1 -q -y && \
    conda run -n promptflow-serve \
    pip install -r /flow/requirements.txt && \
    conda run -n promptflow-serve pip install promptflow && \
    conda run -n promptflow-serve pip install keyrings.alt && \
    conda run -n promptflow-serve pip install gunicorn==22.0.0 && \
    conda run -n promptflow-serve pip install 'uvicorn>=0.27.0,<1.0.0' && \
    conda run -n promptflow-serve pip cache purge && \
    conda clean -a -y

In my flow code all the python nodes are using the new syntax with `

from promptflow.core import tool

However nodes with LLM that I don't implement myself seem to use old deprecated syntax from promptflow.tool

In my flow 'pollster' is LLM node (see inserted image)
User's image

And inside that node error occurs that is causing whole flow to crash:
` raise FailedToImportModule(

promptflow.contracts._errors.FailedToImportModule: Failed to import modules with error: Import node 'pollster' provider module 'promptflow.tools.aoai' failed. Root cause: ModuleNotFoundError("No module named 'promptflow.tools'").

[2025-02-18 18:10:25 +0000] [346] [INFO] Worker exiting (pid: 346)

[2025-02-18 18:10:25 +0000] [338] [ERROR] Worker (pid:343) exited with code 3

I tempraly fixed it by adding all the dependencies from my conda virtual environment to requirements.txt in the docker build folder that I printed using comand pip list --format=freeze. It's suboptimal as it probably has too many dependencies, but at least it worked.

Azure Machine Learning
Azure Machine Learning
An Azure machine learning service for building and deploying models.
3,141 questions
Azure Container Apps
Azure Container Apps
An Azure service that provides a general-purpose, serverless container platform.
543 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. kothapally Snigdha 1,595 Reputation points Microsoft Vendor
    2025-02-18T23:03:56.9733333+00:00

    Hi Bart Bachniak,

    It seems that the error you are encountering is related to missing dependencies in your Docker image for Promptflow. The ModuleNotFoundError indicates that the promptflow.tools module is not found, which suggests that the required dependencies are not properly installed in your Docker environment.

    To resolve this issue, ensure that your requirements.txt file includes all necessary dependencies for the LLM nodes, especially those that are part of the promptflow.tools package. Since you mentioned that you added all dependencies from the conda virtual environment as a temporary fix, it would be beneficial to identify the specific dependencies required for the LLM nodes and include only those in your requirements.txt.

    Additionally, you may want to verify that the version of Promptflow you are using is compatible with the syntax and modules you are implementing in your flow. If the LLM nodes are using deprecated syntax, consider updating them to the latest version of the Promptflow library that supports the new syntax.

    I hope these helps you. Thank you!


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.