Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .azure/app-cloud-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pr:
- "src/lightning/__version__.py"
- "src/lightning/app/**"
- "src/lightning_app/*"
- "examples/app/**"
- "requirements/app/**"
- "tests/integrations_app/**"
- "setup.py"
Expand Down Expand Up @@ -163,14 +164,14 @@ jobs:
# This test is very important to test the main user story of lightning app.
# It also e2e tests running on cloud without installing dependencies.
- bash: |
rm -rf examples/lightning-quick-start || true
git clone https://github.com/Lightning-AI/lightning-quick-start examples/lightning-quick-start
rm -rf examples/app/lightning-quick-start || true
git clone https://github.com/Lightning-AI/lightning-quick-start examples/app/lightning-quick-start
condition: eq(variables['name'], 'quick_start')
displayName: 'Clone Quick start Repo'

- bash: |
rm -rf examples/app_template_react_ui || true
git clone https://github.com/Lightning-AI/lightning-template-react examples/app_template_react_ui
rm -rf examples/app/template_react_ui || true
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'

Expand All @@ -186,7 +187,7 @@ jobs:
displayName: 'List pip dependency'

- bash: |
ls -l examples/$(TEST_APP_NAME)
ls -l examples/app/$(TEST_APP_NAME)
echo ${TEST_FILE}
python -m pytest ${TEST_FILE}::test_$(TEST_APP_NAME)_example_cloud \
--timeout=540 --capture=no -v --color=yes
Expand Down
3 changes: 2 additions & 1 deletion .github/checkgroup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ subprojects:
- "src/lightning_app/*"
- "tests/integrations_app/**"
- "!tests/integrations_app/flagship/**"
- "examples/app_*/**"
- "examples/app/**"
- "requirements/app/**"
- "setup.py"
- "!requirements/*/docs.txt"
Expand Down Expand Up @@ -348,6 +348,7 @@ subprojects:
- "src/lightning/__version__.py"
- "src/lightning/app/**"
- "src/lightning_app/*"
- "examples/app/**"
- "requirements/app/**"
- "tests/integrations_app/**"
- "!tests/integrations_app/flagship/**"
Expand Down
4 changes: 2 additions & 2 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ app:
- 'tests/tests_app/**'
- 'tests/integrations_app/**'
- 'tests/integrations_app_examples/**'
- 'examples/app_*/**'
- 'examples/app/**'
- 'docs/source-app/**'
- 'requirements/app/**'

Expand All @@ -13,7 +13,7 @@ pl:
- "src/pytorch_lightning/*"
- 'tests/tests_pytorch/**'
- 'tests/legacy/**'
- 'examples/pl_*/**'
- 'examples/pytorch/**'
- 'docs/source-pytorch/**'
- 'requirements/pytorch/**'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-examples-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
- "src/lightning_app/*"
- "tests/integrations_app/**"
- "!tests/integrations_app/flagship/**"
- "examples/app_*/**"
- "examples/app/**"
- "requirements/app/**"
- "setup.py"
- "!requirements/*/docs.txt"
Expand Down
6 changes: 3 additions & 3 deletions docs/source-app/examples/dag/dag_from_scratch.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ First, let's define the component we need:
* Processing is responsible to execute a ``processing.py`` script.
* A collection of model work to train all models in parallel.

.. literalinclude:: ../../../examples/app_dag/app.py
.. literalinclude:: ../../../../examples/app/dag/app.py
:lines: 53-75

And its run method executes the steps described above.

.. literalinclude:: ../../../examples/app_dag/app.py
.. literalinclude:: ../../../../examples/app/dag/app.py
:lines: 77-100

----
Expand All @@ -49,5 +49,5 @@ And its run method executes the steps described above.
Step 2: Define the scheduling
*****************************

.. literalinclude:: ../../../examples/app_dag/app.py
.. literalinclude:: ../../../../examples/app/dag/app.py
:lines: 103-132
2 changes: 1 addition & 1 deletion docs/source-app/glossary/storage/drive_content.rst
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ In the example below, the Drive is created by the Flow and passed to its Works.

The ``Work_1`` put a file **a.txt** in the **Drive("lit://this_drive_id")** and the ``Work_2`` can list and get the **a.txt** file from it.

.. literalinclude:: ../../../examples/app_drive/app.py
.. literalinclude:: ../../../../examples/app/drive/app.py

----

