Search code examples
python-3.xyamlcondaazure-machine-learning-service

How to execute python commands from a conda .yaml specification file?


I am trying to list conda dependencies using a .yaml file for an AzureML environment. I do not want to use a custom docker image just for a few variations. I wonder if there is a way to instruct the build to run python commands using the .yaml file. Here are excerpts of what I have tried as of now:

name: classifer_environment
dependencies:
- python=3.6.2

- pip:
  - azureml-defaults>=1.0.45
  - nltk==3.4.5
  - spacy

- command: 
  - bash -c "python -m nltk.downloader stopwords"
  - bash -c "python -m spacy download en_core_web_sm"

I also tried this:

name: classifer_environment
dependencies:
- python=3.6.2

- pip:
  - azureml-defaults>=1.0.45
  - nltk==3.4.5
  - spacy

- python: 
  - nltk.downloader stopwords
  - spacy download en_core_web_sm

I do not have much clarity about yaml specifications. Both the specifications fail with the following messages respectively in the build logs:
"Unable to install package for command."
"Unable to install package for python."


Solution

  • This might be a neat feature to have, but for now it's not a thing - at least not directly in the YAML like this.

    Instead, the unit of computation in Conda is the package. That is, if you need to run additional scripts or commands at environment creation, it can be achieved by building a custom package and including this package in the YAML as a dependency. The package itself could be pretty much empty, but whatever code one needs to run would be included via some installation scripts.