Skip to content

Commit 59fa320

Browse files
authored
Tests/App: refactor examples - structure (#15770)
* rename _examples dir * refactor * clean * path * add inits * skip * e2e * azure * e2e * rev * unify single depth for ignore docs req. * group
1 parent 7b2788e commit 59fa320

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+110
-83
lines changed

.azure/app-cloud-e2e.yml

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,15 @@ pr:
2727
- "release/*"
2828
paths:
2929
include:
30+
- ".actions/**"
3031
- ".azure/app-cloud-e2e.yml"
31-
- "requirements/app/**"
3232
- "src/lightning_app/**"
33-
- "tests/tests_app/**"
3433
- "examples/app_*/**" # some tests_app tests call examples files
35-
- "tests/tests_app_examples/**"
34+
- "requirements/app/**"
35+
- "tests/tests_examples_app/**"
3636
- "setup.py"
37-
- ".actions/**"
3837
exclude:
39-
- "requirements/app/docs.txt"
38+
- "requirements/*/docs.txt"
4039
- "*.md"
4140
- "**/*.md"
4241

@@ -59,30 +58,42 @@ jobs:
5958
matrix:
6059
'App: v0_app':
6160
name: "v0_app"
61+
dir: "public"
6262
'App: boring_app':
6363
name: "boring_app"
64+
dir: "public"
6465
'App: template_streamlit_ui':
6566
name: "template_streamlit_ui"
67+
dir: "public"
6668
'App: template_react_ui':
6769
name: "template_react_ui"
70+
dir: "public"
6871
# 'App: template_jupyterlab': # TODO: clarify where these files lives
6972
# name: "template_jupyterlab"
70-
'App: idle_timeout':
71-
name: "idle_timeout"
72-
'App: collect_failures':
73-
name: "collect_failures"
74-
'App: custom_work_dependencies':
75-
name: "custom_work_dependencies"
7673
'App: installation_commands_app':
7774
name: "installation_commands_app"
75+
dir: "public"
7876
'App: drive':
7977
name: "drive"
78+
dir: "public"
8079
'App: payload':
8180
name: "payload"
81+
dir: "public"
8282
'App: commands_and_api':
8383
name: "commands_and_api"
84+
dir: "public"
8485
'App: quick_start':
8586
name: "quick_start"
87+
dir: "public"
88+
'App: idle_timeout':
89+
name: "idle_timeout"
90+
dir: "local"
91+
'App: collect_failures':
92+
name: "collect_failures"
93+
dir: "local"
94+
'App: custom_work_dependencies':
95+
name: "custom_work_dependencies"
96+
dir: "local"
8697
timeoutInMinutes: "20"
8798
cancelTimeoutInMinutes: "2"
8899
# values: https://docs.microsoft.com/en-us/azure/devops/pipelines/process/phases?view=azure-devops&tabs=yaml#workspace
@@ -124,7 +135,7 @@ jobs:
124135
# - bash: |
125136
# rm -rf examples/app_template_jupyterlab || true
126137
# git clone https://github.com/Lightning-AI/LAI-lightning-template-jupyterlab-App examples/app_template_jupyterlab
127-
# cp examples/app_template_jupyterlab/tests/test_template_jupyterlab.py tests/tests_app_examples/test_template_jupyterlab.py
138+
# cp examples/app_template_jupyterlab/tests/test_template_jupyterlab.py tests/tests_examples_app/test_template_jupyterlab.py
128139
# condition: eq(variables['name'], 'template_jupyterlab')
129140
# displayName: 'Clone Template Jupyter Lab Repo'
130141

@@ -152,15 +163,17 @@ jobs:
152163
- bash: |
153164
mkdir -p ${VIDEO_LOCATION}
154165
ls -l examples/${TEST_APP_NAME}
155-
ls -l tests/tests_app_examples
156-
python -m pytest tests/tests_app_examples/test_${TEST_APP_NAME}.py::test_${TEST_APP_NAME}_example_cloud --timeout=1200 --capture=no -v --color=yes
166+
ls -l tests/tests_examples_app/public
167+
python -m pytest tests/tests_examples_app/${TEST_APP_FOLDER}/test_${TEST_APP_NAME}.py::test_${TEST_APP_NAME}_example_cloud \
168+
--timeout=1200 --capture=no -v --color=yes
157169
env:
158170
HEADLESS: '1'
159171
PACKAGE_LIGHTNING: '1'
160172
CLOUD: '1'
161173
VIDEO_LOCATION: $(video_artifact_dir)
162174
PR_NUMBER: $(local_id)
163175
TEST_APP_NAME: $(name)
176+
TEST_APP_FOLDER: $(dir)
164177
HAR_LOCATION: './artifacts/hars'
165178
SLOW_MO: '50'
166179
#LAI_USER: $(LAI_USER) # for STAGING
@@ -191,6 +204,7 @@ jobs:
191204
LIGHTNING_CLOUD_URL: $(LIGHTNING_CLOUD_URL_PROD)
192205
PR_NUMBER: $(local_id)
193206
TEST_APP_NAME: $(name)
207+
TEST_APP_FOLDER: $(dir)
194208
# GRID_USER_ID: $(LIGHTNING_USER_ID) # TODO: clarify the meaning
195209
# GRID_USER_KEY: $(LIGHTNING_API_KEY) # TODO: clarify the meaning
196210
# GRID_URL: $(LIGHTNING_CLOUD_URL)

.azure/gpu-tests-lite.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pr:
2020
- "release/*"
2121
paths:
2222
include:
23+
- ".actions/**"
2324
- ".azure/gpu-tests-lite.yml"
2425
- "examples/lite/**"
2526
- "examples/run_lite_examples.sh"
@@ -29,7 +30,6 @@ pr:
2930
- "src/lightning_lite/**"
3031
- "tests/tests_lite/**"
3132
- "setup.cfg" # includes pytest config
32-
- ".actions/**"
3333
exclude:
3434
- "requirements/lite/docs.txt"
3535
- "*.md"

.azure/gpu-tests-pytorch.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pr:
2020
- "release/*"
2121
paths:
2222
include:
23+
- ".actions/**"
2324
- ".azure/gpu-tests-pytorch.yml"
2425
- "examples/run_pl_examples.sh"
2526
- "examples/pl_basics/backbone_image_classifier.py"
@@ -33,9 +34,8 @@ pr:
3334
- "setup.cfg" # includes pytest config
3435
- "requirements/lite/**"
3536
- "src/lightning_lite/**"
36-
- ".actions/**"
3737
exclude:
38-
- "requirements/**/docs.txt"
38+
- "requirements/*/docs.txt"
3939
- "*.md"
4040
- "**/*.md"
4141

.azure/hpu-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pr:
1717
- "release/*"
1818
paths:
1919
include:
20+
- ".actions/**"
2021
- ".azure/hpu-tests.yml"
2122
- "examples/pl_hpu/mnist_sample.py"
2223
- "requirements/lite/**"
@@ -25,9 +26,8 @@ pr:
2526
- "src/pytorch_lightning/**"
2627
- "tests/tests_pytorch/**"
2728
- "setup.cfg" # includes pytest config
28-
- ".actions/**"
2929
exclude:
30-
- "requirements/**/docs.txt"
30+
- "requirements/*/docs.txt"
3131
- "*.md"
3232
- "**/*.md"
3333

.azure/ipu-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ pr:
1515
- "release/*"
1616
paths:
1717
include:
18+
- ".actions/**"
1819
- ".azure/ipu-tests.yml"
1920
- "requirements/lite/**"
2021
- "src/lightning_lite/**"
2122
- "requirements/pytorch/**"
2223
- "src/pytorch_lightning/**"
2324
- "tests/tests_pytorch/**"
2425
- "setup.cfg" # includes pytest config
25-
- ".actions/**"
2626
exclude:
27-
- "requirements/**/docs.txt"
27+
- "requirements/*/docs.txt"
2828
- "*.md"
2929
- "**/*.md"
3030

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
# Lightning App
4646
/src/lightning_app @tchaton @lantiga @awaelchli @hhsecond @ethanwharris
4747
/tests/tests_app @tchaton @lantiga @awaelchli @hhsecond @ethanwharris
48-
/tests/tests_app_examples @tchaton @lantiga @awaelchli @hhsecond @ethanwharris
48+
/tests/tests_examples_app @tchaton @lantiga @awaelchli @hhsecond @ethanwharris
4949
/examples/app_* @tchaton @lantiga @awaelchli @hhsecond @ethanwharris
5050

5151
/.github/CODEOWNERS @williamfalcon

.github/checkgroup.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ subprojects:
245245
paths:
246246
- ".github/workflows/ci-app-examples.yml"
247247
- "src/lightning_app/**"
248-
- "tests/tests_app_examples/**"
248+
- "tests/tests_examples_app/**"
249249
- "examples/app_*/**"
250250
- "requirements/app/**"
251251
- "setup.py"
@@ -269,9 +269,8 @@ subprojects:
269269
- ".azure/app-cloud-e2e.yml"
270270
- "requirements/app/**"
271271
- "src/lightning_app/**"
272-
- "tests/tests_app/**"
273272
- "examples/app_*/**" # some tests_app tests call examples files
274-
- "tests/tests_app_examples/**"
273+
- "tests/tests_examples_app/**"
275274
- "setup.py"
276275
- ".actions/**"
277276
- "!requirements/app/docs.txt"

.github/labeler.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ app:
55
all: ['!src/pytorch_lightning/**/*', '!tests/tests_pytorch/**/*', '!docs/source-pytorch/**/*', '!requirements/pytorch/*']
66
- any: ['tests/tests_app/**/*']
77
all: ['!src/pytorch_lightning/**/*', '!tests/tests_pytorch/**/*', '!docs/source-pytorch/**/*', '!requirements/pytorch/*']
8-
- any: ['tests/tests_app_examples/**/*']
8+
- any: ['tests/tests_examples_app/**/*']
99
all: ['!src/pytorch_lightning/**/*', '!tests/tests_pytorch/**/*', '!docs/source-pytorch/**/*', '!requirements/pytorch/*']
1010
- any: ['examples/app_*/**/*']
1111
all: ['!src/pytorch_lightning/**/*', '!tests/tests_pytorch/**/*', '!docs/source-pytorch/**/*', '!requirements/pytorch/*']
@@ -16,12 +16,12 @@ app:
1616

1717
pl:
1818
- any: ['src/pytorch_lightning/**/*']
19-
all: ['!src/lightning/**/*', '!src/lightning_app/**/*', '!tests/tests_app/**/*', '!tests/tests_app_examples/**/*', '!docs/source-app/**/*', '!requirements/app/*']
19+
all: ['!src/lightning/**/*', '!src/lightning_app/**/*', '!tests/tests_app/**/*', '!tests/tests_examples_app/**/*', '!docs/source-app/**/*', '!requirements/app/*']
2020
- any: ['examples/*pl_*/**/*']
21-
all: ['!src/lightning/**/*', '!src/lightning_app/**/*', '!tests/tests_app/**/*', '!tests/tests_app_examples/**/*', '!docs/source-app/**/*', '!requirements/app/*']
21+
all: ['!src/lightning/**/*', '!src/lightning_app/**/*', '!tests/tests_app/**/*', '!tests/tests_examples_app/**/*', '!docs/source-app/**/*', '!requirements/app/*']
2222
- any: ['tests/tests_pytorch/**/*']
23-
all: ['!src/lightning/**/*', '!src/lightning_app/**/*', '!tests/tests_app/**/*', '!tests/tests_app_examples/**/*', '!docs/source-app/**/*', '!requirements/app/*']
23+
all: ['!src/lightning/**/*', '!src/lightning_app/**/*', '!tests/tests_app/**/*', '!tests/tests_examples_app/**/*', '!docs/source-app/**/*', '!requirements/app/*']
2424
- any: ['docs/source-pytorch/**/*']
25-
all: ['!src/lightning/**/*', '!src/lightning_app/**/*', '!tests/tests_app/**/*', '!tests/tests_app_examples/**/*', '!docs/source-app/**/*', '!requirements/app/*']
25+
all: ['!src/lightning/**/*', '!src/lightning_app/**/*', '!tests/tests_app/**/*', '!tests/tests_examples_app/**/*', '!docs/source-app/**/*', '!requirements/app/*']
2626
- any: ['requirements/pytorch/*']
27-
all: ['!src/lightning/**/*', '!src/lightning_app/**/*', '!tests/tests_app/**/*', '!tests/tests_app_examples/**/*', '!docs/source-app/**/*', '!requirements/app/*']
27+
all: ['!src/lightning/**/*', '!src/lightning_app/**/*', '!tests/tests_app/**/*', '!tests/tests_examples_app/**/*', '!docs/source-app/**/*', '!requirements/app/*']

.github/workflows/ci-app-examples.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
paths:
1111
- ".github/workflows/ci-app-examples.yml"
1212
- "src/lightning_app/**"
13-
- "tests/tests_app_examples/**"
13+
- "tests/tests_examples_app/**"
1414
- "examples/app_*/**"
1515
- "requirements/app/**"
1616
- "setup.py"
@@ -111,7 +111,7 @@ jobs:
111111
AWS_DEFAULT_REGION: us-east-1
112112
PYTEST_ARTIFACT: results-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}.xml
113113
run: |
114-
coverage run --source ${COVERAGE_SCOPE} -m pytest -m "not cloud" tests_app_examples --timeout=300 -vvvv --junitxml=$PYTEST_ARTIFACT --durations=0
114+
coverage run --source ${COVERAGE_SCOPE} -m pytest -m "not cloud" tests_examples_app --timeout=300 -vvvv --junitxml=$PYTEST_ARTIFACT --durations=0
115115
116116
- name: Upload pytest test results
117117
uses: actions/upload-artifact@v3