Expand Down
2 changes: 1 addition & 1 deletion docs/source-app/glossary/storage/drive_content_old.rst
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ In the example below, the Drive is created by the flow and passed to its Lightni

The ``Work_1`` put a file **a.txt** in the **Drive("lit://this_drive_id")** and the ``Work_2`` can list and get the **a.txt** file from it.

.. literalinclude:: ../../../examples/app_drive/app.py
.. literalinclude:: ../../../../examples/app/drive/app.py


----
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# app.py
# !curl https://raw.githubusercontent.com/Lightning-AI/lightning/master/examples/app_multi_node/pl_boring_script.py -o pl_boring_script.py
# !curl https://raw.githubusercontent.com/Lightning-AI/lightning/master/examples/app/multi_node/pl_boring_script.py -o pl_boring_script.py
import lightning as L
from lightning.app.components.training import LightningTrainerScript

Expand Down
10 changes: 5 additions & 5 deletions docs/source-app/moving_to_the_cloud.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ Without doing this conscientiously for every single path, your application will
In the example below, a file written by **SourceFileWork** is being transferred by the flow
to the **DestinationFileAndServeWork** work. The Path object is the reference to the file.

.. literalinclude:: ../examples/app_boring/app.py
.. literalinclude:: ../../examples/app/boring/app.py
:emphasize-lines: 5, 22, 28, 48

In the ``scripts/serve.py`` file, we are creating a **FastApi Service** running on port ``1111``
that returns the content of the file received from **SourceFileWork** when
a post request is sent to ``/file``.

.. literalinclude:: ../examples/app_boring/scripts/serve.py
.. literalinclude:: ../../examples/app/boring/scripts/serve.py
:emphasize-lines: 21, 23-26

----
Expand All @@ -64,22 +64,22 @@ In order to assemble them, you need to do two things:

Here's how to expose the port:

.. literalinclude:: ../examples/app_boring/app.py
.. literalinclude:: ../../examples/app/boring/app.py
:emphasize-lines: 8
:lines: 33-44


And here's how to expose your services within the ``configure_layout`` flow hook:

.. literalinclude:: ../examples/app_boring/app.py
.. literalinclude:: ../../examples/app/boring/app.py
:emphasize-lines: 5
:lines: 53-57

In this example, we're appending ``/file`` to our **FastApi Service** url.
This means that our ``Boring Tab`` triggers the ``get_file_content`` from the **FastAPI Service**
and embeds its content as an `IFrame <https://en.wikipedia.org/wiki/HTML_element#Frames>`_.

