Custom Dockerfile on Azure Environment with python poetry

Antara Das 376 Reputation points
2021-12-06T20:04:14.557+00:00

I am new to docker and environments. This could be basics but i have been trying to install packages in my pyproject.toml file in Dockerfile without success.

I have tried using poetry to export requirements.txt file and using it with the
Environment.from_pip_requirements('requirements.txt') function and a Dockerfile.

But could there be any elegant solution to use toml file directly for creating a custom environment ?

Azure Machine Learning
Azure Machine Learning
An Azure machine learning service for building and deploying models.
2,573 questions
0 comments No comments
{count} vote

Accepted answer
  1. Antara Das 376 Reputation points
    2021-12-08T16:31:16.963+00:00

    Thanks for the response, @Ram R
    Using the Dockerfile :

    FROM python:3.8-slim-buster  
    ENV PYTHONUNBUFFERED=1 \  
        PYTHONDONTWRITEBYTECODE=1 \  
        PIP_NO_CACHE_DIR=1 \  
        PIP_DISABLE_PIP_VERSION_CHECK=1 \  
        POETRY_VERSION=1.1.7 \  
        PYLINT_VERSION=2.9.4  
      
    RUN pip install pylint==$PYLINT_VERSION \  
        && pip install "poetry==$POETRY_VERSION"   
      
    COPY pyproject.toml ./  
    RUN poetry config virtualenvs.create false   
    
    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Ramr-msft 17,616 Reputation points
    2021-12-07T15:37:01.407+00:00

    @Antara Das Thanks for the question. Can you please share the sample/document that you are trying. I would recommend to use yml file that is relatively easy to get from pip requirements file

    from azureml.core import Environment
    from azureml.core.conda_dependencies import CondaDependencies

    env = Environment(“myenv”)
    env.python.conda_dependencies = CondaDependencies(“my_yaml_file”)

    https://learn.microsoft.com/en-us/azure/machine-learning/how-to-train-with-custom-image

    0 comments No comments