tests/tests_app_examples/collect_failures/__init__.py

Whitespace-only changes.

tests/tests_app_examples/components/__init__.py

Whitespace-only changes.

tests/tests_app_examples/components/python/__init__.py

Whitespace-only changes.

tests/tests_app_examples/custom_work_dependencies/__init__.py

Whitespace-only changes.

tests/tests_app_examples/idle_timeout/__init__.py

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# TODO: check the tests to be able to run without this init file
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# TODO: check the tests to be able to run without this init file

tests/tests_app_examples/core_features_app/app.py renamed to tests/tests_examples_app/apps/core_features_app/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def __init__(self):
88
super().__init__()
99

1010
def run(self):
11-
# these env vars are set here: tests/tests_app_examples/test_core_features_app.py:15
11+
# these env vars are set here: tests/tests_examples_app/test_core_features_app.py:15
1212
assert os.getenv("FOO", "") == "bar"
1313
assert os.getenv("BLA", "") == "bloz"
1414
self._exit()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# TODO: check the tests to be able to run without this init file
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# TODO: check the tests to be able to run without this init file
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import os
2+
3+
from lightning_app import _PROJECT_ROOT
4+
5+
_PATH_APPS = os.path.join(_PROJECT_ROOT, "tests", "tests_examples_app", "apps")

tests/tests_app_examples/test_collect_failures.py renamed to tests/tests_examples_app/local/test_collect_failures.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
from time import sleep
33

44
import pytest
5+
from tests_examples_app.local import _PATH_APPS
56

6-
from lightning_app import _PROJECT_ROOT
77
from lightning_app.testing.testing import run_app_in_cloud
88

99

@@ -22,7 +22,7 @@ def test_collect_failures_example_cloud() -> None:
2222
"good_value_of_i_4",
2323
"invalid_value_of_i_5",
2424
]
25-
with run_app_in_cloud(os.path.join(_PROJECT_ROOT, "tests/tests_app_examples/collect_failures")) as (
25+
with run_app_in_cloud(os.path.join(_PATH_APPS, "collect_failures")) as (
2626
_,
2727
_,
2828
fetch_logs,

tests/tests_app_examples/test_core_features_app.py renamed to tests/tests_examples_app/local/test_core_features_app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22

33
from click.testing import CliRunner
4-
from tests_app import _PROJECT_ROOT
4+
from tests_examples_app.local import _PATH_APPS
55

66
from lightning_app.cli.lightning_cli import run_app
77

@@ -12,7 +12,7 @@ def test_core_features_app_example():
1212
result = runner.invoke(
1313
run_app,
1414
[
15-
os.path.join(_PROJECT_ROOT, "tests/tests_app_examples/core_features_app/app.py"),
15+
os.path.join(_PATH_APPS, "core_features_app", "app.py"),
1616
"--blocking",
1717
"False",
1818
"--open-ui",

tests/tests_app_examples/test_custom_work_dependencies.py renamed to tests/tests_examples_app/local/test_custom_work_dependencies.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from time import sleep
33

44
import pytest
5-
from tests_app import _PROJECT_ROOT
5+
from tests_examples_app.local import _PATH_APPS
66

77
from lightning_app.testing.testing import run_app_in_cloud
88

@@ -11,7 +11,7 @@
1111
def test_custom_work_dependencies_example_cloud() -> None:
1212
# if requirements not installed, the app will fail
1313
with run_app_in_cloud(
14-
os.path.join(_PROJECT_ROOT, "tests/tests_app_examples/custom_work_dependencies/"),
14+
os.path.join(_PATH_APPS, "custom_work_dependencies"),
1515
app_name="app.py",
1616
) as (_, _, fetch_logs, _):
1717
has_logs = False

tests/tests_app_examples/test_idle_timeout.py renamed to tests/tests_examples_app/local/test_idle_timeout.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
from time import sleep
33

44
import pytest
5-
from tests_app import _PROJECT_ROOT
5+
from tests_examples_app.local import _PATH_APPS
66

77
from lightning_app.testing.testing import run_app_in_cloud
88

99

1010
@pytest.mark.cloud
1111
def test_idle_timeout_example_cloud() -> None:
12-
with run_app_in_cloud(os.path.join(_PROJECT_ROOT, "tests/tests_app_examples/idle_timeout")) as (
12+
with run_app_in_cloud(os.path.join(_PATH_APPS, "idle_timeout")) as (
1313
_,
1414
_,
1515
fetch_logs,
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import os
2+
3+
from lightning_app import _PROJECT_ROOT
4+
5+
_PATH_EXAMPLES = os.path.join(_PROJECT_ROOT, "examples")

tests/tests_app_examples/test_app_dag.py renamed to tests/tests_examples_app/public/test_app_dag.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
from time import sleep
33

44
import pytest
5-
from tests_app import _PROJECT_ROOT
5+
from tests_examples_app.public import _PATH_EXAMPLES
66

77
from lightning_app.testing.testing import run_app_in_cloud
88

99

1010
@pytest.mark.cloud
1111
def test_app_dag_example_cloud() -> None:
12-
with run_app_in_cloud(os.path.join(_PROJECT_ROOT, "examples/app_dag")) as (_, _, fetch_logs, _):
12+
with run_app_in_cloud(os.path.join(_PATH_EXAMPLES, "app_dag")) as (_, _, fetch_logs, _):
1313

1414
launch_log, finish_log = False, False
1515
while not (launch_log and finish_log):

tests/tests_app_examples/test_argparse.py renamed to tests/tests_examples_app/public/test_argparse.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import os
22
import sys
33

4-
from lightning_app import _PROJECT_ROOT
4+
from tests_examples_app.public import _PATH_EXAMPLES
5+
56
from lightning_app.testing.testing import application_testing
67
from lightning_app.utilities.load_app import _patch_sys_argv
78

@@ -10,7 +11,7 @@ def test_app_argparse_example():
1011
original_argv = sys.argv
1112

1213
command_line = [
13-
os.path.join(_PROJECT_ROOT, "examples/app_argparse/app.py"),
14+
os.path.join(_PATH_EXAMPLES, "app_argparse", "app.py"),
1415
"--app_args",
1516
"--use_gpu",
1617
"--without-server",

0 commit comments

Comments
 (0)