.. literalinclude:: ../examples/app_boring/scripts/serve.py
.. literalinclude:: ../../examples/app/boring/scripts/serve.py
:lines: 23-26


Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
Empty file removed examples/app_layout/__init__.py
Empty file.
Empty file removed examples/app_v0/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion src/lightning/app/components/python/popen.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def __init__(

In this example, the script will be launch with the :class:`~subprocess.Popen`.

.. literalinclude:: ../../../examples/app_components/python/component_popen.py
.. literalinclude:: ../../../../examples/app/components/python/component_popen.py
:language: python
"""
super().__init__(**kwargs)
Expand Down
4 changes: 2 additions & 2 deletions src/lightning/app/components/python/tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ def __init__(
Even more interesting, this component works for ANY PyTorch Lightning script and
its state can be used in real time in a UI.

.. literalinclude:: ../../../examples/app_components/python/component_tracer.py
.. literalinclude:: ../../../../examples/app/components/python/component_tracer.py
:language: python


Once implemented, this component can easily be integrated within a larger app
to execute a specific python script.

.. literalinclude:: ../../../examples/app_components/python/app.py
.. literalinclude:: ../../../../examples/app/components/python/app.py
:language: python
"""
super().__init__(**kwargs)
Expand Down
2 changes: 1 addition & 1 deletion src/lightning/app/components/serve/gradio_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ServeGradio(LightningWork, abc.ABC):

In the example below, the ``ServeGradio`` is subclassed to deploy ``AnimeGANv2``.

.. literalinclude:: ../../../examples/app_components/serve/gradio/app.py
.. literalinclude:: ../../../../examples/app/components/serve/gradio/app.py
:language: python

The result would be the following:
Expand Down
2 changes: 1 addition & 1 deletion src/lightning/app/core/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ def run(self):
:header: Build your own DAG
:description: Learn more DAG scheduling with examples.
:col_css: col-md-4
:button_link: ../../../examples/app_dag/dag.html
:button_link: ../../../examples/app/dag/dag.html
:height: 180
:tag: Basic

Expand Down
2 changes: 1 addition & 1 deletion tests/integrations_app/public/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from pathlib import Path

_PATH_EXAMPLES = Path(__file__).resolve().parents[3] / "examples"
_PATH_EXAMPLES = Path(__file__).resolve().parents[3] / "examples" / "app"
2 changes: 1 addition & 1 deletion tests/integrations_app/public/test_app_dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@pytest.mark.cloud
def test_app_dag_example_cloud() -> None:
with run_app_in_cloud(os.path.join(_PATH_EXAMPLES, "app_dag")) as (_, _, fetch_logs, _):
with run_app_in_cloud(os.path.join(_PATH_EXAMPLES, "dag")) as (_, _, fetch_logs, _):

launch_log, finish_log = False, False
while not (launch_log and finish_log):
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations_app/public/test_argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def test_app_argparse_example():
original_argv = sys.argv

command_line = [
os.path.join(_PATH_EXAMPLES, "app_argparse", "app.py"),
os.path.join(_PATH_EXAMPLES, "argparse", "app.py"),
"--app_args",
"--use_gpu",
"--without-server",
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations_app/public/test_boring_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@pytest.mark.cloud
def test_boring_app_example_cloud() -> None:
with run_app_in_cloud(os.path.join(_PATH_EXAMPLES, "app_boring"), app_name="app_dynamic.py", debug=True) as (
with run_app_in_cloud(os.path.join(_PATH_EXAMPLES, "boring"), app_name="app_dynamic.py", debug=True) as (
_,
view_page,
_,
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations_app/public/test_commands_and_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@pytest.mark.timeout(300)
@pytest.mark.cloud
def test_commands_and_api_example_cloud() -> None:
with run_app_in_cloud(os.path.join(_PATH_EXAMPLES, "app_commands_and_api")) as (
with run_app_in_cloud(os.path.join(_PATH_EXAMPLES, "commands_and_api")) as (
_,
view_page,
fetch_logs,
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations_app/public/test_drive.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@pytest.mark.cloud
def test_drive_example_cloud() -> None:
with run_app_in_cloud(os.path.join(_PATH_EXAMPLES, "app_drive")) as (
with run_app_in_cloud(os.path.join(_PATH_EXAMPLES, "drive")) as (
_,
_,
fetch_logs,
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations_app/public/test_gradio.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class MyGradioServe(ServeGradio):

inputs = gradio_mock.inputs.Image(type="pil")
outputs = gradio_mock.outputs.Image(type="pil")
examples = [["./examples/app_components/serve/gradio/beyonce.png"]]
examples = [["./examples/app/components/serve/gradio/beyonce.png"]]

def build_model(self):
super().build_model()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
def test_installation_commands_app_example_cloud() -> None:
# This is expected to pass, since the "setup" flag is passed
with run_app_in_cloud(
os.path.join(_PATH_EXAMPLES, "app_installation_commands"),
os.path.join(_PATH_EXAMPLES, "installation_commands"),
app_name="app.py",
extra_args=["--setup"],
debug=True,
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations_app/public/test_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_layout_example():
result = runner.invoke(
run_app,
[
os.path.join(_PATH_EXAMPLES, "app_layout", "app.py"),
os.path.join(_PATH_EXAMPLES, "layout", "app.py"),
"--blocking",
"False",
"--open-ui",
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations_app/public/test_multi_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_multi_node_examples(_, app_name, monkeypatch):
# rewritten to use `lightning.app` imports (CI does this)
# * if you installed `lightning`, then the imports in this file and mocks
# need to be changed to use `lightning`.
monkeypatch.chdir(os.path.join(_PATH_EXAMPLES, "app_multi_node"))
monkeypatch.chdir(os.path.join(_PATH_EXAMPLES, "multi_node"))
command_line = [app_name, "--blocking", "False", "--open-ui", "False", "--setup"]
result = application_testing(LightningTestMultiNodeApp, command_line)
assert result.exit_code == 0
2 changes: 1 addition & 1 deletion tests/integrations_app/public/test_payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@pytest.mark.cloud
def test_payload_example_cloud() -> None:
with run_app_in_cloud(os.path.join(_PATH_EXAMPLES, "app_payload")) as (_, _, fetch_logs, _):
with run_app_in_cloud(os.path.join(_PATH_EXAMPLES, "payload")) as (_, _, fetch_logs, _):

has_logs = False
while not has_logs:
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations_app/public/test_pickle_or_not.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_pickle_or_not_example():
result = runner.invoke(
run_app,
[
os.path.join(_PATH_EXAMPLES, "app_pickle_or_not", "app.py"),
os.path.join(_PATH_EXAMPLES, "pickle_or_not", "app.py"),
"--blocking",
"False",
"--open-ui",
Expand Down
4 changes: 2 additions & 2 deletions tests/integrations_app/public/test_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
],
)
def test_scripts(file):
_run_script(str(os.path.join(_PATH_EXAMPLES, f"app_components/python/{file}")))
_run_script(str(os.path.join(_PATH_EXAMPLES, f"components/python/{file}")))


@pytest.mark.skip(reason="causing some issues with CI, not sure if the test is actually needed")
Expand All @@ -28,7 +28,7 @@ def test_components_app_example():
result = runner.invoke(
run_app,
[
os.path.join(_PATH_EXAMPLES, "app_components/python/app.py"),
os.path.join(_PATH_EXAMPLES, "components/python/app.py"),
"--blocking",
"False",
"--open-ui",
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations_app/public/test_template_react_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@pytest.mark.cloud
def test_template_react_ui_example_cloud() -> None:
"""This test ensures streamlit works in the cloud by clicking a button and checking the logs."""
with run_app_in_cloud(os.path.join(_PATH_EXAMPLES, "app_template_react_ui")) as (
with run_app_in_cloud(os.path.join(_PATH_EXAMPLES, "template_react_ui")) as (
_,
view_page,
fetch_logs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@pytest.mark.cloud
def test_template_streamlit_ui_example_cloud() -> None:
"""This test ensures streamlit works in the cloud by clicking a button and checking the logs."""
with run_app_in_cloud(os.path.join(_PATH_EXAMPLES, "app_template_streamlit_ui")) as (
with run_app_in_cloud(os.path.join(_PATH_EXAMPLES, "template_streamlit_ui")) as (
_,
view_page,
fetch_logs,
Expand Down
10 changes: 5 additions & 5 deletions tests/integrations_app/public/test_v0_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def run_once(self) -> Tuple[bool, float]:

def test_v0_app_example():
command_line = [
os.path.join(_PATH_EXAMPLES, "app_v0", "app.py"),
os.path.join(_PATH_EXAMPLES, "v0", "app.py"),
"--blocking",
"False",
"--open-ui",
Expand Down Expand Up @@ -65,15 +65,15 @@ def check_content(button_name, text_content):
)
def test_v0_app_example_byoc_cloud() -> None:
with run_app_in_cloud(
os.path.join(_PATH_EXAMPLES, "app_v0"),
os.path.join(_PATH_EXAMPLES, "v0"),
extra_args=["--cluster-id", os.environ.get("LIGHTNING_BYOC_CLUSTER_ID")],
) as (_, view_page, fetch_logs, app_name):
run_v0_app(fetch_logs, view_page)


@pytest.mark.cloud
def test_v0_app_example_cloud() -> None:
with run_app_in_cloud(os.path.join(_PATH_EXAMPLES, "app_v0")) as (
with run_app_in_cloud(os.path.join(_PATH_EXAMPLES, "v0")) as (
_,
view_page,
fetch_logs,
Expand All @@ -87,11 +87,11 @@ def test_v0_app_example_cloud() -> None:
MagicMock(side_effect=ModuleNotFoundError("Module X not found")),
)
def test_load_app_from_file_module_error():
empty_app = CloudRuntime.load_app_from_file(os.path.join(_PATH_EXAMPLES, "app_v0", "app.py"))
empty_app = CloudRuntime.load_app_from_file(os.path.join(_PATH_EXAMPLES, "v0", "app.py"))
assert isinstance(empty_app, LightningApp)
assert isinstance(empty_app.root, EmptyFlow)


def test_load_app_from_file():
app = load_app_from_file(os.path.join(_PATH_EXAMPLES, "app_v0", "app.py"))
app = load_app_from_file(os.path.join(_PATH_EXAMPLES, "v0", "app.py"))
assert isinstance(app, LightningApp)
Loading