diff --git a/Project_One-Tests/test_ml_metrics.py b/Project_One-Tests/test_ml_metrics.py new file mode 100644 index 0000000..5804523 --- /dev/null +++ b/Project_One-Tests/test_ml_metrics.py @@ -0,0 +1,29 @@ +import sys +import os +import pytest +sys.path.append("../azureml-app/") #append path for 1 module level up. +from inference_code.model_class import MyModel +from sklearn.metrics.regression import r2_score + +class TestMLMetrics(object): + """ + testing of the model + """ + def setUp(self): + pass + + def test_r2_within_business_value(self): + m = MyModel() + m.init() + + # Add code to load your super secret cross validation stuff + # use secrets encoded in a variable group available in the ADO Pipeline + # cuz scientists can't access that and game the system. + super_secret_data = None + + y_predicted = m.predict(super_secret_data[x]) + + r2_score(super_secret_data[y], y_predicted) + + assert(r2_score > 2 < r2_score) + diff --git a/Project_One-Tests/test_model.py b/Project_One-Tests/test_model.py index 49b86c5..13b13c7 100644 --- a/Project_One-Tests/test_model.py +++ b/Project_One-Tests/test_model.py @@ -15,3 +15,6 @@ def test_init(self): m = MyModel() m.init() assert(m.x_scaler is not None) + assert(m.y_scaler is not None) + assert(m.model is not None) + diff --git a/README.md b/README.md index d712cff..03564a3 100644 --- a/README.md +++ b/README.md @@ -542,4 +542,74 @@ Output from the pipeline should resemble the following: ![alt text](./readme_images/ado_output_successful_build.png) +## Defining your Release Pipeline + +While release pipelines are often used to deliver artifacts in a deployed state, our scenario calls for an different approach. Our build artifact is an image that contains our tested model and we will be creating a Two Stage Release that will first deliver the correct image to aQA environment where it can be picked up and be tested by a product team. Once all conditions for the product team is satisfied a release manager will manually approve the Production release step and the model will become available for consumption in the Production Environment. +Creating Variable Groups Required for the Release Pipeline +1. Click on the Library menu item in the Azure DevOps portal and click + +![alt text](./readme_images/ado_rp_add_variable_group.png) + +2. Complete the resulting form as depicted below, making sure that you provide values to the variables that correspond to the Targeted QA Environment + +![alt text](./readme_images/ado_rp_qa_variable_form.png) + +3. After each Variable Value has been assigned click the to encrypt its value in the pipeline. +4. Repeat Steps 2 and 3 above to set up a variable group for the targeted Production Environment. +### Create the Release Pipeline +1. In the Azure DevOps portal Click on Pipelines -> Releases in the left menu + +![alt text](./readme_images/ado_rp_rp_button_click.png) + +2. Click The New pipeline menu item and select New release pipeline + +![alt text](./readme_images/ado_rp_new_rp.png) + +3. Add Two Stages, Named QA and Production Respectively ensuring that you select the “Empty Template”. Click on the Pre-deployment condition icon and continue to configure as depicted below. This will prevent the Production deployment from happening automatically unless there is an Approval provided by One or all of the Approvers (dependent on configuration) and that the Production Stage Deployment will timeout after two days with out an approval. + +![alt text](./readme_images/ado_rp_gated_prod.png) + +4. Add the build artifacts and link the release pipeline to its associated build pipeline. + +![alt text](./readme_images/ado_rp_add_build_artifacts.png) + +Note: The value in the Source alias text area will be required to correctly configure the AZ CLI tasks in Steps 6 and 7 below. +  + +5. In the Menu area select variables and link the QA and Production variable to the relevant slots. + +![alt text](./readme_images/ado_rp_link_variable_groups.png) + +6. Add a CLI Task to the QA Stage and configure it as follows : + +![alt text](./readme_images/ado_rp_qa_cli_1.png) + +![alt text](./readme_images/ado_rp_qa_cli_2.png) + +** Make sure that the working directory set above reflects the generated path correct path here +$(System.DefaultWorkingDirectory)//PipelineArtifacts + +7. Repeat Step 6 above for the Production Stage . + +Note that the script internals are identical for both stages but will target different destination repositories based on the Variables groups assigned to each of the stages. + +![alt text](./readme_images/ado_rp_prod_cli_reveal.png) + +8. Run a release and inspect the results +9. To automate the release process click the Continuous Integration Trigger of the Build Artifact and set as follows. + +![alt text](./readme_images/ado_rp_automate_rp.png) + +![alt text](./readme_images/ado_rp_automate_rp_2.png) + +10. Finally click on the Pre-Release Condition for the QA Stage and set as follows. + +![alt text](./readme_images/ado_rp_qa_prerelease_condition.png) + +11. A successful release will resemble the following + +![alt text](./readme_images/ado_rp_success_1.png) + +![alt text](./readme_images/ado_rp_success_2.png) + diff --git a/readme_images/ado_rp_add_build_artifacts.png b/readme_images/ado_rp_add_build_artifacts.png new file mode 100644 index 0000000..8895a71 Binary files /dev/null and b/readme_images/ado_rp_add_build_artifacts.png differ diff --git a/readme_images/ado_rp_add_variable_group.png b/readme_images/ado_rp_add_variable_group.png new file mode 100644 index 0000000..cf1e7ae Binary files /dev/null and b/readme_images/ado_rp_add_variable_group.png differ diff --git a/readme_images/ado_rp_automate_rp.png b/readme_images/ado_rp_automate_rp.png new file mode 100644 index 0000000..f93b3c1 Binary files /dev/null and b/readme_images/ado_rp_automate_rp.png differ diff --git a/readme_images/ado_rp_automate_rp_2.png b/readme_images/ado_rp_automate_rp_2.png new file mode 100644 index 0000000..e84a9f9 Binary files /dev/null and b/readme_images/ado_rp_automate_rp_2.png differ diff --git a/readme_images/ado_rp_gated_prod.png b/readme_images/ado_rp_gated_prod.png new file mode 100644 index 0000000..f03fbe0 Binary files /dev/null and b/readme_images/ado_rp_gated_prod.png differ diff --git a/readme_images/ado_rp_link_variable_groups.png b/readme_images/ado_rp_link_variable_groups.png new file mode 100644 index 0000000..88c8f24 Binary files /dev/null and b/readme_images/ado_rp_link_variable_groups.png differ diff --git a/readme_images/ado_rp_new_rp.png b/readme_images/ado_rp_new_rp.png new file mode 100644 index 0000000..a660c4f Binary files /dev/null and b/readme_images/ado_rp_new_rp.png differ diff --git a/readme_images/ado_rp_prod_cli_reveal.png b/readme_images/ado_rp_prod_cli_reveal.png new file mode 100644 index 0000000..63c9468 Binary files /dev/null and b/readme_images/ado_rp_prod_cli_reveal.png differ diff --git a/readme_images/ado_rp_qa_cli_1.png b/readme_images/ado_rp_qa_cli_1.png new file mode 100644 index 0000000..706c20d Binary files /dev/null and b/readme_images/ado_rp_qa_cli_1.png differ diff --git a/readme_images/ado_rp_qa_cli_2.png b/readme_images/ado_rp_qa_cli_2.png new file mode 100644 index 0000000..1774c4e Binary files /dev/null and b/readme_images/ado_rp_qa_cli_2.png differ diff --git a/readme_images/ado_rp_qa_prerelease_condition.png b/readme_images/ado_rp_qa_prerelease_condition.png new file mode 100644 index 0000000..137a8ce Binary files /dev/null and b/readme_images/ado_rp_qa_prerelease_condition.png differ diff --git a/readme_images/ado_rp_qa_variable_form.png b/readme_images/ado_rp_qa_variable_form.png new file mode 100644 index 0000000..312d192 Binary files /dev/null and b/readme_images/ado_rp_qa_variable_form.png differ diff --git a/readme_images/ado_rp_rp_button_click.png b/readme_images/ado_rp_rp_button_click.png new file mode 100644 index 0000000..b7b2e7b Binary files /dev/null and b/readme_images/ado_rp_rp_button_click.png differ diff --git a/readme_images/ado_rp_success_1.png b/readme_images/ado_rp_success_1.png new file mode 100644 index 0000000..39c551b Binary files /dev/null and b/readme_images/ado_rp_success_1.png differ diff --git a/readme_images/ado_rp_success_2.png b/readme_images/ado_rp_success_2.png new file mode 100644 index 0000000..16ea13c Binary files /dev/null and b/readme_images/ado_rp_success_2.png differ