pytorch-lightning

Форк
0
175 строк · 6.7 Кб
1
name: Test App
2

3
# see: https://help.github.com/en/actions/reference/events-that-trigger-workflows
4
on:
5
  push:
6
    branches: [master, "release/*"]
7
  pull_request:
8
    branches: [master, "release/*"]
9
    types: [opened, reopened, ready_for_review, synchronize] # added `ready_for_review` since draft is skipped
10
    paths:
11
      - ".actions/*"
12
      - ".github/workflows/ci-tests-app.yml"
13
      - "requirements/ci.txt"
14
      - "src/lightning/app/**"
15
      - "src/lightning_app/*"
16
      - "tests/tests_app/**"
17
      - "requirements/app/**"
18
      - "setup.py"
19
      - "!requirements/*/docs.txt"
20
      - "!*.md"
21
      - "!**/*.md"
22
  schedule:
23
    # At the end of every day
24
    - cron: "0 0 * * *"
25

26
concurrency:
27
  group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }}
28
  cancel-in-progress: ${{ github.event_name == 'pull_request' }}
29

30
defaults:
31
  run:
32
    shell: bash
33

34
jobs:
35
  app-pytest:
36
    if: github.event.pull_request.draft == false
37
    runs-on: ${{ matrix.os }}
38
    strategy:
39
      fail-fast: false
40
      matrix:
41
        os: ["ubuntu-20.04", "macOS-11", "windows-2022"]
42
        pkg-name: ["lightning"]
43
        python-version: ["3.8"]
44
        requires: ["oldest", "latest"]
45
        include:
46
          # only run Python latest, use App scope to limit dependency issues
47
          - { os: "macOS-12", pkg-name: "app", python-version: "3.11", requires: "latest" }
48
          - { os: "ubuntu-22.04", pkg-name: "app", python-version: "3.11", requires: "latest" }
49
          - { os: "windows-2022", pkg-name: "app", python-version: "3.11", requires: "latest" }
50
          # "app" installs the standalone package
51
          - { os: "macOS-11", pkg-name: "app", python-version: "3.9", requires: "latest" }
52
          - { os: "ubuntu-20.04", pkg-name: "app", python-version: "3.9", requires: "latest" }
53
          - { os: "windows-2022", pkg-name: "app", python-version: "3.8", requires: "latest" }
54
    # Timeout: https://stackoverflow.com/a/59076067/4521646
55
    timeout-minutes: 55
56
    env:
57
      PACKAGE_NAME: ${{ matrix.pkg-name }}
