MLOps

MLOps E2E - 1. CI / CD : Github Actions

Hongma 2022. 4. 26. 20:20

 

 

kubeflow 예제들을 다양하게 시도해봐도 잘 되지 않고, 또 복잡하기에 처음부터 차근차근 시작해보기로 했다.

물론 가장 문제는 kubernetes에 대한 이해가 많이 부족한 것이지만, 이번에 kubeflow 환경에서 machine learning project를 end to end로 만들어 보면서 kubernetes에 대한 내용 또한 차근차근 익힐 수 있는 기회가 되었으면 좋겠다.

 

가장 먼저 Github Actions을 만들어 보았다.

 

Github Actions를 사용하는 단계는 다음과 같다.

1. Git Repository 생성

2. ./.github/workflows 폴더 생성

3. workflows 폴더 안에 원하는 기능들에 대한 yaml 파일 생성

 

필자는 가장 기본적으로 push를 할 때마다 super linter를 통해 black, flake8, json, yaml 파일의 품질을 검사하도록 하였고,

추가적으로 codecoverage를 사용해서 readme에 추가하도록 하였다.

 

lint.yml  (super linter)

name: Lint Code Base

on: push  # push일 때 작동

jobs:
  # Set the job key. The key is displayed as the job name
  # when a job name is not provided
  super-lint:
    # Name the Job
    name: Lint Code Base
    # Set the type of machine to run on
    runs-on: ubuntu-latest

    env:
      OS: ${{ matrix.os }}
      PYTHON: '3.7'

    steps:
      # Checks out a copy of your repository on the ubuntu-latest machine
      - name: Checkout code
        uses: actions/checkout@v2

      # Runs the Super-Linter action
      - name: Lint Code Base
        uses: github/super-linter@v4
        env:
          DEFAULT_BRANCH: master
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          VALIDATE_PYTHON_BLACK: true
          VALIDATE_PYTHON_FLAKE8: true
          VALIDATE_JSON: true
          VALIDATE_YAML: true

 

 

codecov.yml  (code coverage)

name: Example workflow for Codecov
on: [push]
jobs:
  run:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
    env:
      OS: ${{ matrix.os }}
      PYTHON: '3.7'
    steps:
    - uses: actions/checkout@master
    - name: Setup Python
      uses: actions/setup-python@master
      with:
        python-version: 3.7
    - name: Generate coverage report
      run: |
        pip install pytest
        pip install pytest-cov
        pytest --cov=./ --cov-report=xml
    - name: Upload coverage to Codecov
      uses: codecov/codecov-action@v3.1.0

 

 

 

 

'MLOps' 카테고리의 다른 글

MLOps E2E - 5. Storage : minio  (0) 2022.05.10
MLOps E2E - 4. Logging : wandb  (0) 2022.05.04
MLOps E2E - 3. Pipeline  (0) 2022.04.29
MLOps E2E - 2-2. CT : Training (kubeflow pipeline)  (0) 2022.04.28
MLOps E2E - 2-1. CT : Data Load (kubeflow pipeline)  (0) 2022.04.27