# Python package # Create and test a Python package on multiple Python versions. # Add steps that analyze code, save the dist with the build record, publish to a PyPI-compatible index, and more: # https://docs.microsoft.com/azure/devops/pipelines/languages/python trigger: tags: include: - '*' branches: include: - "master" - "release/*" - "refs/tags/*" pr: - "master" - "release/*" # variables are automatically exported as environment variables so this will override pip's default cache dir variables: - name: pip_cache_dir value: $(Pipeline.Workspace)/.pip - name: local_id value: $(Build.BuildId) jobs: - job: App_cloud_e2e_testing pool: azure-cpus container: image: mcr.microsoft.com/playwright/python:v1.25.2-focal options: "--shm-size=2g" strategy: matrix: 'App: v0_app': name: "v0_app" 'App: boring_app': name: "boring_app" 'App: template_streamlit_ui': name: "template_streamlit_ui" 'App: template_react_ui': name: "template_react_ui" 'App: template_jupyterlab': # TODO: clarify where these files lives name: "template_jupyterlab" 'App: idle_timeout': name: "idle_timeout" 'App: collect_failures': name: "collect_failures" 'App: custom_work_dependencies': name: "custom_work_dependencies" 'App: drive': name: "drive" 'App: payload': name: "payload" 'App: commands_and_api': name: "commands_and_api" timeoutInMinutes: "30" cancelTimeoutInMinutes: "2" steps: - script: echo '##vso[task.setvariable variable=local_id]$(System.PullRequest.PullRequestNumber)' displayName: "Set id for this PR" condition: eq(variables['Build.Reason'], 'PullRequest') - bash: | whoami printf "local id: $(local_id)\n" python --version pip --version displayName: 'Info' - task: Cache@2 inputs: key: 'pip | "$(name)" | requirements/app/base.txt' restoreKeys: | pip | "$(Agent.OS)" path: $(pip_cache_dir) displayName: Cache pip - bash: python -m pip install -r requirements/app/devel.txt --quiet --find-links ${TORCH_URL} env: TORCH_URL: https://download.pytorch.org/whl/cpu/torch_stable.html displayName: 'Install dependencies' - bash: | python -m pip install playwright python -m playwright install # --with-deps displayName: 'Install Playwright system dependencies' - bash: pip install -e . --find-links https://download.pytorch.org/whl/cpu/torch_stable.html displayName: 'Install lightning' - bash: | git clone https://github.com/Lightning-AI/LAI-lightning-template-jupyterlab-App examples/app_template_jupyterlab cp examples/app_template_jupyterlab/tests/test_template_jupyterlab.py tests/tests_app_examples/test_template_jupyterlab.py condition: eq(variables['name'], 'template_jupyterlab') displayName: 'Clone Template Jupyter Lab Repo' - bash: git clone https://github.com/Lightning-AI/lightning-template-react examples/app_template_react_ui condition: eq(variables['name'], 'template_react_ui') displayName: 'Clone Template React UI Repo' - bash: | mkdir -p ${VIDEO_LOCATION} ls -l examples/${TEST_APP_NAME} ls -l tests/tests_app_examples python -m pytest tests/tests_app_examples/test_${TEST_APP_NAME}.py::test_${TEST_APP_NAME}_example_cloud --timeout=900 --capture=no -v --color=yes env: HEADLESS: '1' PACKAGE_LIGHTNING: '1' CLOUD: '1' VIDEO_LOCATION: '$(Build.ArtifactStagingDirectory)/videos' PR_NUMBER: $(local_id) TEST_APP_NAME: $(name) HAR_LOCATION: './artifacts/hars' SLOW_MO: '50' # LAI_USER: $(LAI_USER) # LAI_PASS: $(LAI_PASS) LIGHTNING_USER_ID: $(LIGHTNING_USER_ID_PROD) LIGHTNING_API_KEY: $(LIGHTNING_API_KEY_PROD) LIGHTNING_USERNAME: $(LIGHTNING_USERNAME) LIGHTNING_CLOUD_URL: $(LIGHTNING_CLOUD_URL_PROD) displayName: 'Run the tests' - publish: '$(Build.ArtifactStagingDirectory)/videos' condition: failed() displayName: 'Publish videos' artifact: $(name) - bash: | time python -c "from lightning.app import testing; testing.delete_cloud_lightning_apps()" condition: always() env: # LAI_USER: $(LAI_USER) # LAI_PASS: $(LAI_PASS) LIGHTNING_USER_ID: $(LIGHTNING_USER_ID_PROD) LIGHTNING_API_KEY: $(LIGHTNING_API_KEY_PROD) LIGHTNING_USERNAME: $(LIGHTNING_USERNAME) LIGHTNING_CLOUD_URL: $(LIGHTNING_CLOUD_URL_PROD) PR_NUMBER: $(local_id) TEST_APP_NAME: $(name) # GRID_USER_ID: $(LIGHTNING_USER_ID) # TODO: clarify the meaning # GRID_USER_KEY: $(LIGHTNING_API_KEY) # TODO: clarify the meaning # GRID_URL: $(LIGHTNING_CLOUD_URL) # _GRID_USERNAME: $(LIGHTNING_USERNAME) displayName: 'Clean Previous Apps'