58
      FREEZE_REQUIREMENTS: ${{ ! (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/')) }}
59
      PYPI_CACHE_DIR: "_pip-wheels"
60
      TORCH_URL: "https://download.pytorch.org/whl/cpu/torch_stable.html"
61
    steps:
62
      - uses: actions/checkout@v4
63
      - name: Set up Python ${{ matrix.python-version }}
64
        uses: actions/setup-python@v5
65
        with:
66
          python-version: ${{ matrix.python-version }}
67

68
      - name: basic setup
69
        run: pip install -q -r .actions/requirements.txt
70

71
      - name: Set min. dependencies
72
        if: ${{ matrix.requires == 'oldest' }}
73
        run: python .actions/assistant.py replace_oldest_ver
74

75
      - name: pip wheels cache
76
        uses: actions/cache/restore@v4
77
        with:
78
          path: ${{ env.PYPI_CACHE_DIR }}
79
          key: pypi_wheels
80
      - name: List restored pkgs
81
        run: |
82
          mkdir -p $PYPI_CACHE_DIR
83
          ls -lh $PYPI_CACHE_DIR
84

85
      - name: Env. variables
86
        run: |
87
          # Switch coverage scope
88
          python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.pkg-name}}' == 'lightning' else 'pytorch_lightning'))" >> $GITHUB_ENV
89
          # if you install mono-package set dependency only for this subpackage
90
          python -c "print('EXTRA_PREFIX=' + str('' if '${{matrix.pkg-name}}' != 'lightning' else 'app-'))" >> $GITHUB_ENV
91

92
      - name: Install package & dependencies
93
        timeout-minutes: 20
94
        run: |
95
          pip install -e ".[${EXTRA_PREFIX}dev]" -U --prefer-binary \
96
            --find-links="${TORCH_URL}" --find-links="${PYPI_CACHE_DIR}"
97
          pip list
98
      - name: Dump handy wheels
99
        if: github.event_name == 'push' && github.ref == 'refs/heads/master'
100
        continue-on-error: true
101
        uses: ./.github/actions/pip-wheels
102
        with:
103
          wheel-dir: ${{ env.PYPI_CACHE_DIR }}
104
          torch-url: ${{ env.TORCH_URL }}
105
          cache-key: "pypi_wheels"
106

107
      - name: Setup Node.js
108
        uses: actions/setup-node@v4
109
        with:
110
          node-version: "16"
111
      - name: Install Yarn
112
        timeout-minutes: 20
113
        run: npm install -g yarn
114

115
      - name: Adjust imports -> App
116
        if: ${{ matrix.pkg-name != 'lightning' }}
117
        run: |
118
          python .actions/assistant.py copy_replace_imports --source_dir="./tests" \
119
            --source_import="lightning.app,lightning.fabric,lightning.pytorch" \
120
            --target_import="lightning_app,lightning_fabric,pytorch_lightning" \
121
            --lightning_by="lightning_app"
122
          python .actions/assistant.py copy_replace_imports --source_dir="./examples" \
123
            --source_import="lightning.app,lightning.fabric,lightning.pytorch" \
124
            --target_import="lightning_app,lightning_fabric,pytorch_lightning" \
125
            --lightning_by="lightning_app"
126

127
      - name: Switch coverage scope
128
        run: python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.pkg-name}}' == 'lightning' else 'lightning_app'))" >> $GITHUB_ENV
129

130
      - name: Set parallel for Unix
131
        if: ${{ runner.os != 'windows' }}
132
        # on Win, tests takes even loner then with normal single thread
133
        run: echo "PYTEST_XDIST_ARGS=-n auto --dist=loadfile" >> $GITHUB_ENV
134
      - name: Tests
135
        working-directory: ./tests
136
        run: |
137
          set -e
138
          python -m coverage run --source ${{ env.COVERAGE_SCOPE }} \
139
            -m pytest -m "not cloud" -vvvv tests_app \
140
              --ignore="tests_app/components/python/test_python.py" \
141
              --timeout=120 --durations=50 ${PYTEST_XDIST_ARGS}
142
          pytest -m "not cloud" -v \
143
            tests_app/components/python/test_python.py \
144
            --timeout=120 --durations=50
145

146
      - name: Statistics
147
        if: success()
148
        working-directory: ./tests
149
        run: |
150
          coverage xml -i
151
          coverage report -i
152

153
      - name: Upload coverage to Codecov
154
        uses: codecov/codecov-action@v4
155
        with:
156
          token: ${{ secrets.CODECOV_TOKEN }}
157
          file: tests/coverage.xml
158
          flags: ${{ env.COVERAGE_SCOPE }},cpu,pytest
159
          env_vars: OS,PYTHON
160
          name: codecov-umbrella
161
          fail_ci_if_error: false
162
# TODO: figure out why we clone and install quick-start
163
#      - name: Clone Quick Start Example Repo
164
#        uses: actions/checkout@v4
165
#        # TODO: this needs to be git submodule
166
#        if: matrix.os == 'windows-2022'  # because the install doesn't work on windows
167
#        with:
168
#          repository: Lightning-AI/lightning-quick-start
169
#          ref: 'main'
170
#          path: lightning-quick-start
171
#
172
#      - name: Lightning Install quick-start
173
#        if: matrix.os != 'windows-2022'  # because the install doesn't work on windows
174
#        run: |
175
#          python -m lightning install app lightning/quick-start -y
176

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.