microsoft / promptflow

Build high-quality LLM apps - from prototyping, testing to production deployment and monitoring.
https://microsoft.github.io/promptflow/
MIT License
9.53k stars 872 forks source link

[Contribution Request] pf cli - extend the pf flow build command to support different python versions #3830

Open lealgamb opened 4 weeks ago

lealgamb commented 4 weeks ago

Is your contribution request related to a problem? Please describe. Yes. We are using the pf flow build command to deploy our flow as an app service. The generated Dockerfile uses Python 3.9, but some of our flow's requirements (e.g., semantic-kernel==1.11.0) need Python 3.10 or above. We need a way to specify the Python version in the Dockerfile.

Detail the functionality and value. The contribution will allow users to specify the Python version in the Dockerfile generated by the pf flow build command. This can be achieved by accepting a conda YAML file instead of a requirements.txt file, similar to how AzureML supports specifying the Python version for environments. This enhancement will provide greater flexibility and ensure compatibility with dependencies that require newer Python versions.

Additional context Here is the current Dockerfile that is generated for reference:

# syntax=docker/dockerfile:1
FROM docker.io/continuumio/miniconda3:latest

WORKDIR /

COPY ./flow/requirements.txt /flow/requirements.txt

# gcc is for build psutil in MacOS
RUN apt-get update && apt-get install -y runit gcc

# create conda environment
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 keyrings.alt && \
    conda run -n promptflow-serve pip install gunicorn==20.1.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

COPY ./flow /flow

EXPOSE 8080

COPY ./connections /connections

# reset runsvdir
RUN rm -rf /var/runit
COPY ./runit /var/runit
# grant permission
RUN chmod -R +x /var/runit

COPY ./start.sh /
CMD ["bash", "./start.sh"]

Here is a sample conda_dependencies.yml for reference that we use in other AzureML processes:

name: custom_env 
dependencies:
- python=3.10
- pip

- pip:
  - semantic-kernel==1.11.0
  - ...