Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I use a different python version for prompt flow custom runtime? #154

Open
sparse-coder opened this issue May 27, 2024 · 5 comments

Comments

@sparse-coder
Copy link

We are using our own environment definition to build the promptflow runtime image, and use it as the base for provisioning the custom runtime on AML compute instance for doing batch and evaluation runs.

So far we are good.

What we need is a way to use a different python version e.g. Python 3.11 on my custom runtime. Is there a way I can do this? So far what I have observed is all the base images supplied by mcr use python 3.9.

My docker file looks like this
FROM mcr.microsoft.com/azureml/promptflow/promptflow-runtime-stable:20240515.v1 COPY ./* ./ RUN pip install -r requirements.txt
Is there a way I can define something in my docker file to upgrade the python version?

@stewartadam
Copy link
Member

stewartadam commented Jun 17, 2024

We're looking to do something similar, you can use conda to update the runtime env with conda install -y 'python=3.11' but unfortunately unseats the promptflow-runtime whl and since that wheel is unpublished, you can't get it back from upstream. You have to manually copy it between Python versions:

FROM mcr.microsoft.com/azureml/promptflow/promptflow-runtime:latest

# Update to Python 3.11
RUN conda install -y 'python=3.11' -p /azureml-envs/prompt-flow/runtime && \
  pip install --no-cache-dir -r extra_requirements.txt && \

# Copy Python 3.9 promptflow-runtime whl to 3.11
RUN cp -a azureml-envs/prompt-flow/runtime/lib/python3.9/site-packages/promptflow/runtime azureml-envs/prompt-flow/runtime/lib/python3.11/site-packages/promptflow/ && \
  sed -i -e 's|bin/python3.9|bin/python3.11|' /azureml-envs/prompt-flow/runtime/bin/prt && \
  grep ^Requires-Dist azureml-envs/prompt-flow/runtime/lib/python3.9/site-packages/promptflow_runtime-*.dist-info/METADATA | cut -d' ' -f2- | cut -d';' -f1 > promptflow-runtime-requirements.txt && \
  pip install --no-cache-dir -r promptflow-runtime-requirements.txt

It's ugly and probably prone to breakage so YMMV, but it works with the current image. If you want to investigate further, this is what helped me:

# pseudo-generate the original dockerfile instructions
docker history --no-trunc --format json mcr.microsoft.com/azureml/promptflow/promptflow-runtime | jq -r '.CreatedBy' | tac

# start the runtime img to inspect its dependencies
docker run -it --rm --entrypoint /bin/bash mcr.microsoft.com/azureml/promptflow/promptflow-runtime:latest /bin/bash
pip show -f promptflow-runtime

@sparse-coder
Copy link
Author

sparse-coder commented Jun 29, 2024

@stewartadam Thank you! I did the same thing by updating the conda env, but this idea of copying the promptflow-runtime wheel didn't occur to me. Good idea👍 BTW!

For now we have decided to not go through this route!

Thank you!

@ebotiab
Copy link

ebotiab commented Oct 3, 2024

Hi, is this issue expected to be fixed in the future?

@WilliamWatsonEAI
Copy link

@ebotiab agreed, this should not be so hard to change base image Python version

@lovedeepatsgit
Copy link

@stewartadam can you please also tell me how to adjust the liveness and readiness of the container, And what do you mean by that promptflow_runtime whl is not published. And, I have also taken reference from your suggestion, but at the end I got stuck on a point in the final deployment, below is the error I am facing:
Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants