Giter Club home page Giter Club logo

mlops-starter-sklearn's Introduction

  MLOps with Azure Machine Learning

Azure Machine Learning + GitHub を利用した MLOps 実装サンプルコード

MIT licensed Star Open in VSCode


👋 概要

本リポジトリは、MLOps のサンプルコードを素早く利用できることを目的に作成されました。Azure Machine Learning と GitHub Actions を利用する想定です。

🚀 使い方

  • Azure Machine Learning と GitHub の環境を準備します。
  • クライアント環境として下記のいずれかにアクセスします。
    • Azure Machine Learning のコンピューティングインスタンス
    • DevContainer 環境
      • Conda でのパッケージインストールの際にメモリを消費するため、ある程度大きいスペックが必要になります。Codespaces の場合、4-core / 8GB RAM / 32GB storage 以上の Machine Type を選択してください。
  • .env ファイルに環境変数の設定をします。
  • ./scripts フォルダの各シェルスクリプトを実行します。
  • GitHub の Secrets を作成し、GitHub Actions を有効化し実行します。

👉 クライアント環境として Azure Machine Learning のコンピューティングインスタンス (Compute Instance) を利用した場合のコードや CI/CD の実行方法は クイックスタート のドキュメントに記載してあります。

📝 技術条件

  • GitHub
    • ソースコード管理、CI/CD パイプライン
  • Data
  • Azure Machine Learning
    • チーム・組織で共有の機械学習プラットフォーム
    • Compute Instance : CPU タイプ、クライアント端末
      • もしくは Dev Container に対応した GitHub Codespace など
    • Compute Cluster : 共有のクラスター環境
    • API : Azure Machine Learning CLI (v2)
  • IDE/Editor
    • Visual Studio Code

📁 コンテンツ

Assets

CLI v2 + YAML

シナリオ YAML ファイル シェルスクリプト 詳細
Create Data asset cli/assets/create-data.yml scripts/assets/create-data.sh データアセットを作成する
Create Compute Cluster cli/assets/create-compute.yml scripts/assets/create-compute.sh Compute を作成する
Create Environment for training cli/assets/create-environment.yml scripts/assets/create-environment.sh 環境を作成する

Prototyping

Notebook

シナリオ Notebook シェルスクリプト 詳細
Baseline Notebook notebooks/train-prototyping.ipynb scripts/prototyping/run-notebooks.sh 実験用の Notebook

Training

CLI v2 + YAML

シナリオ YAML ファイル シェルスクリプト 詳細
Job for training model cli/jobs/train.yml scripts/training/train.sh Azure ML の Job として Python script を実行

CI/CD Pipeline

シナリオ YAML ファイル Status 詳細
Smoke Test .github/workflows/smoke-testing.yml smoke-testing Smoke Test パイプライン

Operationalizing

CLI v2 + YAML

シナリオ YAML ファイル シェルスクリプト 詳細
Create Batch Endpoint (custom) cli/endpoints/batch_deployment.yml scripts/endpoints/deploy-batch-endpoint.sh カスタム型モデルのバッチエンドポイントへのデプロイ
Create Batch Endpoint (mlflow) cli/endpoints/batch_deployment_mlflow.yml scripts/endpoints/deploy-batch-endpoint.sh MLflow 型モデルのバッチエンドポイントへのデプロイ
Create Online Endpoint (custom) cli/endpoints/online_deployment.yml scripts/endpoints/deploy-online-endpoint-custom.sh カスタム型モデルのオンラインエンドポイントへのデプロイ
Create Online Endpoint (mlflow) cli/endpoints/online_deployment_mlflow.yml scripts/endpoints/deploy-online-endpoint-mlflow.sh MLflow 型モデルのオンラインエンドポイントへのデプロイ

CI/CD Pipeline

TODO

🗒️ ドキュメンテーション

📄 ディレクトリ構造

.
├── .devcontainer   # Configuration files for DevContainer
├── .github
│   └── workflows   # YAML files for GitHub Actions
├── .vscode
├── cli             # YAML files for Azure ML CLI v2
│   ├── assets
│   ├── endpoints
│   └── jobs
├── data            # Sample data
│   ├── raw
│   └── samples
├── docs            # Documenting quickstart, coding style guide etc
├── environments    # Python libraries
├── notebooks       # Jupyter Notebook
├── pipelines       # Azure ML Pipeline CLI v2
│   ├── eval
│   ├── prep
│   ├── score
│   └── train
├── scripts
│   ├── assets      # Shell scripts for creating assets like data, compute, environment
│   ├── endpoints   # Shell scripts for scoring model
│   ├── jobs        # Shell scripts for model training
│   └── prototyping # Shell scripts for experimental
├── src
│   ├── data        # Code for data preparation
│   ├── deploy      # Code for scoring model
│   ├── features    # Code for feature engineering
│   ├── model       # Code for model training
│   ├── monitor     # Code for monitoing data and model
│   └── rai         # Code for responsible ai
├── tests
│   ├── data_validation # Code for validating data
│   └── unit            # Code for unit testing
└── utils           # Code for utilities

関連リポジトリ/リソース

主要なリポジトリ/リソースとの比較

リポジトリ/リソース名 概要と目的 本リポジトリとの差異
microsoft/MLOps MLOps の概要説明から、Microsoft 製品でどのように MLOps を実現するのか Azure DevOps や GitHub Actions、IaCなどのツール単位やシナリオ単位でサンプルコードを提供している。 本リポジトリは、ツールを1シナリオに絞り、迅速的に活用可能な MLOps のテンプレートを提供する。
Azure/mlops-v2 MLOps に関してより広範で抽象的なテンプレート。 本リポジトリは、より具体的なデータ・コードを含み、実行可能なサンプルを目指している。
Azure/azureml-examples AzureML に関してのサンプルコード集。テストコード等が整備されている。 本リポジトリは、単発のサンプルコード群ではなく、ML ライフサイクルの一連の流れが end-to-end で網羅されたものを目指している。
Tutorial: Azure Machine Learning in a day End-to-End で AzureML を学ぶことができるチュートリアルページ。 本リポジトリは、比較対象のリポジトリでは掲載されていない ML システムを設計・運用していくための Tips も提供している。

