-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Configuration for environment customization #206
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
Merged
dtzar
merged 25 commits into
microsoft:master
from
algattik:algattik/container-resource
Feb 26, 2020
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
f69a2ca
Merge pull request #2 from microsoft/master
algattik 7b370c1
Merge remote-tracking branch 'upstream/master'
algattik 3ab3230
Merge branch 'master' of https://github.com/microsoft/MLOpsPython
algattik 2e1192c
Merge branch 'master' of https://github.com/algattik/MLOpsPython
algattik 896b20f
Merge branch 'master' of https://github.com/microsoft/MLOpsPython
algattik 2a39602
Update getting_started.md
algattik 9919c06
Update diabetes_regression-ci-build-train.yml
algattik 2d7f427
.
algattik 299c9bf
Update diabetes_regression-ci-build-train.yml
algattik d9a2b4e
Update diabetes_regression-ci-build-train.yml
algattik e7097f9
Update diabetes_regression-ci-build-train.yml
algattik 4db36b8
.
algattik cb4c4c2
Update custom_container.md
algattik 510ea8e
Update custom_container.md
algattik 85a8d75
Update custom_container.md
algattik b4412f4
Update getting_started.md
algattik 4ffc60f
Update getting_started.md
algattik f6eae39
Update custom_container.md
algattik 3f5d430
Update custom_container.md
algattik 69bd887
Update custom_container.md
algattik 9689de9
Merge branch 'master' into algattik/container-resource
algattik dd61a7a
PR comments
algattik d641b87
PR fixes
algattik 7c9154d
Update README.md
algattik 950618d
Merge remote-tracking branch 'upstream/master' into algattik/containe…
algattik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| # Customizing the Azure DevOps job container | ||
|
|
||
| The Model training and deployment pipeline uses a Docker container | ||
| on the Azure Pipelines agents to provide a reproducible environment | ||
| to run test and deployment code. | ||
| The image of the container | ||
| `mcr.microsoft.com/mlops/python:latest` is built with this | ||
| [Dockerfile](../environment_setup/Dockerfile). | ||
|
|
||
| In your project you will want to build your own | ||
| Docker image that only contains the dependencies and tools required for your | ||
| use case. This image will be more likely smaller and therefore faster, and it | ||
| will be totally maintained by your team. | ||
|
|
||
| ## Provision an Azure Container Registry | ||
|
|
||
| An Azure Container Registry is deployed along your Azure ML Workspace to manage models. | ||
| You can use that registry instance to store your MLOps container image as well, or | ||
| provision a separate instance. | ||
|
|
||
| ## Create a Registry Service Connection | ||
|
|
||
| [Create a service connection](https://docs.microsoft.com/en-us/azure/devops/pipelines/library/service-endpoints?view=azure-devops&tabs=yaml#sep-docreg) to your Azure Container Registry: | ||
| - As *Connection type*, select *Docker Registry* | ||
| - As *Registry type*, select *Azure Container Registry* | ||
| - As *Azure container registry*, select your Container registry instance | ||
| - As *Service connection name*, enter `acrconnection` | ||
|
|
||
| ## Update the environment definition | ||
|
|
||
| Modify the [Dockerfile](../environment_setup/Dockerfile) and/or the | ||
| [ci_dependencies.yml](../diabetes_regression/ci_dependencies.yml) CI Conda | ||
| environment definition to tailor your environment. | ||
| Conda provides a [reusable environment for training and deployment with Azure Machine Learning](https://docs.microsoft.com/en-us/azure/machine-learning/how-to-use-environments). | ||
| The Conda environment used for CI should use the same package versions as the Conda environment | ||
| used for the Azure ML training and scoring environments (defined in [conda_dependencies.yml](../diabetes_regression/conda_dependencies.yml)). | ||
| This enables you to run unit and integration tests using the exact same dependencies as used in the ML pipeline. | ||
|
|
||
| If a package is available in a Conda package repository, then we recommend that | ||
| you use the Conda installation rather than the pip installation. Conda packages | ||
| typically come with prebuilt binaries that make installation more reliable. | ||
|
|
||
| ## Create a container build pipeline | ||
|
|
||
| In your [Azure DevOps](https://dev.azure.com) project create a new build | ||
| pipeline referring to the | ||
| [environment_setup/docker-image-pipeline.yml](../environment_setup/docker-image-pipeline.yml) | ||
| pipeline definition in your forked repository. | ||
|
|
||
| Edit the [environment_setup/docker-image-pipeline.yml](../environment_setup/docker-image-pipeline.yml) file | ||
| and modify the string `'public/mlops/python'` with an name suitable to describe your environment, | ||
| e.g. `'mlops/diabetes_regression'`. | ||
|
|
||
| Save and run the pipeline. This will build and push a container image to your Azure Container Registry with | ||
| the name you have just edited. The next step is to modify the build pipeline to run the CI job on a container | ||
| run from that image. | ||
|
|
||
| ## Modify the model pipeline | ||
|
|
||
| Modify the model pipeline file [diabetes_regression-ci-build-train.yml](../.pipelines/diabetes_regression-ci-build-train.yml) by replacing this section: | ||
|
|
||
| ``` | ||
| resources: | ||
| containers: | ||
| - container: mlops | ||
| image: mcr.microsoft.com/mlops/python:latest | ||
| ``` | ||
|
|
||
| with (using the image name previously defined): | ||
|
|
||
| ``` | ||
| resources: | ||
| containers: | ||
| - container: mlops | ||
| image: mlops/diabetes_regression | ||
| endpoint: acrconnection | ||
| ``` | ||
|
|
||
| Run the pipeline and ensure your container has been used. | ||
|
|
||
| ## Addressing conflicting dependencies | ||
|
|
||
| Especially when working in a team, it's possible for environment changes across branches to interfere with one another. | ||
|
|
||
| For example, if the master branch is using scikit-learn and you create a branch to use Tensorflow instead, and you | ||
| decide to remove scikit-learn from the | ||
| [ci_dependencies.yml](../diabetes_regression/ci_dependencies.yml) Conda environment definition | ||
| and run the [docker-image-pipeline.yml](../environment_setup/docker-image-pipeline.yml) Docker image, | ||
| then the master branch will stop building. | ||
|
|
||
| You could leave scikit-learn in addition to Tensorflow in the environment, but that is not ideal, as you would have to take an extra step to remove scikit-learn after merging your branch to master. | ||
|
|
||
| A better approach would be to use a distinct name for your modified environment, such as `mlops/diabetes_regression/tensorflow`. | ||
| By changing the name of the image in your branch in both the container build pipeline | ||
| [environment_setup/docker-image-pipeline.yml](../environment_setup/docker-image-pipeline.yml) | ||
| and the model pipeline file | ||
| [diabetes_regression-ci-build-train.yml](../.pipelines/diabetes_regression-ci-build-train.yml), | ||
| and running both pipelines in sequence on your branch, | ||
| you avoid any branch conflicts, and the name does not have to be changed after merging to master. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.