Repository कोड चलाना

Machine Learning के लिए CI/CD

Ravi Bhadauria

Machine Learning Engineer

Shared repository मॉडल

  • कई सहयोगी एक ही repository पर काम करते हैं
  • संबंधित काम के लिए Feature/Topic ब्रांच बनाई जाती हैं
    • Pull request खोले जाते हैं
    • कोड की समीक्षा होती है और बदलाव सुझाए जाते हैं
    • ब्रांच कोड main ब्रांच में merge होता है
  • CI/CD checks को सक्षम करने से कोड गुणवत्ता बेहतर होती है

शेयर्ड repository मॉडल की छवि जहाँ कई डेवलपर एक ही repository में योगदान दे रहे हैं

Machine Learning के लिए CI/CD

Feature ब्रांच बनाएँ

लैंडिंग पेज की छवि जिसमें Branch टैब हाइलाइट है

Branch पेज की छवि जिसमें New branch टैब हाइलाइट है

Machine Learning के लिए CI/CD

Feature ब्रांच बनाएँ

Repository लैंडिंग पेज की छवि जिसमें सक्रिय Feature ब्रांच दिख रही है

Machine Learning के लिए CI/CD

Repository कोड जोड़ें

ब्रांच में hello_world.py के रूप में सेव करें

import datetime

def main():
    print("Hello, World!")

    # Get the current time and print it
    current_time = datetime.datetime.now()
    print("Current time:", current_time)

if __name__ == "__main__":
    main()
Machine Learning के लिए CI/CD

Workflow इवेंट कॉन्फ़िगर करें

  • Pull request इवेंट के लिए target ब्रांच निर्दिष्ट करें
on:
  pull_request:
    branches: [ "main" ]
Machine Learning के लिए CI/CD

Actions सिंटैक्स

steps:
  - name: My Action 
    uses: <org_or_user_name>/<reponame>@<version_number>
    with:
      action-argument: value
Machine Learning के लिए CI/CD

Workflow steps और actions कॉन्फ़िगर करें

  • जॉब स्टेप में repository checkout करना
steps:
  - name: Checkout 
    uses: actions/checkout@v3
  • Python environment सेटअप करना
steps:
  - name: Setup Python
    uses: actions/setup-python@v4
    with:
      python-version: 3.9
Machine Learning के लिए CI/CD

सबको साथ जोड़ें

  • Workflow, main पर pull request पर trigger होता है
  • build जॉब में तीन steps हैं
    • Checkout repository checkout करता है
    • Setup Python Python environment सेटअप करता है
    • Run Python script Python फ़ाइल चलाता है
name: PR

on:
  pull_request:
    branches: [ "main" ]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Setup Python
        uses: actions/setup-python@v4
        with:
          python-version: 3.9
      - name: Run Python script
        run: |
          echo hello_world.py 
          python hello_world.py
Machine Learning के लिए CI/CD

PR बनाएँ और workflow ट्रिगर करें

Pull request पेज की छवि जिसमें चल रहा workflow दिख रहा है

Machine Learning के लिए CI/CD

Workflow logs देखें

Workflow logs पेज की छवि जिसमें Python script स्टेप अन्य steps के साथ दिख रहा है

Machine Learning के लिए CI/CD

अभ्यास करते हैं!

Machine Learning के लिए CI/CD

Preparing Video For Download...