1

how do I pass a yaml file to inference config? the yaml file is in the same source directory as my score.py file

my yaml script is called score_env.yaml

name: inference_environment
dependencies:
- python=3.8.1

- pip:
- azureml-defaults
- numpy
- scikit-learn
- joblib
- pandas

is the following correct

inf_conf = InferenceConfig(entry_script="score.py",environment="score_env.yaml",source_directory=folder_path)

or would i do this instead

inf_conf = InferenceConfig(entry_script="score.py",environment="inference_environment",source_directory=folder_path)
Ross
  • 99
  • 8

2 Answers2

0

The documentation states that you can use either conda_file and pass in a file name or environment and pass in an Environment object.

So, in your case, you would want to use conda_file:

inf_conf = InferenceConfig(entry_script="score.py", conda_file="score_env.yaml", source_directory=folder_path)

link to documentation

Daniel Schneider
  • 1,797
  • 7
  • 20
0

Referring to the answer here[1], I was able to get this working by initiating a new environment:

from azureml.core.environment import Environment

myenv = Environment.from_conda_specification(name="myenv", file_path="score_env.yaml")

and then pass this to the inference_config:

inference_config = InferenceConfig(source_directory=folder_path,
                                        entry_script="score.py",
                                        environment=myenv)

[1]: https://stackoverflow.com/questions/66437607/how-to-create-azure-ml-inference-config-and-deployment-config-class-objects-from#:~:text=CONDA_ENV_FILE_PATH%2C%20%27myenv.yml%27)-,myenv%20%3D%20Environment.from_conda_specification(name%3D%22myenv%22%2C%20file_path%3D%22myenv.yml%22),-script_file_name%20%3D%20%27inference/score

ammar
  • 3
  • 2