pytorch-lightning
206 строк · 7.2 Кб
1# Python package
2# Create and test a Python package on multiple Python versions.
3# Add steps that analyze code, save the dist with the build record, publish to a PyPI-compatible index, and more:
4# https://docs.microsoft.com/azure/devops/pipelines/languages/python
5
6trigger:
7tags:
8include:
9- "*"
10branches:
11include:
12- "master"
13- "release/*"
14- "refs/tags/*"
15
16schedules:
17- cron: "0 0 * * *" # At the end of every day
18displayName: Daily midnight testing
19branches:
20include:
21- "master"
22
23pr:
24branches:
25include:
26- "master"
27- "release/*"
28paths:
29include:
30- ".actions/*"
31- ".azure/app-cloud-e2e.yml"
32- "src/lightning/__about__.py"
33- "src/lightning/__init__.py"
34- "src/lightning/__main__.py"
35- "src/lightning/__setup__.py"
36- "src/lightning/__version__.py"
37- "src/lightning/app/**"
38- "src/lightning_app/*"
39- "examples/app/**"
40- "requirements/app/**"
41- "tests/integrations_app/**"
42- "setup.py"
43exclude:
44- "!tests/integrations_app/flagship/**"
45- "requirements/*/docs.txt"
46- "*.md"
47- "**/*.md"
48
49# variables are automatically exported as environment variables so this will override pip's default cache dir
50variables:
51- name: pip_cache_dir
52value: $(Pipeline.Workspace)/.pip
53- name: local_id
54value: $(Build.BuildId)
55- name: video_artifact_dir
56value: ./videos
57
58jobs:
59- job: test_e2e
60pool: "azure-cpus"
61container:
62# see all available tags: https://mcr.microsoft.com/en-us/product/playwright/python/tags
63image: mcr.microsoft.com/playwright/python:v1.38.0-focal
64options: "--shm-size=4gb"
65strategy:
66matrix:
67"App: v0_app":
68name: "v0_app"
69dir: "public"
70"App: boring_app":
71name: "boring_app"
72dir: "public"
73"App: template_streamlit_ui":
74name: "template_streamlit_ui"
75dir: "public"
76"App: template_react_ui":
77name: "template_react_ui"
78dir: "public"
79# 'App: template_jupyterlab': # TODO: clarify where these files lives
80# name: "template_jupyterlab"
81"App: installation_commands_app":
82name: "installation_commands_app"
83dir: "public"
84"App: drive":
85name: "drive"
86dir: "public"
87"App: payload":
88name: "payload"
89dir: "public"
90"App: commands_and_api":
91name: "commands_and_api"
92dir: "public"
93"App: quick_start":
94name: "quick_start"
95dir: "public"
96"App: idle_timeout":
97name: "idle_timeout"
98dir: "local"
99"App: collect_failures":
100name: "collect_failures"
101dir: "local"
102"App: custom_work_dependencies":
103name: "custom_work_dependencies"
104dir: "local"
105timeoutInMinutes: "15"
106cancelTimeoutInMinutes: "1"
107# values: https://docs.microsoft.com/en-us/azure/devops/pipelines/process/phases?view=azure-devops&tabs=yaml#workspace
108workspace:
109clean: all
110variables:
111FREEZE_REQUIREMENTS: "1"
112HEADLESS: "1"
113PACKAGE_LIGHTNING: "1"
114CLOUD: "1"
115VIDEO_LOCATION: $(video_artifact_dir)
116PR_NUMBER: $(local_id)
117TEST_APP_NAME: $(name)
118TEST_APP_FOLDER: $(dir)
119HAR_LOCATION: "./artifacts/hars"
120SLOW_MO: "50"
121LIGHTNING_DEBUG: "1"
122steps:
123- script: echo '##vso[task.setvariable variable=local_id]$(System.PullRequest.PullRequestNumber)'
124displayName: "Set id for this PR"
125condition: eq(variables['Build.Reason'], 'PullRequest')
126
127- bash: |
128whoami
129mkdir -p "$(video_artifact_dir)/$(name)"
130printf "local id: $(local_id)\n"
131python --version
132pip --version
133echo "allow fail: ${{ in(variables['name'], 'quick_start', 'template_react_ui') }}"
134displayName: "Info"
135
136# TODO: we are testing it as `lightning`, so add also version for `lightning_app`
137- bash: |
138pip install -e .[app-dev] \
139-f https://download.pytorch.org/whl/cpu/torch_stable.html
140displayName: "Install Lightning & dependencies"
141
142- bash: python -m playwright install # --with-deps
143displayName: "Install Playwright system dependencies"
144
145# The magic happens here it doesn't need to install the quick start dependencies.
146# This test is very important to test the main user story of lightning app.
147# It also e2e tests running on cloud without installing dependencies.
148- bash: |
149git clone https://github.com/Lightning-AI/lightning-quick-start examples/app/quick-start
150# without succeeded this could run even if the job has already failed
151condition: and(succeeded(), eq(variables['name'], 'quick_start'))
152displayName: "Clone Quick start Repo"
153- bash: |
154git clone https://github.com/Lightning-AI/lightning-template-react examples/app/template_react_ui
155# without succeeded this could run even if the job has already failed
156condition: and(succeeded(), eq(variables['name'], 'template_react_ui'))
157displayName: "Clone Template React UI Repo"
158
159# Replace imports to use `lightning` instead of `lightning_app` since we install lightning only ATM
160- bash: |
161pip install -q -r .actions/requirements.txt
162python .actions/assistant.py copy_replace_imports \
163--source_dir="./examples" --source_import="lightning_app" --target_import="lightning.app"
164displayName: "Adjust examples"
165
166- bash: pip --version && pip list
167displayName: "List pip dependency"
168
169- bash: |
170ls -l examples/app/$(TEST_APP_NAME)
171echo ${TEST_FILE}
172python -m pytest ${TEST_FILE}::test_$(TEST_APP_NAME)_example_cloud \
173--timeout=360 --capture=no -v --color=yes
174env:
175TEST_FILE: tests/integrations_app/$(TEST_APP_FOLDER)/test_$(TEST_APP_NAME).py
176#LAI_USER: $(LAI_USER) # for STAGING
177#LAI_PASS: $(LAI_PASS) # for STAGING
178LIGHTNING_USER_ID: $(LIGHTNING_USER_ID_PROD)
179LIGHTNING_API_KEY: $(LIGHTNING_API_KEY_PROD)
180LIGHTNING_USERNAME: $(LIGHTNING_USERNAME_PROD)
181LIGHTNING_CLOUD_URL: $(LIGHTNING_CLOUD_URL_PROD)
182# Todo: investigate why these apps are failing
183continueOnError: ${{ in(variables['name'], 'quick_start', 'template_react_ui') }}
184displayName: "Run the tests"
185
186- task: PublishPipelineArtifact@1
187condition: failed()
188inputs:
189path: "$(video_artifact_dir)/$(name)"
190artifactName: $(name)
191publishLocation: "pipeline"
192displayName: "Publish videos"
193
194- bash: |
195time python -c "from lightning.app import testing; testing.delete_cloud_lightning_apps()"
196condition: always()
197continueOnError: "true"
198timeoutInMinutes: "3"
199env:
200#LAI_USER: $(LAI_USER) # for STAGING
201#LAI_PASS: $(LAI_PASS) # for STAGING
202LIGHTNING_USER_ID: $(LIGHTNING_USER_ID_PROD)
203LIGHTNING_API_KEY: $(LIGHTNING_API_KEY_PROD)
204LIGHTNING_USERNAME: $(LIGHTNING_USERNAME_PROD)
205LIGHTNING_CLOUD_URL: $(LIGHTNING_CLOUD_URL_PROD)
206displayName: "Clean Previous Apps"
207