2 |
3 |
4 |
5 | MLOps with Azure Machine Learning
6 |
7 | Azure Machine Learning + GitHub を利用した MLOps 実装サンプルコード
8 |
9 | [](LICENSE)
10 | [](https://github.com/Azure/mlops-starter-sklearn/graphs/contributors)
11 | [](https://github.com/Azure/mlops-starter-sklearn)
12 | [](https://open.vscode.dev/Azure/mlops-starter-sklearn)
13 |
14 |
15 |
16 | ---
17 |
18 | ## 👋 概要
19 | 本リポジトリは、MLOps のサンプルコードを素早く利用できることを目的に作成されました。Azure Machine Learning と GitHub Actions を利用する想定です。
20 |
21 |
22 | ## 🚀 使い方
23 | - Azure Machine Learning と GitHub の環境を準備します。
24 | - クライアント環境として下記のいずれかにアクセスします。
25 | - Azure Machine Learning のコンピューティングインスタンス
26 | - DevContainer 環境
27 | - Conda でのパッケージインストールの際にメモリを消費するため、ある程度大きいスペックが必要になります。Codespaces の場合、4-core / 8GB RAM / 32GB storage 以上の Machine Type を選択してください。
28 | - .env ファイルに環境変数の設定をします。
29 | - [./scripts](./scripts) フォルダの各シェルスクリプトを実行します。
30 | - GitHub の Secrets を作成し、GitHub Actions を有効化し実行します。
31 |
32 | :point_right: **クライアント環境として Azure Machine Learning のコンピューティングインスタンス (Compute Instance) を利用した場合のコードや CI/CD の実行方法は [クイックスタート](./docs/quickstart.md) のドキュメントに記載してあります。**
33 |
34 |
35 | ## 📝 技術条件
36 | - GitHub
37 | - ソースコード管理、CI/CD パイプライン
38 | - Data
39 | - [NYC タクシー & リムジン協会 - グリーンタクシー運行記録](https://learn.microsoft.com/ja-jp/azure/open-datasets/dataset-taxi-green?tabs=azureml-opendatasets)
40 | - Azure Machine Learning
41 | - チーム・組織で共有の機械学習プラットフォーム
42 | - Compute Instance : CPU タイプ、クライアント端末
43 | - もしくは Dev Container に対応した GitHub Codespace など
44 | - Compute Cluster : 共有のクラスター環境
45 | - API : Azure Machine Learning CLI (v2)
46 | - IDE/Editor
47 | - Visual Studio Code
48 |
49 | ## 📁 コンテンツ
50 | ### Assets
51 | **CLI v2 + YAML**
52 |
53 | |シナリオ |YAML ファイル|シェルスクリプト|詳細 |
54 | |--------------------|---------|-----------|-----------|
55 | |Create Data asset |[cli/assets/create-data.yml](cli/assets/create-data.yml)|[scripts/assets/create-data.sh](scripts/assets/create-data.sh)|データアセットを作成する|
56 | |Create Compute Cluster|[cli/assets/create-compute.yml](cli/assets/create-compute.yml)|[scripts/assets/create-compute.sh](scripts/assets/create-compute.sh)|Compute を作成する|
57 | |Create Environment for training|[cli/assets/create-environment.yml](cli/assets/create-environment.yml)|[scripts/assets/create-environment.sh](scripts/assets/create-environment.sh)|環境を作成する|
58 |
59 | ### Prototyping
60 | **Notebook**
61 |
62 | |シナリオ |Notebook|シェルスクリプト|詳細 |
63 | |--------------------|---------|-----------|-----------|
64 | |Baseline Notebook |[notebooks/train-prototyping.ipynb](notebooks/train-prototyping.ipynb)|[scripts/prototyping/run-notebooks.sh](scripts/prototyping/run-notebooks.sh)|実験用の Notebook|
65 |
66 |
67 | ### Training
68 | **CLI v2 + YAML**
69 |
70 | |シナリオ |YAML ファイル|シェルスクリプト|詳細 |
71 | |--------------------|---------|-----------|-----------|
72 | |Job for training model |[cli/jobs/train.yml](cli/jobs/train.yml) |[scripts/training/train.sh](scripts/training/train.sh)| Azure ML の Job として Python script を実行 |
73 |
74 |
75 | **CI/CD Pipeline**
76 | |シナリオ |YAML ファイル|Status |詳細 |
77 | |--------------------|---------|-----------|-----------|
78 | |Smoke Test |[.github/workflows/smoke-testing.yml](.github/workflows/smoke-testing.yml)|[](https://github.com/Azure/MLInsider-MLOps/actions/workflows/smoke-testing.yml)|Smoke Test パイプライン|
79 |
80 |
81 | ### Operationalizing
82 | **CLI v2 + YAML**
83 |
84 | |シナリオ |YAML ファイル |シェルスクリプト|詳細 |
85 | |----------------------------------|---------|-----------|-----------|
86 | |Create Batch Endpoint (custom) |[cli/endpoints/batch_deployment.yml](cli/endpoints/batch_deployment.yml)|[scripts/endpoints/deploy-batch-endpoint.sh](scripts/endpoints/deploy-batch-endpoint-custom.sh) |カスタム型モデルのバッチエンドポイントへのデプロイ|
87 | |Create Batch Endpoint (mlflow) |[cli/endpoints/batch_deployment_mlflow.yml](cli/endpoints/batch_deployment_mlflow.yml)|[scripts/endpoints/deploy-batch-endpoint.sh](scripts/endpoints/deploy-batch-endpoint-mlflow.sh)|MLflow 型モデルのバッチエンドポイントへのデプロイ|
88 | |Create Online Endpoint (custom) |[cli/endpoints/online_deployment.yml](cli/endpoints/online_deployment.yml)|[scripts/endpoints/deploy-online-endpoint-custom.sh](scripts/endpoints/deploy-online-endpoint-custom.sh)|カスタム型モデルのオンラインエンドポイントへのデプロイ|
89 | |Create Online Endpoint (mlflow) |[cli/endpoints/online_deployment_mlflow.yml](cli/endpoints/online_deployment_mlflow.yml)|[scripts/endpoints/deploy-online-endpoint-mlflow.sh](scripts/endpoints/deploy-online-endpoint-mlflow.sh)|MLflow 型モデルのオンラインエンドポイントへのデプロイ|
90 |
91 |
92 | ### CI/CD Pipeline
93 |
94 | >TODO
95 |
96 | ## 🗒️ ドキュメンテーション
97 | - [クイックスタート](./docs/quickstart.md)
98 | - [Coding Guideline](./docs/coding-guidelines.md)
99 |
100 | ## 📄 ディレクトリ構造
101 |
102 | ```
103 | .
104 | ├── .devcontainer # Configuration files for DevContainer
105 | ├── .github
106 | │ └── workflows # YAML files for GitHub Actions
107 | ├── .vscode
108 | ├── cli # YAML files for Azure ML CLI v2
109 | │ ├── assets
110 | │ ├── endpoints
111 | │ └── jobs
112 | ├── data # Sample data
113 | │ ├── raw
114 | │ └── samples
115 | ├── docs # Documenting quickstart, coding style guide etc
116 | ├── environments # Python libraries
117 | ├── notebooks # Jupyter Notebook
118 | ├── pipelines # Azure ML Pipeline CLI v2
119 | │ ├── eval
120 | │ ├── prep
121 | │ ├── score
122 | │ └── train
123 | ├── scripts
124 | │ ├── assets # Shell scripts for creating assets like data, compute, environment
125 | │ ├── endpoints # Shell scripts for scoring model
126 | │ ├── jobs # Shell scripts for model training
127 | │ └── prototyping # Shell scripts for experimental
128 | ├── src
129 | │ ├── data # Code for data preparation
130 | │ ├── deploy # Code for scoring model
131 | │ ├── features # Code for feature engineering
132 | │ ├── model # Code for model training
133 | │ ├── monitor # Code for monitoing data and model
134 | │ └── rai # Code for responsible ai
135 | ├── tests
136 | │ ├── data_validation # Code for validating data
137 | │ └── unit # Code for unit testing
138 | └── utils # Code for utilities
139 | ```
140 |
141 | ---
142 |
143 | ## 関連リポジトリ/リソース
144 |
145 | ### 主要なリポジトリ/リソースとの比較
146 | | リポジトリ/リソース名 | 概要と目的 | 本リポジトリとの差異 |
147 | | --- | --- | --- |
148 | | [microsoft/MLOps](https://github.com/microsoft/MLOps) | MLOps の概要説明から、Microsoft 製品でどのように MLOps を実現するのか Azure DevOps や GitHub Actions、IaCなどのツール単位やシナリオ単位でサンプルコードを提供している。 | 本リポジトリは、ツールを1シナリオに絞り、迅速的に活用可能な MLOps のテンプレートを提供する。|
149 | | [Azure/mlops-v2](https://github.com/Azure/mlops-v2) | MLOps に関してより広範で抽象的なテンプレート。 | 本リポジトリは、より具体的なデータ・コードを含み、実行可能なサンプルを目指している。|
150 | | [Azure/azureml-examples](https://github.com/Azure/azureml-examples) | AzureML に関してのサンプルコード集。テストコード等が整備されている。 | 本リポジトリは、単発のサンプルコード群ではなく、ML ライフサイクルの一連の流れが end-to-end で網羅されたものを目指している。|
151 | | [Tutorial: Azure Machine Learning in a day](https://learn.microsoft.com/en-us/azure/machine-learning/tutorial-azure-ml-in-a-day) | End-to-End で AzureML を学ぶことができるチュートリアルページ。 | 本リポジトリは、比較対象のリポジトリでは掲載されていない ML システムを設計・運用していくための Tips も提供している。|
152 |
153 | ### その他
154 | - https://github.com/dslp/dslp-repo-template
155 |
156 | ## 🛡 免責事項
157 | 当社は、外部のリンク先ウェブサイトの内容に関していかなる責任も負うものではありません。お客様は、自らの責任においてこれらのリンクをご利用ください。なお、お客様によるリンクご利用の結果、ないしはリンクご利用に関連して、お客様が被るいかなる損害または損失について当社は、責任を負うものではありません。
158 |
159 | ## 🤝 Contributing
160 | We are welcome your contribution from customers and internal microsoft employees. Please see [CONTRIBUTING](./CONTRIBUTING.md). We appreciate all contributors from Microsoft employees and community to make this repo thrive.
161 |
162 |
163 |