その他

🛡 免責事項

当社は、外部のリンク先ウェブサイトの内容に関していかなる責任も負うものではありません。お客様は、自らの責任においてこれらのリンクをご利用ください。なお、お客様によるリンクご利用の結果、ないしはリンクご利用に関連して、お客様が被るいかなる損害または損失について当社は、責任を負うものではありません。

🤝 Contributing

We are welcome your contribution from customers and internal microsoft employees. Please see CONTRIBUTING. We appreciate all contributors from Microsoft employees and community to make this repo thrive.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

mlops-starter-sklearn's People

Contributors

hogaku avatar konabuta avatar microsoft-github-operations[bot] avatar microsoftopensource avatar notanaha avatar shohei1029 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mlops-starter-sklearn's Issues

Test issue

please keep this issue open for repo internal testing.

Code Push 時のビルドとテストの自動実行

現状、smoke-testing しか無いので、今後何を追加していくかをこの Issue で議論したいです。

Wiki にも書きましたが、次のパイプラインが必要になると考えています。

  • コード品質の確認
  • Smoke Test
  • Unit Test
  • コンテナーのスキャン
  • 依存関係のスキャン

ファイル名のルールについて : アンダースコア or ハイフン

例えばアンダースコアを使った batch_deployment_mlflow.yml というファイル名がありますが、ハイフンを使ったbatch-deployment-mlflow.yml のファイル名とどちらが良いでしょうか?

どうでも良い気もしますが、何か知見やご意見があれば教えていただけますと幸いです。

Component の登録時の CI/CD

Component の登録は権限があれば簡単にできちゃいますが、それが動くかどうかの検証は別途行う必要があります。Component 登録前に決められた CI/CD をパスするような実装が理想かと思いました。

Smoke Test Fail

@shohei1029 Smoke Test の処理が落ちているようですが、単に現状アップされている Python Script & Jupyter Notebook が black ルールにできていないからですかね?

Custom モデルの Batch Deployment エラー

batch_deployment.yml を実行すると下記のエラーが発生します。同じ事象の方いらっしゃいます?

Error: The yaml file you provided does not match the prescribed schema for BatchDeployment yaml files and/or has the following issues:

1) YAML file cannot be parsed.


Details: 

Failed to submit deployment batch-deployment-1111 due to syntax errors in scoring script score.py.
Error on line 1: import os
If you wish to bypass this validation use --skip-script-validation paramater.

Resolutions:
Double-check your YAML file for syntax and formatting errors. 
If using the CLI, you can also check the full log in debug mode for more details by adding --debug to the end of your command
Additional Resources: The easiest way to author a yaml specification file is using IntelliSense and auto-completion Azure ML VS code extension provides: https://code.visualstudio.com/docs/datascience/azure-machine-learning. To set up VS Code, visit https://docs.microsoft.com/azure/machine-learning/how-to-setup-vs-code

リポジトリ立ち位置の明記

本リポジトリの位置づけ、他のリポジトリとの違いをwiki等に明記してもいいかもしれません。我々や他のcontributor間で認識差異なくcontributeしやすくなると思います。

例えば、下記リポジトリとの違いについて、私の認識は下記の形なのですが、他の人と同じ認識か分からないので、明確化できるとより良いのではと思っています。

  • https://github.com/Azure/mlops-v2
    MLOpsに関してより広範で抽象的なテンプレート。我々のリポジトリはより具体的なデータ・コードを含み、実行可能なサンプルを目指している。

  • https://github.com/Azure/azureml-examples
    AzureMLに関してのサンプルコード集。テストコード等は整備されている。我々のリポジトリは単発のサンプルコード群ではなく、end-to-endでシナリオが網羅されたものを目指している。

  • Tutorial: Get started with a Python script (SDK v2) - Azure Machine Learning | Microsoft Learn (Azure ML in a day)
    end-to-endなサンプルであるが現時点ではカバー範囲が広くない。またテスト/セキュリティ/コードフォーマット/CICD等々が整備されたリポジトリとは言えない。

AzureML 対象クライアントの明確化

対象となるAzureML クライアントを明記するのはいかがでしょうか?ReadmeかWikiあたりでしょうか。

① v1 or v2
例えば、現在のdata prepのサンプル.py等はSDK v1を使っていますが、今回はv2でしかサポートしていないサービス類 (endpoint等)を対象とするかと思うので、v2に統一した方が望ましいと感じています。

② CLI/SDK/(REST/SDK)
同じことをやるにもいくつかクライアントが使えるかと思います。理想的には全クライアント、あるいは少なくともCLI/SDKの両クライアントを網羅することだと思うのですが、一旦優先順位としてどのクライアントの実装を優先するか明記されていると助かります。

Branch protectionの導入 (ブランチ戦略について)

Branch protection の導入はいかがですか?
例えば、最低一人のレビュアー approveがないとmergeできない、等です。
devブランチでは必要ないかもしれませんが、main等の将来的な話も含め、ここに議論場所を作っておきたく思います。

image

https://docs.github.com/ja/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/managing-a-branch-protection-rule

パッケージ管理の実装

yaml の定義ファイル + conda のアップデートコマンドを使うスタイル

poetry カーネルは AML 上で動作せず

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.