-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Add CI app cloud e2e #13499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add CI app cloud e2e #13499
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
f52c245
Add CI app e2e
eee207a
Merge branch 'master' of github.com:Lightning-AI/lightning into add-c…
b2ac812
clean projects
6e1ba6c
clean projects
4c6a0f4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 1a38ae2
update UserID
2e0c268
Merge branch 'master' of github.com:Lightning-AI/lightning into add-c…
e851091
Merge branch 'add-ci-examples-e2e' of github.com:Lightning-AI/lightni…
60cdb3a
Merge branch 'master' into add-ci-examples-e2e
akihironitta 1e4c442
install l
65c240a
Merge branch 'add-ci-examples-e2e' of github.com:Lightning-AI/lightni…
cbaacb0
fix apps cleanup
5969c1e
isort
4df7cd0
revert gitignore
d2e107a
strip username
33dc161
disable cache
a93ab18
download frontend while installing lightning
b42fae5
ci
119e44d
ci
88fdc54
add torch
5e2aeba
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 62145b4
ci
c41b483
ci
0c355b8
ci
782ea13
CI
d202302
ci, and tests
2c754c4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 3bd6731
CI
fc87201
Merge branch 'add-ci-examples-e2e' of github.com:Lightning-AI/lightni…
3ccdc10
Merge branch 'master' of github.com:Lightning-AI/lightning into add-c…
8972e32
revert install changes
b606a9a
Merge branch 'master' of github.com:Lightning-AI/lightning into add-c…
49e924e
move pip list, comment venv
3a4baa4
fix yaml file
9441487
skip quick start test
a782a06
remove .lightning file
ccdfcad
skip files
f2ead3e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 9f2ea4a
don't print
93302be
Merge branch 'add-ci-examples-e2e' of github.com:Lightning-AI/lightni…
aebb086
download frontend inside setup.py
e630d27
pylint
ffecf70
make file changes in seperate job
8aaa632
Merge branch 'master' of github.com:Lightning-AI/lightning into add-c…
3adbea6
skip installing quick-start
3ed0e72
Merge branch 'master' into add-ci-examples-e2e
Borda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # This file contains filters to be used in the CI to detect file changes and run the required CI jobs. | ||
|
|
||
| app_examples: | ||
| - "src/lightning_app/**" | ||
| - "tests/tests_app_examples/**" | ||
| - "requirements/app/**" | ||
| - "examples/app_*" | ||
| - "setup.py" | ||
| - "src/pytorch_lightning/__version__.py" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,186 @@ | ||
| name: cloud-testing | ||
|
|
||
| # Used to run the e2e tests on lightning.ai | ||
|
|
||
| on: # Trigger the workflow on push or pull request, but only for the master branch | ||
| push: | ||
| branches: | ||
| - "master" | ||
| pull_request: | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }} | ||
| cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} | ||
|
|
||
| jobs: | ||
| # This is job should once only once per PR to detect file changes so run required jobs. | ||
| # see .github/file-filters.yml to define file filters and run the jobs based on the output of each filter. | ||
| # More info: https://github.com/marketplace/actions/paths-changes-filter | ||
|
|
||
| changes: | ||
| runs-on: ubuntu-latest | ||
| # Set job outputs to the values from filter step | ||
| outputs: | ||
| app_examples: ${{ steps.filter.outputs.app_examples }} | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - name: Set up Python 3.8 | ||
| uses: actions/setup-python@v2 | ||
| with: | ||
| python-version: "3.8" | ||
|
|
||
| - uses: dorny/paths-filter@v2 | ||
| id: filter | ||
| with: | ||
| filters: .github/file-filters.yml | ||
|
|
||
| cloud-test: | ||
| name: Cloud Test | ||
| needs: changes | ||
| if: ${{ needs.changes.outputs.app_examples == 'true' }} | ||
| runs-on: ubuntu-20.04 | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| app_name: | ||
| - v0_app | ||
| - boring_app | ||
| # - quick_start # TODO: fix this | ||
| - template_streamlit_ui | ||
| - template_react_ui | ||
| - template_jupyterlab | ||
| - idle_timeout | ||
| - collect_failures | ||
| - custom_work_dependencies | ||
| - drive | ||
| - payload | ||
| timeout-minutes: 35 | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - name: Set up Python 3.8 | ||
| uses: actions/setup-python@v2 | ||
| with: | ||
| python-version: "3.8" | ||
|
|
||
| - name: Get PR ID | ||
| id: PR | ||
| run: | | ||
| if [ -z ${{github.event.number}} ]; then | ||
| echo "::set-output name=ID::$(date +%s)" | ||
| else | ||
| echo "::set-output name=ID::${{github.event.number}}" | ||
| fi | ||
|
|
||
| # TODO: Enable cache | ||
tchaton marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # - name: Cache virtualenv | ||
| # id: cache-venv | ||
| # uses: actions/cache@v2 | ||
| # with: | ||
| # path: ./.venv/ | ||
| # key: ${{ runner.os }}-pip-${{ matrix.app_name }}-${{ hashFiles('requirements/app/base.txt', 'requirements/app/*.txt', 'src/lightning_app/__version__.py') }} | ||
| # restore-keys: ${{ runner.os }}-venv-${{ matrix.app_name }}- | ||
|
|
||
| - name: Install dependencies | ||
| shell: bash | ||
| run: | | ||
| pip --version | ||
| python -m pip install -r requirements/app/devel.txt --no-cache --quiet --find-links https://download.pytorch.org/whl/cpu/torch_stable.html | ||
| # if: steps.cache-venv.outputs.cache-hit != 'true' # TODO: Enable cache | ||
|
|
||
| - name: Cache Playwright dependencies | ||
| id: playwright-cache | ||
| uses: actions/cache@v2 | ||
| with: | ||
| path: ~/.cache/ms-playwright | ||
| key: ${{ runner.os }}-playwright-${{ matrix.app_name }}-${{ hashFiles('requirements/app/base.txt', 'requirements/app/*.txt', 'src/lightning_app/__version__.py') }} | ||
| restore-keys: ${{ runner.os }}-playwright-${{ matrix.app_name }}- | ||
|
|
||
| - name: Install Playwright system dependencies | ||
| shell: bash | ||
| run: | | ||
| python -m pip install playwright | ||
| python -m playwright install --with-deps | ||
| # if: steps.playwright-cache.outputs.cache-hit != 'true' # TODO: Enable cache | ||
|
|
||
| - name: Install lightning | ||
| run: | | ||
| pip install -e . | ||
| shell: bash | ||
|
|
||
| - name: Lightning Install quick-start | ||
| if: ${{ (matrix.app_name == 'quick_start') }} | ||
| shell: bash | ||
| run: | | ||
| python -m lightning install app lightning/quick-start -y | ||
|
|
||
| - name: Clone Template React UI Repo | ||
| uses: actions/checkout@v3 | ||
| with: | ||
| repository: Lightning-AI/lightning-template-react | ||
| token: ${{ secrets.PAT_GHOST }} | ||
| ref: 'master' | ||
| path: examples/app_template_react_ui | ||
|
|
||
| - name: Clone Template Jupyter Lab Repo | ||
| uses: actions/checkout@v3 | ||
| with: | ||
| repository: Lightning-AI/lightning-template-jupyterlab | ||
| token: ${{ secrets.PAT_GHOST }} | ||
| ref: 'master' | ||
| path: examples/app_template_jupyterlab | ||
|
|
||
| - name: Copy Template Jupyter Lab Repo tests | ||
| shell: bash | ||
| run: cp examples/app_template_jupyterlab/tests/test_template_jupyterlab.py tests/tests_app_examples/test_template_jupyterlab.py | ||
|
|
||
| - name: List pip dependency | ||
| shell: bash | ||
| run: | | ||
| pip list | ||
|
|
||
| - name: Run the tests | ||
| env: | ||
| LAI_USER: ${{ secrets.LAI_USER }} | ||
| LAI_PASS: ${{ secrets.LAI_PASS }} | ||
| LIGHTNING_USER_ID: ${{ secrets.LIGHTNING_USER_ID }} | ||
| LIGHTNING_API_KEY: ${{ secrets.LIGHTNING_API_KEY }} | ||
| LIGHTNING_USERNAME: ${{ secrets.LIGHTNING_USERNAME }} | ||
| LIGHTNING_CLOUD_URL: ${{ secrets.LIGHTNING_CLOUD_URL }} | ||
| CLOUD: "1" | ||
| VIDEO_LOCATION: ./artifacts/videos | ||
| PR_NUMBER: ${{ steps.PR.outputs.ID }} | ||
| TEST_APP_NAME: ${{ matrix.app_name }} | ||
| HAR_LOCATION: ./artifacts/hars | ||
| SLOW_MO: 50 | ||
| shell: bash | ||
| run: | | ||
| mkdir -p ${VIDEO_LOCATION} | ||
| HEADLESS=1 python -m pytest tests/tests_app_examples/test_${{ matrix.app_name }}.py::test_${{ matrix.app_name }}_example_cloud --timeout=900 --capture=no -v --color=yes | ||
| # Delete the artifacts if successful | ||
| rm -r ${VIDEO_LOCATION}/${{ matrix.app_name }} | ||
|
|
||
| - uses: actions/upload-artifact@v2 | ||
|
|
||
| if: ${{ always() }} | ||
| with: | ||
| name: test-artifacts | ||
| path: ./artifacts/videos | ||
|
|
||
| - name: Clean Previous Apps | ||
| if: ${{ always() }} | ||
| env: | ||
| LAI_USER: ${{ secrets.LAI_USER }} | ||
| LAI_PASS: ${{ secrets.LAI_PASS }} | ||
| LIGHTNING_USER_ID: ${{ secrets.LIGHTNING_USER_ID }} | ||
| LIGHTNING_API_KEY: ${{ secrets.LIGHTNING_API_KEY }} | ||
| LIGHTNING_USERNAME: ${{ secrets.LIGHTNING_USERNAME }} | ||
| LIGHTNING_CLOUD_URL: ${{ secrets.LIGHTNING_CLOUD_URL }} | ||
| PR_NUMBER: ${{ steps.PR.outputs.ID }} | ||
| TEST_APP_NAME: ${{ matrix.app_name }} | ||
| GRID_USER_ID: ${{ secrets.LIGHTNING_USER_ID }} | ||
| GRID_USER_KEY: ${{ secrets.LIGHTNING_API_KEY }} | ||
| GRID_URL: ${{ secrets.LIGHTNING_CLOUD_URL }} | ||
| _GRID_USERNAME: ${{ secrets.LIGHTNING_USERNAME }} | ||
| shell: bash | ||
| run: | | ||
| time python -c "from lightning.app import testing; testing.delete_cloud_lightning_apps()" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import logging | ||
|
|
||
| from lightning_app import LightningApp, LightningFlow | ||
| from lightning_app.frontend import StreamlitFrontend | ||
| from lightning_app.utilities.state import AppState | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class StreamlitUI(LightningFlow): | ||
| def __init__(self): | ||
| super().__init__() | ||
| self.message_to_print = "Hello World!" | ||
| self.should_print = False | ||
|
|
||
| def configure_layout(self): | ||
| return StreamlitFrontend(render_fn=render_fn) | ||
|
|
||
|
|
||
| def render_fn(state: AppState): | ||
| import streamlit as st | ||
|
|
||
| should_print = st.button("Should print to the terminal ?") | ||
|
|
||
| if should_print: | ||
| state.should_print = not state.should_print | ||
|
|
||
| st.write("Currently printing." if state.should_print else "Currently waiting to print.") | ||
|
|
||
|
|
||
| class HelloWorld(LightningFlow): | ||
| def __init__(self): | ||
| super().__init__() | ||
| self.counter = 0 | ||
| self.streamlit_ui = StreamlitUI() | ||
|
|
||
| def run(self): | ||
| self.streamlit_ui.run() | ||
| if self.streamlit_ui.should_print: | ||
| logger.info(f"{self.counter}: {self.streamlit_ui.message_to_print}") | ||
| self.counter += 1 | ||
| self.streamlit_ui.should_print = False | ||
|
|
||
| def configure_layout(self): | ||
| return [{"name": "StreamLitUI", "content": self.streamlit_ui}] | ||
|
|
||
|
|
||
| app = LightningApp(HelloWorld()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| streamlit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,8 @@ | ||
| from lightning_app.testing.testing import application_testing, LightningTestApp, run_work_isolated | ||
| from lightning_app.testing.testing import ( | ||
| application_testing, | ||
| delete_cloud_lightning_apps, | ||
| LightningTestApp, | ||
| run_work_isolated, | ||
| ) | ||
|
|
||
| __all__ = ["application_testing", "run_work_isolated", "LightningTestApp"] | ||
| __all__ = ["application_testing", "run_work_isolated", "LightningTestApp", "delete_cloud_lightning_apps"] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.