# master1039/azure-mlopspython architecture

> Architecture diagram of the GitHub repository master1039/azure-mlopspython, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/master1039/azure-mlopspython
- Repository: https://github.com/master1039/azure-mlopspython

## Overview

##### Project Type & Purpose
- This is an MLOps reference implementation that demonstrates how to build a full end-to-end CI/CD pipeline for a machine-learning workflow using Azure DevOps and Azure Machine Learning.
- Key goals:
- Automate data validation, model training (Python & R), model evaluation and selection.
- Automate model registration and versioning in Azure ML.
- Automate real-time deployment (ACI/AKS) with canary and A/B testing via Helm and Istio.
- Use Infrastructure as Code (ARM/Terraform) for environment provisioning.

##### File-Structure Analysis & Architectural Patterns
- Top level:
- **.pipelines**: YAML templates for CI/CD pipelines in Azure DevOps (build, test, train, publish, deploy).
- **environment_setup** & **bootstrap**: IaC scripts (ARM, Terraform) and bootstrap scripts to provision Azure resources, Container Registry, Compute, Workspace.
- **charts**: Helm charts for deploying model services (Istio canary, A/B testing).
- **data**: Sample diabetes CSV files and data-validation tests.
- **diabetes_regression**: Core ML project: training code (Python/R), evaluation, registration, scoring scripts & configs (ACI/AKS deployment YAMLs).
- **ml_service**: Python SDK wrappers that orchestrate Azure ML Pipelines from DevOps tasks.

- Architectural patterns:
- **CI/CD pipeline**: Separation of build (lint, data tests, unit tests), train (AML pipeline submission), package/deploy (Docker image build, Helm).
- **AML Pipeline**: Modular steps—data validation → training → evaluation → registration → batch scoring.
- **Micro-services**: Real-time inference as containerized services on ACI/AKS.
- **Canary/A-B**: Service mesh (Istio) layered on Kubernetes for traffic splitting.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Swimlanes
    subgraph "Environment Provisioning" 
        direction TB
        IaC["Infrastructure as Code (ARM/Terraform)"]:::infra
        Bootstrap["Bootstrap Scripts"]:::infra
    end

    subgraph "Developer & Code Repo"
        direction TB
        Dev["Developer Environment"]:::dev
        GitRepo["Git Repository"]:::dev
        Notebooks["Experimentation Notebooks"]:::note
    end

    subgraph "CI/CD Pipelines"
        direction TB
        DevOpsBuild["Azure DevOps Build Pipeline"]:::pipelines
        DevOpsRelease["Azure DevOps Release Pipeline"]:::pipelines
    end

    subgraph "Azure Machine Learning"
        direction TB
        AMLWorkspace["Azure ML Workspace"]:::azure
        AMLPipeline["AML Pipeline: train & register"]:::azure
        ModelRegistry["Model Registry"]:::azure
        DataStorage["Blob Storage"]:::storage
        ComputeTrain["Compute Targets (Training)"]:::compute
        ComputeBatch["Compute Targets (Batch Scoring)"]:::compute
    end

    subgraph "Container & Orchestration"
        direction TB
        ACR["Azure Container Registry"]:::storage
        AKSIstio["Kubernetes + Istio (ACI/AKS)"]:::k8s
    end

    %% Relationships
    Dev -->|push code| GitRepo
    GitRepo -->|trigger| DevOpsBuild
    DevOpsBuild -->|run tests & lint| DataStorage
    DevOpsBuild -->|submit| AMLPipeline
    AMLPipeline -->|reads/writes| DataStorage
    AMLPipeline -->|uses| ComputeTrain
    AMLPipeline -->|registers| ModelRegistry
    ModelRegistry -->|new model| DevOpsRelease
    DevOpsRelease -->|build & push image| ACR
    DevOpsRelease -->|deploy via Helm| AKSIstio
    AKSIstio -->|canary/A-B testing| AKSIstio
    DevOpsBuild -->|trigger batch| ComputeBatch
    ComputeBatch -->|reads| DataStorage

    %% Links to IaC
    IaC --> DevOpsBuild
    Bootstrap --> DevOpsBuild

    %% Developer Lane
    Dev --> Notebooks
    Notebooks -. optional .-> DevOpsBuild

    %% Click Events
    click IaC "https://github.com/master1039/azure-mlopspython/tree/master/environment_setup/"
    click Bootstrap "https://github.com/master1039/azure-mlopspython/tree/master/bootstrap/"
    click DevOpsBuild "https://github.com/master1039/azure-mlopspython/tree/master/.pipelines/"
    click DevOpsRelease "https://github.com/master1039/azure-mlopspython/tree/master/.pipelines/"
    click Notebooks "https://github.com/master1039/azure-mlopspython/tree/master/experimentation/"
    click DataStorage "https://github.com/master1039/azure-mlopspython/tree/master/data/"
    click ACR "https://github.com/master1039/azure-mlopspython/tree/master/charts/"
    click AKSIstio "https://github.com/master1039/azure-mlopspython/tree/master/charts/abtest-istio/"
    click AKSIstio "https://github.com/master1039/azure-mlopspython/tree/master/charts/abtest-model/"
    click AKSIstio "https://github.com/master1039/azure-mlopspython/blob/master/charts/load_test.sh"
    click ComputeTrain "https://github.com/master1039/azure-mlopspython/tree/master/diabetes_regression/training/"
    click ComputeBatch "https://github.com/master1039/azure-mlopspython/tree/master/diabetes_regression/scoring/"
    click ModelRegistry "https://github.com/master1039/azure-mlopspython/blob/master/diabetes_regression/register/register_model.py"
    click AMLPipeline "https://github.com/master1039/azure-mlopspython/blob/master/ml_service/pipelines/diabetes_regression_build_train_pipeline.py"
    click AMLPipeline "https://github.com/master1039/azure-mlopspython/blob/master/ml_service/pipelines/diabetes_regression_build_parallel_batchscore_pipeline.py"
    click Dev "https://github.com/master1039/azure-mlopspython/blob/master/ml_service/util/smoke_test_scoring_service.py"

    %% Styles
    classDef infra fill:#FFF4E6,stroke:#FF8000,stroke-width:2px
    classDef dev fill:#FFFBE6,stroke:#FFD700,stroke-width:2px
    classDef pipelines fill:#E6FFEA,stroke:#00A800,stroke-width:2px
    classDef azure fill:#E6F0FF,stroke:#0050A0,stroke-width:2px
    classDef storage fill:#E6FFFC,stroke:#008080,stroke-width:2px
    classDef compute fill:#FFF2E6,stroke:#FF8C00,stroke-width:2px
    classDef k8s fill:#F3E6FF,stroke:#8000A8,stroke-width:2px
    classDef note fill:#FFFFE6,stroke:#A8A800,stroke-width:2px
```
