VYPR
Critical severityNVD Advisory· Published Jun 6, 2024· Updated Oct 15, 2025

RCE via Property/Class Pollution in lightning-ai/pytorch-lightning

CVE-2024-5452

Description

A remote code execution (RCE) vulnerability exists in the lightning-ai/pytorch-lightning library version 2.2.1 due to improper handling of deserialized user input and mismanagement of dunder attributes by the deepdiff library. The library uses deepdiff.Delta objects to modify application state based on frontend actions. However, it is possible to bypass the intended restrictions on modifying dunder attributes, allowing an attacker to construct a serialized delta that passes the deserializer whitelist and contains dunder attributes. When processed, this can be exploited to access other modules, classes, and instances, leading to arbitrary attribute write and total RCE on any self-hosted pytorch-lightning application in its default configuration, as the delta endpoint is enabled by default.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
lightningPyPI
< 2.3.32.3.3

Affected products

1

Patches

1
330af381de88

Remove the lightning app code (#20039)

300 files changed · +15 16635
  • .actions/assistant.py+1 32 modified
    @@ -14,10 +14,8 @@
     import glob
     import logging
     import os
    -import pathlib
     import re
     import shutil
    -import tarfile
     import tempfile
     import urllib.request
     from distutils.version import LooseVersion
    @@ -35,11 +33,6 @@
             "requirements/pytorch/strategies.txt",
             "requirements/pytorch/examples.txt",
         ),
    -    "app": (
    -        "requirements/app/app.txt",
    -        "requirements/app/cloud.txt",
    -        "requirements/app/ui.txt",
    -    ),
         "fabric": (
             "requirements/fabric/base.txt",
             "requirements/fabric/strategies.txt",
    @@ -216,30 +209,6 @@ def distribute_version(src_folder: str, ver_file: str = "version.info") -> None:
             shutil.copy2(ver_template, fpath)
     
     
    -def _download_frontend(pkg_path: str, version: str = "v0.0.0"):
    -    """Downloads an archive file for a specific release of the Lightning frontend and extracts it to the correct
    -    directory."""
    -
    -    try:
    -        frontend_dir = pathlib.Path(pkg_path, "ui")
    -        download_dir = tempfile.mkdtemp()
    -
    -        shutil.rmtree(frontend_dir, ignore_errors=True)
    -        # TODO: remove this once lightning-ui package is ready as a dependency
    -        frontend_release_url = f"https://lightning-packages.s3.amazonaws.com/ui/{version}.tar.gz"
    -        response = urllib.request.urlopen(frontend_release_url)
    -
    -        file = tarfile.open(fileobj=response, mode="r|gz")
    -        file.extractall(path=download_dir)  # noqa: S202
    -
    -        shutil.move(download_dir, frontend_dir)
    -        print("The Lightning UI has successfully been downloaded!")
    -
    -    # If installing from source without internet connection, we don't want to break the installation
    -    except Exception:
    -        print("The Lightning UI downloading has failed!")
    -
    -
     def _load_aggregate_requirements(req_dir: str = "requirements", freeze_requirements: bool = False) -> None:
         """Load all base requirements from all particular packages and prune duplicates.
     
    @@ -466,7 +435,7 @@ def pull_docs_files(
                     raise RuntimeError(f"Requesting file '{zip_url}' does not exist or it is just unavailable.")
     
                 with zipfile.ZipFile(zip_file, "r") as zip_ref:
    -                zip_ref.extractall(tmp)  # noqa: S202
    +                zip_ref.extractall(tmp)
     
                 zip_dirs = [d for d in glob.glob(os.path.join(tmp, "*")) if os.path.isdir(d)]
                 # check that the extracted archive has only repo folder
    
  • .azure/app-cloud-e2e.yml+0 206 removed
    @@ -1,206 +0,0 @@
    -# 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/*"
    -
    -schedules:
    -  - cron: "0 0 * * *" # At the end of every day
    -    displayName: Daily midnight testing
    -    branches:
    -      include:
    -        - "master"
    -
    -pr:
    -  branches:
    -    include:
    -      - "master"
    -      - "release/*"
    -  paths:
    -    include:
    -      - ".actions/*"
    -      - ".azure/app-cloud-e2e.yml"
    -      - "src/lightning/__about__.py"
    -      - "src/lightning/__init__.py"
    -      - "src/lightning/__main__.py"
    -      - "src/lightning/__setup__.py"
    -      - "src/lightning/__version__.py"
    -      - "src/lightning/app/**"
    -      - "src/lightning_app/*"
    -      - "examples/app/**"
    -      - "requirements/app/**"
    -      - "tests/integrations_app/**"
    -      - "setup.py"
    -    exclude:
    -      - "!tests/integrations_app/flagship/**"
    -      - "requirements/*/docs.txt"
    -      - "*.md"
    -      - "**/*.md"
    -
    -# 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)
    -  - name: video_artifact_dir
    -    value: ./videos
    -
    -jobs:
    -  - job: test_e2e
    -    pool: "azure-cpus"
    -    container:
    -      # see all available tags: https://mcr.microsoft.com/en-us/product/playwright/python/tags
    -      image: mcr.microsoft.com/playwright/python:v1.38.0-focal
    -      options: "--shm-size=4gb"
    -    strategy:
    -      matrix:
    -        "App: v0_app":
    -          name: "v0_app"
    -          dir: "public"
    -        "App: boring_app":
    -          name: "boring_app"
    -          dir: "public"
    -        "App: template_streamlit_ui":
    -          name: "template_streamlit_ui"
    -          dir: "public"
    -        "App: template_react_ui":
    -          name: "template_react_ui"
    -          dir: "public"
    -        # 'App: template_jupyterlab':  # TODO: clarify where these files lives
    -        #   name: "template_jupyterlab"
    -        "App: installation_commands_app":
    -          name: "installation_commands_app"
    -          dir: "public"
    -        "App: drive":
    -          name: "drive"
    -          dir: "public"
    -        "App: payload":
    -          name: "payload"
    -          dir: "public"
    -        "App: commands_and_api":
    -          name: "commands_and_api"
    -          dir: "public"
    -        "App: quick_start":
    -          name: "quick_start"
    -          dir: "public"
    -        "App: idle_timeout":
    -          name: "idle_timeout"
    -          dir: "local"
    -        "App: collect_failures":
    -          name: "collect_failures"
    -          dir: "local"
    -        "App: custom_work_dependencies":
    -          name: "custom_work_dependencies"
    -          dir: "local"
    -    timeoutInMinutes: "15"
    -    cancelTimeoutInMinutes: "1"
    -    # values: https://docs.microsoft.com/en-us/azure/devops/pipelines/process/phases?view=azure-devops&tabs=yaml#workspace
    -    workspace:
    -      clean: all
    -    variables:
    -      FREEZE_REQUIREMENTS: "1"
    -      HEADLESS: "1"
    -      PACKAGE_LIGHTNING: "1"
    -      CLOUD: "1"
    -      VIDEO_LOCATION: $(video_artifact_dir)
    -      PR_NUMBER: $(local_id)
    -      TEST_APP_NAME: $(name)
    -      TEST_APP_FOLDER: $(dir)
    -      HAR_LOCATION: "./artifacts/hars"
    -      SLOW_MO: "50"
    -      LIGHTNING_DEBUG: "1"
    -    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
    -          mkdir -p "$(video_artifact_dir)/$(name)"
    -          printf "local id: $(local_id)\n"
    -          python --version
    -          pip --version
    -          echo "allow fail: ${{ in(variables['name'], 'quick_start', 'template_react_ui') }}"
    -        displayName: "Info"
    -
    -      # TODO: we are testing it as `lightning`, so add also version for `lightning_app`
    -      - bash: |
    -          pip install -e .[app-dev] \
    -            -f https://download.pytorch.org/whl/cpu/torch_stable.html
    -        displayName: "Install Lightning & dependencies"
    -
    -      - bash: python -m playwright install # --with-deps
    -        displayName: "Install Playwright system dependencies"
    -
    -      # The magic happens here it doesn't need to install the quick start dependencies.
    -      # 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: |
    -          git clone https://github.com/Lightning-AI/lightning-quick-start examples/app/quick-start
    -        # without succeeded this could run even if the job has already failed
    -        condition: and(succeeded(), eq(variables['name'], 'quick_start'))
    -        displayName: "Clone Quick start Repo"
    -      - bash: |
    -          git clone https://github.com/Lightning-AI/lightning-template-react examples/app/template_react_ui
    -        # without succeeded this could run even if the job has already failed
    -        condition: and(succeeded(), eq(variables['name'], 'template_react_ui'))
    -        displayName: "Clone Template React UI Repo"
    -
    -      # Replace imports to use `lightning` instead of `lightning_app` since we install lightning only ATM
    -      - bash: |
    -          pip install -q -r .actions/requirements.txt
    -          python .actions/assistant.py copy_replace_imports \
    -            --source_dir="./examples" --source_import="lightning_app" --target_import="lightning.app"
    -        displayName: "Adjust examples"
    -
    -      - bash: pip --version && pip list
    -        displayName: "List pip dependency"
    -
    -      - bash: |
    -          ls -l examples/app/$(TEST_APP_NAME)
    -          echo ${TEST_FILE}
    -          python -m pytest ${TEST_FILE}::test_$(TEST_APP_NAME)_example_cloud \
    -            --timeout=360 --capture=no -v --color=yes
    -        env:
    -          TEST_FILE: tests/integrations_app/$(TEST_APP_FOLDER)/test_$(TEST_APP_NAME).py
    -          #LAI_USER: $(LAI_USER)  # for STAGING
    -          #LAI_PASS: $(LAI_PASS)  # for STAGING
    -          LIGHTNING_USER_ID: $(LIGHTNING_USER_ID_PROD)
    -          LIGHTNING_API_KEY: $(LIGHTNING_API_KEY_PROD)
    -          LIGHTNING_USERNAME: $(LIGHTNING_USERNAME_PROD)
    -          LIGHTNING_CLOUD_URL: $(LIGHTNING_CLOUD_URL_PROD)
    -        # Todo: investigate why these apps are failing
    -        continueOnError: ${{ in(variables['name'], 'quick_start', 'template_react_ui') }}
    -        displayName: "Run the tests"
    -
    -      - task: PublishPipelineArtifact@1
    -        condition: failed()
    -        inputs:
    -          path: "$(video_artifact_dir)/$(name)"
    -          artifactName: $(name)
    -          publishLocation: "pipeline"
    -        displayName: "Publish videos"
    -
    -      - bash: |
    -          time python -c "from lightning.app import testing; testing.delete_cloud_lightning_apps()"
    -        condition: always()
    -        continueOnError: "true"
    -        timeoutInMinutes: "3"
    -        env:
    -          #LAI_USER: $(LAI_USER)  # for STAGING
    -          #LAI_PASS: $(LAI_PASS)  # for STAGING
    -          LIGHTNING_USER_ID: $(LIGHTNING_USER_ID_PROD)
    -          LIGHTNING_API_KEY: $(LIGHTNING_API_KEY_PROD)
    -          LIGHTNING_USERNAME: $(LIGHTNING_USERNAME_PROD)
    -          LIGHTNING_CLOUD_URL: $(LIGHTNING_CLOUD_URL_PROD)
    -        displayName: "Clean Previous Apps"
    
  • docs/crossroad.html+0 1 modified
    @@ -9,7 +9,6 @@
         </style>
       </head>
       <body>
    -    <a href="app/"><button>App</button></a>
         <a href="fabric/"><button>Fabric</button></a>
         <a href="pytorch/"><button>PyTorch</button></a>
       </body>
    
  • docs/rtfd-build.sh+1 1 modified
    @@ -5,7 +5,7 @@ if ! [ $READTHEDOCS_VERSION == "latest" -o $READTHEDOCS_VERSION == "stable" ];
     then
         export FAST_DOCS_DEV=1 ;
         root=$(pwd) ;
    -    for pkg in 'app' 'fabric' 'pytorch' ;
    +    for pkg in 'fabric' 'pytorch' ;
         do
           cd $root/docs/source-$pkg ;
           make html --jobs $(nproc) ;
    
  • docs/source-app/api_reference/components.rst+0 35 removed
    @@ -1,35 +0,0 @@
    -########################
    -lightning.app.components
    -########################
    -
    -.. contents::
    -    :depth: 1
    -    :local:
    -    :backlinks: top
    -
    -.. currentmodule:: lightning.app.components
    -
    -
    -Built-in Components
    -___________________
    -
    -.. autosummary::
    -    :toctree: generated/
    -    :nosignatures:
    -    :template: classtemplate.rst
    -
    -    ~database.client.DatabaseClient
    -    ~database.server.Database
    -    ~python.popen.PopenPythonScript
    -    ~python.tracer.TracerPythonScript
    -    ~training.LightningTrainerScript
    -    ~serve.gradio_server.ServeGradio
    -    ~serve.serve.ModelInferenceAPI
    -    ~serve.python_server.PythonServer
    -    ~serve.streamlit.ServeStreamlit
    -    ~multi_node.base.MultiNode
    -    ~multi_node.fabric.FabricMultiNode
    -    ~multi_node.pytorch_spawn.PyTorchSpawnMultiNode
    -    ~multi_node.trainer.LightningTrainerMultiNode
    -    ~serve.auto_scaler.AutoScaler
    -    ~serve.auto_scaler.ColdStartProxy
    
  • docs/source-app/api_reference/core.rst+0 26 removed
    @@ -1,26 +0,0 @@
    -:orphan:
    -
    -##################
    -lightning.app.core
    -##################
    -
    -.. contents::
    -    :depth: 1
    -    :local:
    -    :backlinks: top
    -
    -.. currentmodule:: lightning.app.core
    -
    -Core APIs
    -___________________
    -
    -.. autosummary::
    -    :toctree: api/
    -    :nosignatures:
    -    :template: classtemplate.rst
    -
    -    LightningApp
    -    LightningFlow
    -    LightningWork
    -
    -Learn more about :ref:`Lightning Core <core_api>`.
    
  • docs/source-app/api_reference/frontend.rst+0 25 removed
    @@ -1,25 +0,0 @@
    -######################
    -lightning.app.frontend
    -######################
    -
    -.. contents::
    -    :depth: 1
    -    :local:
    -    :backlinks: top
    -
    -.. currentmodule:: lightning.app.frontend
    -
    -Lightning FrontEnds
    -___________________
    -
    -.. autosummary::
    -    :toctree: generated/
    -    :nosignatures:
    -    :template: classtemplate.rst
    -
    -    ~frontend.Frontend
    -    ~web.StaticWebFrontend
    -    ~stream_lit.StreamlitFrontend
    -    ~panel.PanelFrontend
    -
    -Learn more about :ref:`Frontend's <ui_and_frontends>`.
    
  • docs/source-app/api_reference/runners.rst+0 21 removed
    @@ -1,21 +0,0 @@
    -#####################
    -lightning.app.runners
    -#####################
    -
    -.. contents::
    -    :depth: 1
    -    :local:
    -    :backlinks: top
    -
    -.. currentmodule:: lightning.app.runners
    -
    -Lightning Core
    -______________
    -
    -.. autosummary::
    -    :toctree: generated/
    -    :nosignatures:
    -    :template: classtemplate.rst
    -
    -    ~cloud.CloudRuntime
    -    ~multiprocess.MultiProcessRuntime
    
  • docs/source-app/api_reference/storage.rst+0 71 removed
    @@ -1,71 +0,0 @@
    -#####################
    -lightning.app.storage
    -#####################
    -
    -Lightning Core
    -______________
    -
    -.. contents::
    -    :depth: 1
    -    :local:
    -    :backlinks: top
    -
    -.. currentmodule:: lightning.app.storage
    -
    -.. autosummary::
    -    :toctree: generated/
    -    :nosignatures:
    -    :template: classtemplate.rst
    -
    -    ~path.Path
    -    ~drive.Drive
    -    ~payload.Payload
    -    ~mount.Mount
    -
    -----
    -
    -************************
    -Learn more about Storage
    -************************
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: Learn about the differences between Drive vs Path.
    -   :description: Learn about their differences.
    -   :col_css: col-md-4
    -   :button_link: ../glossary/storage/differences.html
    -   :height: 180
    -   :tag: Basic
    -
    -.. displayitem::
    -   :header: The Drive Object.
    -   :description: Put, List and Get Files From a Shared Drive Disk.
    -   :col_css: col-md-4
    -   :button_link:  ../glossary/storage/drive.html
    -   :height: 180
    -   :tag: Basic
    -
    -.. displayitem::
    -   :header: The Path Object.
    -   :description: Transfer Files From One Component to Another by Reference.
    -   :col_css: col-md-4
    -   :button_link:  ../glossary/storage/path.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -.. displayitem::
    -   :header: The Mount Object.
    -   :description: Mount an AWS S3 Bucket When Running on the Cloud.
    -   :col_css: col-md-4
    -   :button_link:  ../workflows/mount_aws_s3_bucket.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/basics.rst+0 259 removed
    @@ -1,259 +0,0 @@
    -:orphan:
    -
    -.. _basics:
    -
    -######
    -Basics
    -######
    -
    -In this guide, we'll cover the basic terminology associated with the Lightning framework.
    -
    -----
    -
    -**************
    -Lightning App
    -**************
    -
    -The :class:`~lightning.app.core.app.LightningApp` runs a tree of one or more components that interact to create end-to-end applications. There are two kinds of components: :class:`~lightning.app.core.flow.LightningFlow` and :class:`~lightning.app.core.work.LightningWork`. This modular design enables you to reuse components created by other users.
    -
    -----
    -
    -Lightning Work
    -^^^^^^^^^^^^^^
    -
    -The :class:`~lightning.app.core.work.LightningWork` component is a building block optimized for long-running jobs or integrating third-party services. LightningWork can be used for training large models, downloading a dataset, or any long-lasting operation.
    -
    -----
    -
    -Lightning Flow
    -^^^^^^^^^^^^^^
    -
    -The :class:`~lightning.app.core.flow.LightningFlow` component coordinates long-running tasks :class:`~lightning.app.core.work.LightningWork` and runs its children :class:`~lightning.app.core.flow.LightningFlow` components.
    -
    -----
    -
    -Lightning App Tree
    -^^^^^^^^^^^^^^^^^^
    -
    -Components can be nested to form component trees where the LightningFlows are its branches and LightningWorks are its leaves.
    -
    -Here's a basic application with four flows and two works:
    -
    -.. literalinclude:: code_samples/quickstart/app_comp.py
    -
    -And here's its associated tree structure:
    -
    -.. figure:: https://pl-public-data.s3.amazonaws.com/assets_lightning/tree.gif
    -    :alt: Basic App Components
    -    :width: 100 %
    -
    -A Lightning App runs all flows into a single process. Its flows coordinate the execution of the works each running in their own independent processes.
    -
    -----
    -
    -Lightning Distributed Event Loop
    -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    -
    -Drawing inspiration from modern web frameworks like `React.js <https://reactjs.org/>`_, the Lightning app runs all flows in an **event loop** (forever), which is triggered every 0.1 seconds after collecting any works' state change.
    -
    -.. figure::  https://pl-public-data.s3.amazonaws.com/assets_lightning/lightning_loop.gif
    -
    -When running an app in the cloud, the :class:`~lightning.app.core.work.LightningWork` run on different machines. Lightning communicates any :class:`~lightning.app.core.work.LightningWork` state changes to the **event loop** which re-executes the flow with the newly-collected works' state.
    -
    -----
    -
    -Lightning App State
    -^^^^^^^^^^^^^^^^^^^
    -
    -By design, each component is stateful and its state is composed of all its attributes. The **Lightning App State** is the collection of all its components state.
    -
    -With this mechanism, any component can **react** to any other component **state changes**, simply by relying on its attributes within the flow.
    -
    -For example, here we define two flow components, **RootFlow** and **ChildFlow**, where the child flow prints and increments a counter indefinitely and gets reflected in **RootFlow** state.
    -
    -You can easily check the state of your entire app:
    -
    -.. literalinclude:: code_samples/quickstart/app_01.py
    -
    -Here's the entire tree structure associated with your app:
    -
    -.. figure:: https://pl-public-data.s3.amazonaws.com/assets_lightning/parent_child.png
    -    :alt: Parent Child Components
    -    :width: 100 %
    -
    -And here's the output you get when running the above application using **Lightning CLI**:
    -
    -.. code-block:: console
    -
    -    $ lightning_app run app docs/source/code_samples/quickstart/app_01.py
    -      INFO: Your app has started. View it in your browser: http://127.0.0.1:7501/view
    -      State: {'works': {'w_1': {'vars': {'counter': 1}}, 'w_2': {'vars': {'counter': 0}}}}
    -
    -      State: {'works': {'w_1': {'vars': {'counter': 3}}, 'w_2': {'vars': {'counter': 1}}}}
    -
    -      State: {'works': {'w_1': {'vars': {'counter': 4}}, 'w_2': {'vars': {'counter': 1}}}}
    -
    -      State: {'works': {'w_1': {'vars': {'counter': 5}}, 'w_2': {'vars': {'counter': 2}}}}
    -
    -      State: {'works': {'w_1': {'vars': {'counter': 6}}, 'w_2': {'vars': {'counter': 2}}}}
    -
    -      State: {'works': {'w_1': {'vars': {'counter': 7}}, 'w_2': {'vars': {'counter': 3}}}}
    -      ...
    -
    -This app will count forever because the **lightning event loop** indefinitely calls the root flow run method.
    -
    -----
    -
    -*******************************
    -Controlling the Execution Flow
    -*******************************
    -
    -
    -LightningWork: To Cache or Not to Cache Calls
    -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    -
    -With Lightning, you can control how to run your components.
    -
    -By default, the :class:`~lightning.app.core.flow.LightningFlow` is executed infinitely by the **Lightning Infinite Loop** and the :class:`~lightning.app.core.work.LightningWork` does not run in **parallel**,
    -meaning the **Lightning Infinite Loop** (a.k.a the flow) waits until that long-running work is completed to continue.
    -
    -Similar to `React.js Components and Props <https://reactjs.org/docs/components-and-props.html>`_, the :class:`~lightning.app.core.work.LightningWork`
    -component accepts arbitrary inputs (the "props") to its **run** method and by default runs **once** for each unique input provided.
    -
    -Here's an example of this behavior:
    -
    -.. literalinclude:: code_samples/basics/0.py
    -    :language: python
    -    :emphasize-lines: 10, 19
    -
    -And you should see the following by running the code above:
    -
    -.. code-block:: console
    -
    -    $ python example.py
    -      INFO: Your app has started. View it in your browser: http://127.0.0.1:7501/view
    -      # After you have clicked `run` on the UI.
    -      I received the following props: args: () kwargs: {'value': 1}
    -      I received the following props: args: () kwargs: {'value': 10}
    -
    -As you can see, the intermediate run didn't execute as already cached.
    -
    -To disable this behavior, set ``cache_calls=False`` to make any LightningWork run infinitely.
    -
    -.. literalinclude:: code_samples/basics/1.py
    -    :diff: code_samples/basics/0.py
    -
    -.. code-block:: console
    -
    -    $ python example.py
    -      INFO: Your app has started. View it in your browser: http://127.0.0.1:7501/view
    -      # After you have clicked `run` on the UI.
    -      I received the following props: args: () kwargs: {'value': 1}
    -      I received the following props: args: () kwargs: {'value': 1}
    -      I received the following props: args: () kwargs: {'value': 1}
    -      I received the following props: args: () kwargs: {'value': 1}
    -      I received the following props: args: () kwargs: {'value': 1}
    -      I received the following props: args: () kwargs: {'value': 10}
    -
    -
    -.. note:: Passing a sequence of different props to the work run method queues their execution. We recommend avoiding this behavior as it can be hard to debug. Instead, wait for the previous run to execute.
    -
    -----
    -
    -LightningWork: Parallel vs Non Parallel
    -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    -
    -The LightningWork component is made for long-running jobs.
    -
    -As an example, let's create a long-running **LightningWork** component that will take 1 hour to do its "work".
    -
    -.. literalinclude:: code_samples/quickstart/app_02.py
    -    :language: python
    -    :emphasize-lines: 15
    -
    -Here's the output you get when running the above application using **Lightning CLI**:
    -
    -.. code-block:: console
    -
    -    $ lightning_app run app docs/source/code_samples/quickstart/app_02.py
    -      INFO: Your app has started. View it in your browser: http://127.0.0.1:7501/view
    -      # After you have clicked `run` on the UI.
    -      0.0 0.0
    -      ...
    -      0.0003 0.0003
    -      ...
    -      1.0 1.0
    -      ...
    -      1 hour later!
    -      1.0 1.0
    -      1 hour later!
    -      1.0 1.0
    -      1 hour later!
    -      ...
    -
    -The child work runs only once, hence why the progress counter stops increasing once the work is completed.
    -
    -This is useful for monitoring the progress of a long-running operation, like training a big model.
    -
    -.. note ::
    -    The Lightning Infinite Loop runs multiple cycles per second.
    -    It is good practice to keep the loop running fast, so that your application stays responsive,
    -    especially when it contains user-interface components.
    -
    -----
    -
    -****************
    -Multiple works
    -****************
    -
    -In practical use cases, you might want to execute multiple long-running works in parallel.
    -
    -To enable this behavior, set ``parallel=True`` in the ``__init__`` method of
    -your :class:`~lightning.app.core.work.LightningWork`.
    -
    -Here's an example of the interaction between parallel and non-parallel behaviors:
    -
    -.. figure:: https://pl-public-data.s3.amazonaws.com/assets_lightning/blocking_non_blocking.gif
    -    :alt: mnist GPU bar
    -    :width: 100 %
    -
    -Below, we reuse the **HourLongWork** work defined in the previous example, but modify the **RootFlow**
    -to run two **HourLongWork** works in a parallel way.
    -
    -.. literalinclude:: code_samples/quickstart/app/app_0.py
    -    :emphasize-lines: 21
    -
    -Above, both ``child_work_1`` and ``child_work_2`` are long-running works that are executed
    -asynchronously in parallel.
    -
    -When running the above app, we see the following logs:
    -
    -.. code-block:: console
    -
    -    $ lightning_app run app docs/source/code_samples/quickstart/app/app_0.py
    -      INFO: Your app has started. View it in your browser: http://127.0.0.1:7501/view
    -      # After you have clicked `run` on the UI.
    -      0.0, 0.0
    -      ...
    -      0.0003, 0.0003
    -      ...
    -      1.0, 1.0
    -      ...
    -      1 hour later `child_work_1` started!
    -      1 hour later `child_work_2` started!
    -      0.0, 0.0
    -      ...
    -      0.0003, 0.0003
    -      ...
    -      1.0, 1.0
    -      1 hour later `child_work_1` started!
    -      1 hour later `child_work_2` started!
    -      ...
    -
    -----
    -
    -***********
    -Next Steps
    -***********
    -
    -To keep learning about Lightning, build a :ref:`ui_and_frontends`.
    
  • docs/source-app/code_samples/basics/0.py+0 19 removed
    @@ -1,19 +0,0 @@
    -from lightning.app import LightningWork
    -
    -
    -class ExampleWork(LightningWork):
    -    def run(self, *args, **kwargs):
    -        print(f"I received the following props: args: {args} kwargs: {kwargs}")
    -
    -
    -work = ExampleWork()
    -work.run(value=1)
    -
    -# Providing the same value. This won't run as already cached.
    -work.run(value=1)
    -work.run(value=1)
    -work.run(value=1)
    -work.run(value=1)
    -
    -# Changing the provided value. This isn't cached and will run again.
    -work.run(value=10)
    
  • docs/source-app/code_samples/basics/1.py+0 22 removed
    @@ -1,22 +0,0 @@
    -from lightning.app import LightningWork
    -
    -
    -class ExampleWork(LightningWork):
    -    def __init__(self):
    -        super().__init__(cache_calls=False)
    -
    -    def run(self, *args, **kwargs):
    -        print(f"I received the following props: args: {args} kwargs: {kwargs}")
    -
    -
    -work = ExampleWork()
    -work.run(value=1)
    -
    -# Providing the same value. This won't run as already cached.
    -work.run(value=1)
    -work.run(value=1)
    -work.run(value=1)
    -work.run(value=1)
    -
    -# Changing the provided value. This isn't cached and will run again.
    -work.run(value=10)
    
  • docs/source-app/code_samples/convert_pl_to_app/app.py+0 17 removed
    @@ -1,17 +0,0 @@
    -from lightning.app import LightningFlow, LightningApp, CloudCompute
    -from lightning.app.components import TracerPythonScript
    -
    -
    -class RootFlow(LightningFlow):
    -    def __init__(self):
    -        super().__init__()
    -        self.runner = TracerPythonScript(
    -            "train.py",
    -            cloud_compute=CloudCompute("gpu"),
    -        )
    -
    -    def run(self):
    -        self.runner.run()
    -
    -
    -app = LightningApp(RootFlow())
    
  • docs/source-app/code_samples/convert_pl_to_app/requirements.txt+0 3 removed
    @@ -1,3 +0,0 @@
    -torch
    -torchvision
    -pytorch_lightning
    
  • docs/source-app/code_samples/convert_pl_to_app/train.py+0 46 removed
    @@ -1,46 +0,0 @@
    -import os
    -
    -import torch
    -import torch.nn.functional as F
    -from torch import nn
    -from torch.utils.data import DataLoader, random_split
    -from torchvision import transforms as T
    -from torchvision.datasets import MNIST
    -
    -import lightning.pytorch as pl
    -
    -
    -class LitAutoEncoder(pl.LightningModule):
    -    def __init__(self):
    -        super().__init__()
    -        self.encoder = nn.Sequential(nn.Linear(28 * 28, 128), nn.ReLU(), nn.Linear(128, 3))
    -        self.decoder = nn.Sequential(nn.Linear(3, 128), nn.ReLU(), nn.Linear(128, 28 * 28))
    -
    -    def forward(self, x):
    -        # in lightning,
    -        # forward defines the prediction/inference actions
    -        embedding = self.encoder(x)
    -        return embedding
    -
    -    def training_step(self, batch, batch_idx):
    -        # training_step defines the train loop.
    -        # It is independent of forward
    -        x, _ = batch
    -        x = x.view(x.size(0), -1)
    -        z = self.encoder(x)
    -        x_hat = self.decoder(z)
    -        loss = F.mse_loss(x_hat, x)
    -        self.log("train_loss", loss)
    -        return loss
    -
    -    def configure_optimizers(self):
    -        optimizer = torch.optim.Adam(self.parameters(), lr=1e-3)
    -        return optimizer
    -
    -
    -dataset = MNIST(os.getcwd(), download=True, transform=T.ToTensor())
    -train, val = random_split(dataset, [55000, 5000])
    -
    -autoencoder = LitAutoEncoder()
    -trainer = pl.Trainer(accelerator="auto")
    -trainer.fit(autoencoder, DataLoader(train), DataLoader(val))
    
  • docs/source-app/code_samples/quickstart/app_01.py+0 27 removed
    @@ -1,27 +0,0 @@
    -from lightning.app import LightningWork, LightningFlow, LightningApp
    -from lightning.app.utilities.app_helpers import pretty_state
    -
    -
    -class Work(LightningWork):
    -    def __init__(self):
    -        super().__init__(cache_calls=False)
    -        # Attributes are registered automatically in the state.
    -        self.counter = 0
    -
    -    def run(self):
    -        # Incrementing an attribute gets reflected in the `Flow` state.
    -        self.counter += 1
    -
    -
    -class Flow(LightningFlow):
    -    def __init__(self):
    -        super().__init__()
    -        self.w = Work()
    -
    -    def run(self):
    -        if self.w.has_started:
    -            print(f"State: {pretty_state(self.state)} \n")
    -        self.w.run()
    -
    -
    -app = LightningApp(Flow())
    
  • docs/source-app/code_samples/quickstart/app_02.py+0 32 removed
    @@ -1,32 +0,0 @@
    -from time import sleep
    -
    -from lightning.app import LightningWork, LightningFlow, LightningApp
    -
    -
    -# This work takes an hour to run
    -class HourLongWork(LightningWork):
    -    def __init__(self, parallel: bool = False):
    -        super().__init__(parallel=parallel)
    -        self.progress = 0.0
    -
    -    def run(self):
    -        self.progress = 0.0
    -        for _ in range(3600):
    -            self.progress += 1.0 / 3600  # Reporting my progress to the Flow.
    -            sleep(1)
    -
    -
    -class RootFlow(LightningFlow):
    -    def __init__(self, child_work: LightningWork):
    -        super().__init__()
    -        self.child_work = child_work
    -
    -    def run(self):
    -        # prints the progress from the child work
    -        print(round(self.child_work.progress, 4))
    -        self.child_work.run()
    -        if self.child_work.counter == 1.0:
    -            print("1 hour later!")
    -
    -
    -app = LightningApp(RootFlow(HourLongWork()))
    
  • docs/source-app/code_samples/quickstart/app_03.py+0 31 removed
    @@ -1,31 +0,0 @@
    -from time import sleep
    -
    -from lightning.app import LightningWork, LightningFlow, LightningApp
    -
    -
    -class HourLongWork(LightningWork):
    -    def __init__(self):
    -        super().__init__(cache_calls=False)
    -        self.progress = 0.0
    -
    -    def run(self):
    -        self.progress = 0.0
    -        for _ in range(3600):
    -            self.progress += 1.0 / 3600
    -            sleep(1)
    -
    -
    -class RootFlow(LightningFlow):
    -    def __init__(self, child_work: LightningWork):
    -        super().__init__()
    -        self.child_work = child_work
    -
    -    def run(self):
    -        # prints the progress from the child work
    -        print(round(self.child_work.progress, 4))
    -        self.child_work.run()
    -        if self.child_work.counter == 1.0:
    -            print("1 hour later!")
    -
    -
    -app = LightningApp(RootFlow(HourLongWork()))
    
  • docs/source-app/code_samples/quickstart/app/app_0.py+0 21 removed
    @@ -1,21 +0,0 @@
    -from lightning.app import LightningWork, LightningFlow, LightningApp
    -from docs.quickstart.app_02 import HourLongWork
    -
    -
    -class RootFlow(LightningFlow):
    -    def __init__(self, child_work_1: LightningWork, child_work_2: LightningWork):
    -        super().__init__()
    -        self.child_work_1 = child_work_1
    -        self.child_work_2 = child_work_2
    -
    -    def run(self):
    -        print(round(self.child_work_1.progress, 4), round(self.child_work_2.progress, 4))
    -        self.child_work_1.run()
    -        self.child_work_2.run()
    -        if self.child_work_1.progress == 1.0:
    -            print("1 hour later `child_work_1` started!")
    -        if self.child_work_2.progress == 1.0:
    -            print("1 hour later `child_work_2` started!")
    -
    -
    -app = LightningApp(RootFlow(HourLongWork(parallel=True), HourLongWork(parallel=True)))
    
  • docs/source-app/code_samples/quickstart/app/app_1.py+0 92 removed
    @@ -1,92 +0,0 @@
    -import flash
    -from flash.core.data.utils import download_data
    -from flash.image import ImageClassificationData, ImageClassifier
    -
    -from lightning.app import LightningWork, LightningFlow, LightningApp, CloudCompute
    -from lightning.pytorch.callbacks import ModelCheckpoint
    -
    -
    -# Step 1: Create a training LightningWork component that gets a backbone as input
    -# and saves the best model and its score
    -class ImageClassifierTrainWork(LightningWork):
    -    def __init__(self, max_epochs: int, backbone: str, cloud_compute: CloudCompute):
    -        # parallel is set to True to run asynchronously
    -        super().__init__(parallel=True, cloud_compute=cloud_compute)
    -        # Number of epochs to run
    -        self.max_epochs = max_epochs
    -        # The model backbone to train on
    -        self.backbone = backbone
    -        self.best_model_path = None
    -        self.best_model_score = None
    -
    -    def run(self, train_folder):
    -        # Create a datamodule from the given dataset
    -        datamodule = ImageClassificationData.from_folders(
    -            train_folder=train_folder,
    -            batch_size=1,
    -            val_split=0.5,
    -        )
    -        # Create an image classfier task with the given backbone
    -        model = ImageClassifier(datamodule.num_classes, backbone=self.backbone)
    -        # Start a Lightning trainer, with 1 training batch and 4 validation batches
    -        trainer = flash.Trainer(
    -            max_epochs=self.max_epochs,
    -            limit_train_batches=1,
    -            limit_val_batches=4,
    -            callbacks=[ModelCheckpoint(monitor="val_cross_entropy")],
    -        )
    -        # Train the model
    -        trainer.fit(model, datamodule=datamodule)
    -        # Save the model path
    -        self.best_model_path = trainer.checkpoint_callback.best_model_path
    -        # Save the model score
    -        self.best_model_score = trainer.checkpoint_callback.best_model_score.item()
    -
    -
    -# Step 2: Create a serving LightningWork component that gets a model input and serves it
    -class ImageClassifierServeWork(LightningWork):
    -    def run(self, best_model_path: str):
    -        # Load the model from the model path
    -        model = ImageClassifier.load_from_checkpoint(best_model_path)
    -        model.serve(output="labels")
    -
    -
    -# Step 3: Create a root LightningFlow component that gets number of epochs and a path to
    -# a dataset as inputs, initialize 2 training components and serves the best model
    -class RootFlow(LightningFlow):
    -    def __init__(self, max_epochs: int, data_dir: str):
    -        super().__init__()
    -        self.data_dir = data_dir
    -        # Init an image classifier with resnet18 backbone
    -        self.train_work_1 = ImageClassifierTrainWork(
    -            max_epochs,
    -            "resnet18",
    -        )
    -        # Init an image classifier with resnet26 backbone
    -        self.train_work_2 = ImageClassifierTrainWork(
    -            max_epochs,
    -            "resnet26",
    -        )
    -        # Init the serving component
    -        self.server_work = ImageClassifierServeWork()
    -
    -    def run(self):
    -        # running both `train_work_1` and `train_work_2` in parallel and asynchronously.
    -        self.train_work_1.run(self.data_dir)
    -        self.train_work_2.run(self.data_dir)
    -
    -        # run serve_work only when both `best_model_score` are available.
    -        if self.train_work_1.best_model_score and self.train_work_2.best_model_score:
    -            # serve only the best model between `train_work_1` and `train_work_2`.
    -            self.server_work.run(
    -                self.train_work_1.best_model_path
    -                if self.train_work_1.best_model_score < self.train_work_2.best_model_score
    -                else self.train_work_2.best_model_path
    -            )
    -
    -
    -# Step 4: download a dataset to your local directory under `/data`
    -download_data("https://pl-flash-data.s3.amazonaws.com/hymenoptera_data.zip", "./data")
    -
    -# Initialize your Lightning app with 5 epochs
    -app = LightningApp(RootFlow(5, "./data/hymenoptera_data"))
    
  • docs/source-app/code_samples/quickstart/app_comp.py+0 26 removed
    @@ -1,26 +0,0 @@
    -from lightning.app import LightningFlow, LightningApp
    -from lightning.app.testing import EmptyFlow, EmptyWork
    -
    -
    -class FlowB(LightningFlow):
    -    def __init__(self):
    -        super().__init__()
    -        self.flow_d = EmptyFlow()
    -        self.work_b = EmptyWork()
    -
    -    def run(self):
    -        ...
    -
    -
    -class FlowA(LightningFlow):
    -    def __init__(self):
    -        super().__init__()
    -        self.flow_b = FlowB()
    -        self.flow_c = EmptyFlow()
    -        self.work_a = EmptyWork()
    -
    -    def run(self):
    -        ...
    -
    -
    -app = LightningApp(FlowA())
    
  • docs/source-app/code_samples/quickstart/app/__init__.py+0 0 removed
  • docs/source-app/code_samples/quickstart/hello_world/app.py+0 15 removed
    @@ -1,15 +0,0 @@
    -from lightning.app import LightningFlow, LightningApp
    -
    -
    -# Step 1: Subclass LightningFlow component to define the app flow.
    -class HelloWorld(LightningFlow):
    -    # Step 2: Add the app logic to the LightningFlow run method to
    -    # ``print("Hello World!")`.
    -    # The LightningApp executes the run method of the main LightningFlow
    -    # within an infinite loop.
    -    def run(self):
    -        print("Hello World!")
    -
    -
    -# Step 3: Initialize a LightningApp with the LightningFlow you defined (in step 1)
    -app = LightningApp(HelloWorld())
    
  • docs/source-app/code_samples/quickstart/hello_world/app_ui.py+0 57 removed
    @@ -1,57 +0,0 @@
    -import os
    -
    -from lightning.app import LightningFlow, LightningApp
    -from lightning.app.frontend import StaticWebFrontend, StreamlitFrontend
    -from lightning.app.utilities.state import AppState
    -
    -
    -# Step 1: Define your LightningFlow component with the app UI
    -class UIStreamLit(LightningFlow):
    -    def __init__(self):
    -        super().__init__()
    -        self.should_print = False
    -
    -    # Step 2: Override `configure_layout` to define the layout of the UI
    -    # In this example, we are using `StreamlitFrontend`
    -    def configure_layout(self):
    -        return StreamlitFrontend(render_fn=render_fn)
    -
    -
    -# Step 3: Implement the StreamLit render method
    -def render_fn(state: AppState):
    -    import streamlit as st
    -    from streamlit_autorefresh import st_autorefresh
    -
    -    st_autorefresh(interval=2000, limit=None, key="refresh")
    -
    -    state.should_print = st.select_slider(
    -        "Should the Application print 'Hello World !' to the terminal:",
    -        [False, True],
    -    )
    -
    -
    -# Step 4: Implement a Static Web Frontend. This could be react, vue, etc.
    -class UIStatic(LightningFlow):
    -    # Step 5:
    -    def configure_layout(self):
    -        return StaticWebFrontend(os.path.join(os.path.dirname(__file__), "ui"))
    -
    -
    -# Step 6: Implement the root flow.
    -class HelloWorld(LightningFlow):
    -    def __init__(self):
    -        super().__init__()
    -        self.static_ui = UIStatic()
    -        self.streamlit_ui = UIStreamLit()
    -
    -    def run(self):
    -        print("Hello World!" if self.streamlit_ui.should_print else "")
    -
    -    def configure_layout(self):
    -        return [
    -            {"name": "StreamLit", "content": self.streamlit_ui},
    -            {"name": "Static", "content": self.static_ui},
    -        ]
    -
    -
    -app = LightningApp(HelloWorld())
    
  • docs/source-app/code_samples/quickstart/hello_world/ui/index.html+0 1 removed
    @@ -1 +0,0 @@
    -<div>Hello from component UIStatic</div>
    
  • docs/source-app/code_samples/quickstart/__init__.py+0 0 removed
  • docs/source-app/conf.py+0 412 removed
    @@ -1,412 +0,0 @@
    -# Configuration file for the Sphinx documentation builder.
    -#
    -# This file does only contain a selection of the most common options. For a
    -# full list see the documentation:
    -# http://www.sphinx-doc.org/en/master/config
    -
    -# -- Path setup --------------------------------------------------------------
    -
    -# If extensions (or modules to document with autodoc) are in another directory,
    -# add these directories to sys.path here. If the directory is relative to the
    -# documentation root, use os.path.abspath to make it absolute, like shown here.
    -
    -import glob
    -import inspect
    -import os
    -import shutil
    -import sys
    -
    -import lai_sphinx_theme
    -from lightning_utilities.docs import fetch_external_assets
    -
    -import lightning
    -
    -_PATH_HERE = os.path.abspath(os.path.dirname(__file__))
    -_PATH_ROOT = os.path.realpath(os.path.join(_PATH_HERE, "..", ".."))
    -sys.path.insert(0, os.path.abspath(_PATH_ROOT))
    -
    -_SPHINX_MOCK_REQUIREMENTS = int(os.environ.get("SPHINX_MOCK_REQUIREMENTS", True))
    -_FAST_DOCS_DEV = int(os.environ.get("FAST_DOCS_DEV", True))
    -_FETCH_S3_ASSETS = int(os.getenv("DOCS_FETCH_ASSETS", not _FAST_DOCS_DEV))
    -
    -# -- Project information -----------------------------------------------------
    -
    -# this name shall match the project name in Github as it is used for linking to code
    -project = "lightning"
    -copyright = lightning.__copyright__
    -author = lightning.__author__
    -
    -# The short X.Y version
    -version = lightning.__version__
    -# The full version, including alpha/beta/rc tags
    -release = lightning.__version__
    -
    -# -- Project documents -------------------------------------------------------
    -
    -if _FETCH_S3_ASSETS:
    -    fetch_external_assets(
    -        docs_folder=_PATH_HERE,
    -        assets_folder="_static/fetched-s3-assets",
    -        retrieve_pattern=r"https?://[-a-zA-Z0-9_]+\.s3\.[-a-zA-Z0-9()_\\+.\\/=]+"
    -    )
    -
    -# -- General configuration ---------------------------------------------------
    -
    -# If your documentation needs a minimal Sphinx version, state it here.
    -
    -needs_sphinx = "5.3"
    -
    -# Add any Sphinx extension module names here, as strings. They can be
    -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
    -# ones.
    -extensions = [
    -    "sphinx.ext.autodoc",
    -    "sphinx.ext.doctest",
    -    "sphinx.ext.intersphinx",
    -    "sphinx_toolbox.collapse",
    -    "sphinx.ext.todo",
    -    "sphinx.ext.coverage",
    -    # "sphinx.ext.linkcode",
    -    "sphinx.ext.autosummary",
    -    "sphinx.ext.napoleon",
    -    # 'sphinxcontrib.mockautodoc',  # raises error: directive 'automodule' is already registered ...
    -    # 'sphinxcontrib.fulltoc',  # breaks pytorch-theme with unexpected kw argument 'titles_only'
    -    "sphinxcontrib.video",
    -    "myst_parser",
    -    "sphinx.ext.autosectionlabel",
    -    "nbsphinx",
    -    "sphinx_autodoc_typehints",
    -    "sphinx_copybutton",
    -    "sphinx_paramlinks",
    -    "sphinx_togglebutton",
    -    "sphinx.ext.githubpages",
    -    "lai_sphinx_theme.extensions.lightning",
    -    'sphinx.ext.mathjax',
    -]
    -
    -# Add any paths that contain templates here, relative to this directory.
    -templates_path = ["_templates"]
    -
    -# myst-parser, forcing to parse all html pages with mathjax
    -# https://github.com/executablebooks/MyST-Parser/issues/394
    -myst_update_mathjax = False
    -# https://myst-parser.readthedocs.io/en/latest/syntax/optional.html?highlight=anchor#auto-generated-header-anchors
    -myst_heading_anchors = 3
    -
    -# https://berkeley-stat159-f17.github.io/stat159-f17/lectures/14-sphinx..html#conf.py-(cont.)
    -# https://stackoverflow.com/questions/38526888/embed-ipython-notebook-in-sphinx-document
    -# I execute the notebooks manually in advance. If notebooks test the code,
    -# they should be run at build time.
    -nbsphinx_execute = "never"
    -nbsphinx_allow_errors = True
    -nbsphinx_requirejs_path = ""
    -
    -# The suffix(es) of source filenames.
    -# You can specify multiple suffix as a list of string:
    -#
    -# source_suffix = ['.rst', '.md']
    -# source_suffix = ['.rst', '.md', '.ipynb']
    -source_suffix = {
    -    ".rst": "restructuredtext",
    -    ".txt": "markdown",
    -    ".md": "markdown",
    -    ".ipynb": "nbsphinx",
    -}
    -
    -# The master toctree document.
    -master_doc = "index"
    -
    -# The language for content autogenerated by Sphinx. Refer to documentation
    -# for a list of supported languages.
    -#
    -# This is also used if you do content translation via gettext catalogs.
    -# Usually you set "language" from the command line for these cases.
    -language = 'en'
    -
    -# List of patterns, relative to source-app directory, that match files and
    -# directories to ignore when looking for source-app files.
    -# This pattern also affects html_static_path and html_extra_path.
    -exclude_patterns = [
    -    "PULL_REQUEST_TEMPLATE.md",
    -    "**/README.md/*",
    -    "readme.md",
    -    "_templates",
    -    "code_samples/convert_pl_to_app/requirements.txt",
    -    "**/_static/*"
    -]
    -
    -# The name of the Pygments (syntax highlighting) style to use.
    -pygments_style = None
    -
    -# -- Options for HTML output -------------------------------------------------
    -
    -# The theme to use for HTML and HTML Help pages.  See the documentation for
    -# a list of builtin themes.
    -#
    -html_theme = "lai_sphinx_theme"
    -html_theme_path = [os.environ.get('LIT_SPHINX_PATH', lai_sphinx_theme.get_html_theme_path())]
    -
    -# Theme options are theme-specific and customize the look and feel of a theme
    -# further.  For a list of options available for each theme, see the
    -# documentation.
    -
    -html_theme_options = {
    -    "pytorch_project": lightning.__homepage__,
    -    "analytics_id": "G-D3Q2ESCTZR",
    -    "canonical_url": lightning.__homepage__,
    -    "collapse_navigation": False,
    -    "display_version": True,
    -    "logo_only": False,
    -}
    -
    -html_favicon = "_static/images/icon.svg"
    -
    -# Add any paths that contain custom static files (such as style sheets) here,
    -# relative to this directory. They are copied after the builtin static files,
    -# so a file named "default.css" will overwrite the builtin "default.css".
    -html_static_path = ["_templates", "_static"]
    -
    -# Custom sidebar templates, must be a dictionary that maps document names
    -# to template names.
    -#
    -# The default sidebars (for documents that don't match any pattern) are
    -# defined by theme itself.  Builtin themes are using these templates by
    -# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
    -# 'searchbox.html']``.
    -#
    -# html_sidebars = {}
    -
    -# -- Options for HTMLHelp output ---------------------------------------------
    -
    -# Output file base name for HTML help builder.
    -htmlhelp_basename = project + "-doc"
    -
    -# -- Options for LaTeX output ------------------------------------------------
    -
    -latex_elements = {
    -    # The paper size ('letterpaper' or 'a4paper').
    -    # 'papersize': 'letterpaper',
    -    # The font size ('10pt', '11pt' or '12pt').
    -    # 'pointsize': '10pt',
    -    # Additional stuff for the LaTeX preamble.
    -    # 'preamble': '',
    -    # Latex figure (float) alignment
    -    "figure_align": "htbp",
    -}
    -
    -# Grouping the document tree into LaTeX files. List of tuples
    -# (source-app start file, target name, title,
    -#  author, documentclass [howto, manual, or own class]).
    -latex_documents = [
    -    (master_doc, project + ".tex", project + " Documentation", author, "manual"),
    -]
    -
    -# MathJax configuration
    -mathjax3_config = {
    -    'tex': {
    -        'packages': {'[+]': ['ams', 'newcommand', 'configMacros']}
    -    },
    -}
    -
    -# -- Options for manual page output ------------------------------------------
    -
    -# One entry per manual page. List of tuples
    -# (source-app start file, name, description, authors, manual section).
    -man_pages = [(master_doc, project, project + " Documentation", [author], 1)]
    -
    -# -- Options for Texinfo output ----------------------------------------------
    -
    -# Grouping the document tree into Texinfo files. List of tuples
    -# (source-app start file, target name, title, author,
    -#  dir menu entry, description, category)
    -texinfo_documents = [
    -    (
    -        master_doc,
    -        project,
    -        project + " Documentation",
    -        author,
    -        project,
    -        lightning.__docs__,
    -        "Miscellaneous",
    -    ),
    -]
    -
    -# -- Options for Epub output -------------------------------------------------
    -
    -# Bibliographic Dublin Core info.
    -epub_title = project
    -
    -# The unique identifier of the text. This can be a ISBN number
    -# or the project homepage.
    -#
    -# epub_identifier = ''
    -
    -# A unique identification for the text.
    -#
    -# epub_uid = ''
    -
    -# A list of files that should not be packed into the epub file.
    -epub_exclude_files = ["search.html"]
    -
    -# -- Extension configuration -------------------------------------------------
    -
    -# -- Options for intersphinx extension ---------------------------------------
    -
    -# Example configuration for intersphinx: refer to the Python standard library.
    -intersphinx_mapping = {
    -    "python": ("https://docs.python.org/3", None),
    -    "torch": ("https://pytorch.org/docs/stable/", None),
    -    "numpy": ("https://numpy.org/doc/stable/", None),
    -}
    -
    -nitpicky = True
    -
    -
    -nitpick_ignore = [
    -    ("py:class", "typing.Self"),
    -    # missing in generated API
    -    ("py:exc", "MisconfigurationException"),
    -    # TODO: generated list of all existing ATM, need to be fixed
    -    ('py:exc', 'ApiException'),
    -    ('py:class', 'BaseModel'),
    -    ('py:exc', 'LightningPlatformException'),
    -    ('py:class', 'forwarded'),
    -    ('py:class', 'lightning.app.api.http_methods.Delete'),
    -    ('py:class', 'lightning.app.api.http_methods.Get'),
    -    ('py:class', 'lightning.app.api.http_methods.HttpMethod'),
    -    ('py:class', 'lightning.app.api.http_methods.Post'),
    -    ('py:class', 'lightning.app.api.http_methods.Put'),
    -    ('py:class', 'lightning.app.components.python.TracerPythonScript'),
    -    ('py:func', 'lightning.app.pdb.set_trace'),
    -    ('py:class', 'lightning.app.runners.runtime.Runtime'),
    -    ('py:class', 'lightning.app.source_code.local.LocalSourceCodeDir'),
    -    ('py:class', 'lightning.app.storage.payload._BasePayload'),
    -    ('py:class', 'lightning.app.structures.Dict'),
    -    ('py:class', 'lightning.app.structures.List'),
    -    ('py:class', 'lightning.app.testing.testing.LightningTestApp'),
    -    ('py:class', 'lightning.app.utilities.app_status.WorkStatus'),
    -    ('py:class', 'lightning.app.utilities.frontend.AppInfo'),
    -    ('py:class', 'lightning.app.utilities.packaging.app_config.AppConfig'),
    -    ('py:class', 'lightning.app.utilities.packaging.build_config.BuildConfig'),
    -    ('py:class', 'lightning.app.utilities.packaging.cloud_compute.CloudCompute'),
    -    ('py:class', 'lightning.app.utilities.proxies.WorkRunExecutor'),
    -    ('py:class', 'lightning.app.utilities.tracer.Tracer'),
    -    ('py:class', 'lightning_cloud.openapi.models.cloudspace_id_runs_body.CloudspaceIdRunsBody'),
    -    ('py:class', 'lightning_cloud.openapi.models.externalv1_lightningapp_instance.Externalv1LightningappInstance'),
    -    ('py:class', 'lightning_cloud.openapi.models.v1_cloud_space.V1CloudSpace'),
    -    ('py:class', 'lightning_cloud.openapi.models.v1_env_var.V1EnvVar'),
    -    ('py:class', 'lightning_cloud.openapi.models.v1_flowserver.V1Flowserver'),
    -    ('py:class', 'lightning_cloud.openapi.models.v1_lightning_auth.V1LightningAuth'),
    -    ('py:class', 'lightning_cloud.openapi.models.v1_lightning_run.V1LightningRun'),
    -    ('py:class', 'lightning_cloud.openapi.models.v1_lightningwork_drives.V1LightningworkDrives'),
    -    ('py:class', 'lightning_cloud.openapi.models.v1_membership.V1Membership'),
    -    ('py:class', 'lightning_cloud.openapi.models.v1_network_config.V1NetworkConfig'),
    -    ('py:class', 'lightning_cloud.openapi.models.v1_queue_server_type.V1QueueServerType'),
    -    ('py:class', 'lightning_cloud.openapi.models.v1_work.V1Work'),
    -    ('py:class', 'pydantic.main.BaseModel'),
    -    ('py:meth', 'transfer'),
    -]
    -
    -# -- Options for todo extension ----------------------------------------------
    -
    -# If true, `todo` and `todoList` produce output, else they produce nothing.
    -todo_include_todos = True
    -
    -
    -def setup(app):
    -    # this is for hiding doctest decoration,
    -    # see: http://z4r.github.io/python/2011/12/02/hides-the-prompts-and-output/
    -    app.add_js_file("copybutton.js")
    -    app.add_css_file("main.css")
    -
    -# copy all examples to local folder
    -path_examples = os.path.join(_PATH_HERE, "..", "examples")
    -if not os.path.isdir(path_examples):
    -    os.mkdir(path_examples)
    -for path_app_example in glob.glob(os.path.join(_PATH_ROOT, "examples", "app_*")):
    -    path_app_example2 = os.path.join(path_examples, os.path.basename(path_app_example))
    -    if not os.path.isdir(path_app_example2):
    -        shutil.copytree(path_app_example, path_app_example2, dirs_exist_ok=True)
    -
    -
    -# Ignoring Third-party packages
    -# https://stackoverflow.com/questions/15889621/sphinx-how-to-exclude-imports-in-automodule
    -def _package_list_from_file(file):
    -    list_pkgs = []
    -    with open(file) as fp:
    -        lines = fp.readlines()
    -    for ln in lines:
    -        found = [ln.index(ch) for ch in list(",=<>#") if ch in ln]
    -        pkg = ln[: min(found)] if found else ln
    -        if pkg.rstrip():
    -            list_pkgs.append(pkg.rstrip())
    -    return list_pkgs
    -
    -
    -# define mapping from PyPI names to python imports
    -PACKAGE_MAPPING = {
    -    "PyYAML": "yaml",
    -}
    -MOCK_PACKAGES = []
    -if _SPHINX_MOCK_REQUIREMENTS:
    -    # mock also base packages when we are on RTD since we don't install them there
    -    MOCK_PACKAGES += _package_list_from_file(os.path.join(_PATH_ROOT, "requirements.txt"))
    -MOCK_PACKAGES = [PACKAGE_MAPPING.get(pkg, pkg) for pkg in MOCK_PACKAGES]
    -
    -autodoc_mock_imports = MOCK_PACKAGES
    -
    -
    -autosummary_generate = True
    -
    -autodoc_member_order = "groupwise"
    -autoclass_content = "both"
    -# the options are fixed and will be soon in release,
    -#  see https://github.com/sphinx-doc/sphinx/issues/5459
    -autodoc_default_options = {
    -    "members": None,
    -    "methods": None,
    -    # 'attributes': None,
    -    "special-members": "__call__",
    -    "exclude-members": "_abc_impl",
    -    "show-inheritance": True,
    -    "private-members": True,
    -    "noindex": True,
    -}
    -
    -# Sphinx will add “permalinks” for each heading and description environment as paragraph signs that
    -#  become visible when the mouse hovers over them.
    -# This value determines the text for the permalink; it defaults to "¶". Set it to None or the empty
    -#  string to disable permalinks.
    -# https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_permalinks
    -# html_add_permalinks = "¶"
    -# True to prefix each section label with the name of the document it is in, followed by a colon.
    -#  For example, index:Introduction for a section called Introduction that appears in document index.rst.
    -#  Useful for avoiding ambiguity when the same section heading appears in different documents.
    -# http://www.sphinx-doc.org/en/master/usage/extensions/autosectionlabel.html
    -autosectionlabel_prefix_document = True
    -
    -# only run doctests marked with a ".. doctest::" directive
    -doctest_test_doctest_blocks = ""
    -doctest_global_setup = """
    -import importlib
    -import os
    -
    -from lightning.app import LightningWork, LightningFlow, LightningApp, CloudCompute
    -from lightning.fabric.loggers.tensorboard import _TENSORBOARD_AVAILABLE, _TENSORBOARDX_AVAILABLE
    -"""
    -coverage_skip_undoc_in_source = True
    -
    -# skip false positive linkcheck errors from anchors
    -linkcheck_anchors = False
    -
    -# A timeout value, in seconds, for the linkcheck builder.
    -linkcheck_timeout = 60
    -
    -# ignore all links in any CHANGELOG file
    -linkcheck_exclude_documents = [r"^(.*\/)*CHANGELOG.*$"]
    -
    -
    -# ignore the following relative links (false positive errors during linkcheck)
    -linkcheck_ignore = [
    -    "https://www.openai.com/index/clip/",
    -]
    
  • docs/source-app/contribute_app.rst+0 7 removed
    @@ -1,7 +0,0 @@
    -:orphan:
    -
    -#################
    -Contribute an app
    -#################
    -
    -Show off your work! Contribute and example to be highlighted in our documentation and App gallery.
    
  • docs/source-app/core_api/lightning_app/app.py+0 27 removed
    @@ -1,27 +0,0 @@
    -from lightning.app import LightningWork, LightningFlow, LightningApp
    -from lightning.app.utilities.app_helpers import pretty_state
    -
    -
    -class Work(LightningWork):
    -    def __init__(self):
    -        super().__init__(cache_calls=False)
    -        # Attributes are registered automatically in the state.
    -        self.counter = 0
    -
    -    def run(self):
    -        # Incrementing an attribute gets reflected in the `Flow` state.
    -        self.counter += 1
    -
    -
    -class Flow(LightningFlow):
    -    def __init__(self):
    -        super().__init__()
    -        self.w = Work()
    -
    -    def run(self):
    -        if self.w.has_started:
    -            print(f"State: {pretty_state(self.state)} \n")
    -        self.w.run()
    -
    -
    -app = LightningApp(Flow())
    
  • docs/source-app/core_api/lightning_app/communication_content.rst+0 160 removed
    @@ -1,160 +0,0 @@
    -
    -********************************
    -Communication Between Components
    -********************************
    -
    -When creating interactive Lightning Apps (App) with multiple components, you may need your components to share information with each other and rely on that information to control their execution, share progress in the UI, trigger a sequence of operations, etc.
    -
    -To accomplish that, Lightning components can communicate using the App State. The App State is composed of all attributes defined within each component's **__init__** method e.g anything attached to the component with **self.x = y**.
    -
    -All attributes of all **LightningWork (Work)** components are accessible in the **LightningFlow (Flow)** components in real-time.
    -
    -By design, the Flows communicate to all **Works** within the application. However, Works can't communicate with each other directly, they must use Flows as a proxy to communicate.
    -
    -Once a Work is running, any updates to the Work's state is automatically communicated to the Flow, as a delta (using `DeepDiff <https://github.com/seperman/deepdiff>`_). The state communication isn't bi-directional, communication is only done from Work to Flow.
    -
    -Internally, the App is alternatively collecting deltas sent from all the registered Works and/or UI, and running the root Flow run method of the App.
    -
    -----
    -
    -*************************************************
    -Communication from LightningWork to LightningFlow
    -*************************************************
    -
    -LightningFlow (Flow) can access their children's LightningWork (Work) state.
    -
    -When a running Work attribute gets updated inside its method (separate process locally or remote machine), the app re-executes Flow's run method once it receives the state update from the Work.
    -
    -Here's an example to better understand communication from Work to Flow.
    -
    -The ``WorkCounter`` increments a counter until 1 million and the ``Flow`` prints the work counter.
    -
    -As the Work is running its own process, its state changes are sent to the Flow which contains the latest value of the counter.
    -
    -.. code-block:: python
    -
    -    import lightning as L
    -
    -
    -    class WorkCounter(L.LightningWork):
    -        def __init__(self):
    -            super().__init__(parallel=True)
    -            self.counter = 0
    -
    -        def run(self):
    -            for _ in range(int(10e6)):
    -                self.counter += 1
    -
    -
    -    class Flow(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.w = WorkCounter()
    -
    -        def run(self):
    -            self.w.run()
    -            print(self.w.counter)
    -
    -
    -    app = L.LightningApp(Flow())
    -
    -
    -A delta sent from the Work to the Flow looks like this:
    -
    -.. code-block:: python
    -
    -    {"values_changed": {"root['works']['w']['vars']['counter']": {"new_value": 425}}}
    -
    -Here is the associated illustration:
    -
    -.. figure:: https://pl-public-data.s3.amazonaws.com/assets_lightning/deltas.gif
    -    :alt: Mechanism showing how delta are sent.
    -    :width: 100 %
    -
    -Here's another example that is slightly different. Here we define a Flow and Work, where the Work increments a counter indefinitely and the Flow prints its state which contain the Work.
    -
    -You can easily check the state of your entire app as follows:
    -
    -.. literalinclude:: ../../core_api/lightning_app/app.py
    -
    -Run the app with:
    -
    -.. code-block:: bash
    -
    -    lightning run app docs/source/core_api/lightning_app/app.py
    -
    -And here's the output you get when running the App using the **Lightning CLI**:
    -
    -.. code-block:: console
    -
    -    INFO: Your app has started. View it in your browser: http://127.0.0.1:7501/view
    -    State: {'works': {'w': {'vars': {'counter': 1}}}}
    -    State: {'works': {'w': {'vars': {'counter': 2}}}}
    -    State: {'works': {'w': {'vars': {'counter': 3}}}}
    -    State: {'works': {'w': {'vars': {'counter': 3}}}}
    -    State: {'works': {'w': {'vars': {'counter': 4}}}}
    -    ...
    -
    -----
    -
    -*************************************************
    -Communication from LightningFlow to LightningWork
    -*************************************************
    -
    -Communication from the LightningFlow (Flow) to the LightningWork (Work) while running **isn't supported yet**. If your application requires this feature, please open an issue on Github.
    -
    -Here's an example of what would happen if you try to have the Flow communicate with the Work:
    -
    -.. code-block:: python
    -
    -    import lightning as L
    -    from time import sleep
    -
    -
    -    class WorkCounter(L.LightningWork):
    -        def __init__(self):
    -            super().__init__(parallel=True)
    -            self.counter = 0
    -
    -        def run(self):
    -            while True:
    -                sleep(1)
    -                print(f"Work {self.counter}")
    -
    -
    -    class Flow(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.w = WorkCounter()
    -
    -        def run(self):
    -            self.w.run()
    -            sleep(1)
    -            print(f"Flow {self.w.counter}")
    -            self.w.counter += 1
    -
    -
    -    app = L.LightningApp(Flow())
    -
    -As you can see, there is a divergence between the values within the Work and the Flow.
    -
    -.. code-block:: console
    -
    -    Flow 0
    -    Flow 1
    -    Flow 2
    -    Flow 3
    -    Work 0
    -    Flow 4
    -    Work 0
    -    Flow 5
    -    Work 0
    -    Flow 6
    -    Work 0
    -    Flow 7
    -    Work 0
    -    Flow 8
    -    Work 0
    -    Flow 9
    -    Work 0
    -    Flow 10
    
  • docs/source-app/core_api/lightning_app/communication.rst+0 15 removed
    @@ -1,15 +0,0 @@
    -:orphan:
    -
    -##########################################
    -Communication between Lightning Components
    -##########################################
    -
    -**Audience:** Users that want to create interactive applications.
    -
    -**Level:** Intermediate
    -
    -**Prerequisite**: Read the :doc:`Communication in Lightning Apps article <../../../workflows/access_app_state>`.
    -
    -----
    -
    -.. include:: ../../core_api/lightning_app/communication_content.rst
    
  • docs/source-app/core_api/lightning_app/compute_content.rst+0 40 removed
    @@ -1,40 +0,0 @@
    -:orphan:
    -
    -***************************
    -Customize my Flow resources
    -***************************
    -
    -In the cloud, you can simply configure which machine to run on by passing
    -a :class:`~lightning.app.utilities.packaging.cloud_compute.CloudCompute` to your work ``__init__`` method:
    -
    -.. code-block:: python
    -
    -    import lightning as L
    -
    -    # Run on a small, shared CPU machine. This is the default for every LightningFlow.
    -    app = L.LightningApp(L.Flow(), flow_cloud_compute=L.CloudCompute())
    -
    -
    -Here is the full list of supported machine names:
    -
    -.. list-table:: Hardware by Accelerator Type
    -   :widths: 25 25 25
    -   :header-rows: 1
    -
    -   * - Name
    -     - # of CPUs
    -     - Memory
    -   * - flow-lite
    -     - 0.3
    -     - 4 GB
    -
    -The up-to-date prices for these instances can be found `here <https://lightning.ai/pages/pricing>`_.
    -
    -----
    -
    -************
    -CloudCompute
    -************
    -
    -.. autoclass:: lightning.app.utilities.packaging.cloud_compute.CloudCompute
    -    :noindex:
    
  • docs/source-app/core_api/lightning_app/dynamic_work_content.rst+0 202 removed
    @@ -1,202 +0,0 @@
    -***************************************
    -What Dynamic LightningWork does for you
    -***************************************
    -
    -Dynamic LightningWork (Work) changes the resources your application uses while the application is running (aka at runtime).
    -
    -For example, imagine you want to create a research notebook app for your team. You want every member to be able to create multiple `JupyterLab <https://jupyter.org/>`_ sessions on their hardware of choice.
    -
    -To allow every notebook to choose hardware, it needs to be set up in it's own :class:`~lightning.app.core.work.LightningWork`, but you can't know the number of notebooks user will need in advance. In this case you'll need to add ``LightningWorks`` dynamically at run time.
    -
    -----
    -
    -*****************
    -Use Dynamic Works
    -*****************
    -
    -Dynamic Works should be used anytime you want change the resources your application is using while it is running (aka at runtime).
    -
    -You're usually going to use the ``start`` and ``stop`` methods together.
    -
    -----
    -
    -Add a Dynamic Work
    -^^^^^^^^^^^^^^^^^^
    -
    -There are a couple of ways you can add a dynamic Work:
    -
    -- Option 1: Attach your components in the **run** method using the Python functions.
    -- Option 2: Use the Lightning built-in classes :class:`~lightning.app.structures.Dict` or :class:`~lightning.app.structures.List`.
    -
    -.. note:: Using the Lightning built-in classes is usually easier to read.
    -
    -----
    -
    -**OPTION 1:** Attach your components in the run method of a flow using the Python functions **hasattr**, **setattr**, and **getattr**:
    -
    -.. code-block:: python
    -
    -    class RootFlow(lapp.LightningFlow):
    -
    -        def run(self):
    -
    -            if not hasattr(self, "work"):
    -                # The `Work` component is created and attached here.
    -                setattr(self, "work", Work())
    -            # Run the `Work` component.
    -            getattr(self,  "work").run()
    -
    -**OPTION 2:** Use the built-in Lightning classes :class:`~lightning.app.structures.Dict` or :class:`~lightning.app.structures.List`
    -
    -.. code-block:: python
    -
    -    from lightning.app.structures import Dict
    -
    -    class RootFlow(lapp.LightningFlow):
    -
    -        def __init__(self):
    -            super().__init__()
    -            self.dict = Dict()
    -
    -        def run(self):
    -            if "work" not in self.dict:
    -                # The `Work` component is attached here.
    -                self.dict["work"] = Work()
    -            self.dict["work"].run()
    -
    -----
    -
    -Stop a Work
    -^^^^^^^^^^^
    -Stop a work when you are concerned about cost.
    -
    -To stop a work, use the work ``stop`` method:
    -
    -.. code-block:: python
    -
    -    class RootFlow(L.LightningFlow):
    -
    -        def __init__(self):
    -            super().__init__()
    -            self.work = Work()
    -
    -        def run(self):
    -            self.work.stop()
    -
    -----
    -
    -*********************
    -Dynamic Work Examples
    -*********************
    -
    -..
    -    The entire application can be found `here <https://github.com/Lightning-AI/lightning-template-jupyterlab>`_.
    -
    -----
    -
    -Dynamic Work with Jupyter Notebooks
    -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    -
    -In this example, we are dynamically creating ``JupyterLabWork`` every time a user clicks the **Create Jupyter Notebook** button.
    -
    -In order to do that, we are iterating over the list of ``jupyter_config_requests`` infinitely.
    -
    -.. code-block:: python
    -
    -    import lightning as L
    -
    -
    -    class JupyterLabManager(L.LightningFlow):
    -
    -        """This flow manages the users notebooks running within works.""""
    -
    -        def __init__(self):
    -            super().__init__()
    -            self.jupyter_works = L.structures.Dict()
    -            self.jupyter_config_requests = []
    -
    -        def run(self):
    -            for idx, jupyter_config in enumerate(self.jupyter_config_requests):
    -
    -                # The Jupyter Config has this form is:
    -                # {"use_gpu": False/True, "token": None, "username": ..., "stop": False}
    -
    -                # Step 1: Check if JupyterWork already exists for this username
    -                username = jupyter_config["username"]
    -                if username not in self.jupyter_works:
    -                    jupyter_config["ready"] = False
    -
    -                    # Set the hardware selected by the user: GPU or CPU.
    -                    cloud_compute = L.CloudCompute("gpu" if jupyter_config["use_gpu"] else "cpu-small")
    -
    -                    # Step 2: Create new JupyterWork dynamically !
    -                    self.jupyter_works[username] = JupyterLabWork(cloud_compute=cloud_compute)
    -
    -                # Step 3: Run the JupyterWork
    -                self.jupyter_works[username].run()
    -
    -                # Step 4: Store the notebook token in the associated config.
    -                # We are using this to know when the notebook is ready
    -                # and display the stop button on the UI.
    -                if self.jupyter_works[username].token:
    -                    jupyter_config["token"] = self.jupyter_works[username].token
    -
    -                # Step 5: Stop the work if the user requested it.
    -                if jupyter_config['stop']:
    -                    self.jupyter_works[username].stop()
    -                    self.jupyter_config_requests.pop(idx)
    -
    -        def configure_layout(self):
    -            return L.app.frontend.StreamlitFrontend(render_fn=render_fn)
    -
    -----
    -
    -Dynamic Works with StreamLit UI
    -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    -
    -Continuing from the Jupyter Notebook example, in the UI, we receive the **state** of the Jupyter Manager and the state can be modified directly from the UI.
    -
    -.. code-block:: python
    -
    -    import streamlit as st
    -
    -
    -    def render_fn(state):
    -
    -        # Step 1: Enable users to select their notebooks and create them
    -        column_1, column_2, column_3 = st.columns(3)
    -        with column_1:
    -            create_jupyter = st.button("Create Jupyter Notebook")
    -        with column_2:
    -            username = st.text_input('Enter your username', "tchaton")
    -            assert username
    -        with column_3:
    -            use_gpu = st.checkbox('Use GPU')
    -
    -        # Step 2: If a user clicked the button, add an element to the list of configs
    -        # Note: state.jupyter_config_requests = ... will sent the state update to the component.
    -        if create_jupyter:
    -            new_config = [{"use_gpu": use_gpu, "token": None, "username": username, "stop": False}]
    -            state.jupyter_config_requests = state.jupyter_config_requests + new_config
    -
    -        # Step 3: List of running notebooks.
    -        for idx, config in enumerate(state.jupyter_config_requests):
    -            column_1, column_2, column_3 = st.columns(3)
    -            with column_1:
    -                if not idx:
    -                    st.write(f"Idx")
    -                st.write(f"{idx}")
    -            with column_2:
    -                if not idx:
    -                    st.write(f"Use GPU")
    -                st.write(config['use_gpu'])
    -            with column_3:
    -                if not idx:
    -                    st.write(f"Stop")
    -                if config["token"]:
    -                    should_stop = st.button("Stop this notebook")
    -
    -                    # Step 4: Change stop if the user clicked the button
    -                    if should_stop:
    -                        config["stop"] = should_stop
    -                        state.jupyter_config_requests = state.jupyter_config_requests
    
  • docs/source-app/core_api/lightning_app/dynamic_work.rst+0 15 removed
    @@ -1,15 +0,0 @@
    -:orphan:
    -
    -.. _dynamic_work:
    -
    -#####################
    -Dynamic LightningWork
    -#####################
    -
    -**Audience:** Users who want to create applications that adapt to user demands.
    -
    -**Level:** Advanced
    -
    -----
    -
    -.. include:: dynamic_work_content.rst
    
  • docs/source-app/core_api/lightning_app/index.rst+0 94 removed
    @@ -1,94 +0,0 @@
    -#############
    -Lightning App
    -#############
    -**Audience:** Users who want to know how an app works under the hood 🤯.
    -
    -**Lightning App:** We call workflows composed of multiple LightningWorks a **Lightning App**.
    -
    -----
    -
    -*******************
    -Peek under the hood
    -*******************
    -
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: App Components Tree (Basic)
    -   :description: Learn more component composition and nesting.
    -   :col_css: col-md-4
    -   :button_link: ../../glossary/app_tree.html
    -   :height: 180
    -   :tag: Basic
    -
    -.. displayitem::
    -   :header: The event loop (Basic)
    -   :description: Learn more about the event loop.
    -   :col_css: col-md-4
    -   :button_link: ../../glossary/event_loop.html
    -   :height: 180
    -   :tag: Basic
    -
    -.. displayitem::
    -   :header: Communication between Flow and Works
    -   :description: Learn more about components communicate.
    -   :col_css: col-md-4
    -   :button_link: communication.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -.. displayitem::
    -   :header: Customize Flow compute resources
    -   :description: Learn more about Flow customizations.
    -   :col_css: col-md-4
    -   :button_link: compute_content.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -.. displayitem::
    -   :header: Dynamically create, execute and stop Work
    -   :description: Learn more about components creation.
    -   :col_css: col-md-4
    -   :button_link: dynamic_work.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -.. displayitem::
    -   :header: Sharing My Components (Intermediate)
    -   :description: Learn more component composition and nesting.
    -   :col_css: col-md-4
    -   :button_link: ../../glossary/sharing_components.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    -
    -----
    -
    -*****************
    -Lightning App API
    -*****************
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: LightningApp API
    -   :description: Look into the Lightning API reference.
    -   :col_css: col-md-4
    -   :button_link: lightning_app.html
    -   :height: 180
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/core_api/lightning_app/lightning_app.rst+0 12 removed
    @@ -1,12 +0,0 @@
    -:orphan:
    -
    -.. _lightning_app:
    -
    -############
    -LightningApp
    -############
    -
    -
    -.. autoclass:: lightning.app.core.app.LightningApp
    -    :exclude-members: _run, connect, get_component_by_name, maybe_apply_changes, set_state
    -    :noindex:
    
  • docs/source-app/core_api/lightning_flow.rst+0 8 removed
    @@ -1,8 +0,0 @@
    -.. _lightning_flow:
    -
    -#############
    -LightningFlow
    -#############
    -
    -.. autoclass:: lightning.app.core.flow.LightningFlow
    -    :exclude-members: _attach_backend, _exit, _is_state_attribute, set_state
    
  • docs/source-app/core_api/lightning_work/compute_content.rst+0 94 removed
    @@ -1,94 +0,0 @@
    -
    -***************************
    -Customize my Work resources
    -***************************
    -
    -In the cloud, you can simply configure which machine to run on by passing
    -a :class:`~lightning.app.utilities.packaging.cloud_compute.CloudCompute` to your work ``__init__`` method:
    -
    -.. code-block:: python
    -
    -    import lightning as L
    -
    -    # Run on a free, shared CPU machine. This is the default for every LightningWork.
    -    MyCustomWork(cloud_compute=L.CloudCompute())
    -
    -    # Run on a dedicated, medium-size CPU machine (see specs below)
    -    MyCustomWork(cloud_compute=L.CloudCompute("cpu-medium"))
    -
    -    # Run on cheap GPU machine with a single GPU (see specs below)
    -    MyCustomWork(cloud_compute=L.CloudCompute("gpu"))
    -
    -    # Run on a fast multi-GPU machine (see specs below)
    -    MyCustomWork(cloud_compute=L.CloudCompute("gpu-fast-multi"))
    -
    -.. warning::
    -     Custom base images are not supported with the default CPU cloud compute. For example:
    -
    -     .. code-block:: py
    -
    -         class MyWork(LightningWork):
    -             def __init__(self):
    -              super().__init__(cloud_build_config=BuildConfig(image="my-custom-image")) # no cloud compute, for example default work
    -
    -
    -Here is the full list of supported machine names:
    -
    -.. list-table:: Hardware by Accelerator Type
    -   :widths: 25 25 25 25
    -   :header-rows: 1
    -
    -   * - Name
    -     - # of CPUs
    -     - GPUs
    -     - Memory
    -   * - default
    -     - 1
    -     - 0
    -     - 4 GB
    -   * - cpu-small
    -     - 2
    -     - 0
    -     - 8 GB
    -   * - cpu-medium
    -     - 8
    -     - 0
    -     - 32 GB
    -   * - gpu
    -     - 4
    -     - 1 (T4, 16 GB)
    -     - 16 GB
    -   * - gpu-fast
    -     - 8
    -     - 1 (V100, 16 GB)
    -     - 61 GB
    -   * - gpu-fast-multi
    -     - 32
    -     - 4 (V100 16 GB)
    -     - 244 GB
    -
    -The up-to-date prices for these instances can be found `here <https://lightning.ai/pages/pricing>`_.
    -
    -----
    -
    -**********************
    -Stop my work when idle
    -**********************
    -
    -By providing **idle_timeout=X Seconds**, the work is automatically stopped **X seconds** after doing nothing.
    -
    -.. code-block:: python
    -
    -    import lightning as L
    -
    -    # Run on a single CPU and turn down immediately when idle.
    -    MyCustomWork(cloud_compute=L.CloudCompute("gpu", idle_timeout=0))
    -
    -----
    -
    -************
    -CloudCompute
    -************
    -
    -.. autoclass:: lightning.app.utilities.packaging.cloud_compute.CloudCompute
    -    :noindex:
    
  • docs/source-app/core_api/lightning_work/compute.rst+0 15 removed
    @@ -1,15 +0,0 @@
    -:orphan:
    -
    -.. _cloud_compute:
    -
    -############################
    -Customize your Cloud Compute
    -############################
    -
    -**Audience:** Users who want to select the hardware to run in the cloud.
    -
    -**Level:** Intermediate
    -
    -----
    -
    -.. include:: compute_content.rst
    
  • docs/source-app/core_api/lightning_work/handling_app_exception_content.rst+0 74 removed
    @@ -1,74 +0,0 @@
    -
    -***************************************************
    -What handling Lightning App exceptions does for you
    -***************************************************
    -
    -Imagine you are creating a Lightning App (App) where your team can launch model training by providing their own Github Repo any time they want.
    -
    -As the App admin, you don't want the App to go down if their code has a bug and breaks.
    -
    -Instead, you would like the LightningWork (Work) to capture the exception and present the issue to users.
    -
    -----
    -
    -****************************
    -Configure exception handling
    -****************************
    -
    -The LightningWork (Work) accepts an argument **raise_exception** which is **True** by default. This aligns with Python default behaviors.
    -
    -However, for the user case stated in the previous section, we want to capture the Work exceptions. This is done by providing ``raise_exception=False`` to the work ``__init__`` method.
    -
    -.. code-block:: python
    -
    -    import lightning as L
    -
    -    MyCustomWork(raise_exception=False)  # <== HERE: The exception is captured.
    -
    -    # Default behavior
    -    MyCustomWork(raise_exception=True)  # <== HERE: The exception is raised within the flow and terminates the app
    -
    -
    -And you can customize this behavior by overriding the ``on_exception`` hook to the Work.
    -
    -.. code-block:: python
    -
    -    import lightning as L
    -
    -    class MyCustomWork(L.LightningWork):
    -
    -        def on_exception(self, exception: Exception):
    -            # do something when an exception is triggered.
    -
    -----
    -
    -**************************
    -Exception handling example
    -**************************
    -
    -This is the pseudo-code for the application described above.
    -
    -.. code-block:: python
    -
    -    import lightning as L
    -
    -    class RootFlow(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.user_jobs = L.structures.Dict()
    -            self.requested_jobs = []
    -
    -        def run(self):
    -            for request in self.requested_jobs:
    -                job_id = request["id"]
    -                if job_id not in self.user_jobs:
    -                    # Note: The `GithubRepoLauncher` doesn't exist yet.
    -                    self.user_jobs[job_id] = GithubRepoLauncher(
    -                        **request,
    -                        raise_exception=False, # <== HERE: The exception is captured.
    -                    )
    -                self.user_jobs[job_id].run()
    -
    -                if self.user_jobs[job_id].status.stage == "failed" and "printed" not in request:
    -                    print(self.user_jobs[job_id].status) # <== HERE: Print the user exception.
    -                    request["printed"] = True
    
  • docs/source-app/core_api/lightning_work/handling_app_exception.rst+0 13 removed
    @@ -1,13 +0,0 @@
    -:orphan:
    -
    -###############################
    -Handle Lightning App exceptions
    -###############################
    -
    -**Audience:** Users who want to make Lightning Apps more robust to potential issues.
    -
    -**Level:** Advanced
    -
    -----
    -
    -.. include:: handling_app_exception_content.rst
    
  • docs/source-app/core_api/lightning_work/index.rst+0 112 removed
    @@ -1,112 +0,0 @@
    -##############
    -Lightning Work
    -##############
    -
    -**Audience:** Users who want to know how Lightning Work works under the hood 🤯.
    -
    -----
    -
    -*******************
    -Peek under the hood
    -*******************
    -
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: To Cache or Not to Cache Calls
    -   :description: Learn more about work execution and internal caching.
    -   :col_css: col-md-4
    -   :button_link: ../../workflows/run_work_once.html
    -   :height: 180
    -   :tag: Basic
    -
    -.. displayitem::
    -   :header: Parallel Work
    -   :description: Learn more about work parallelization.
    -   :col_css: col-md-4
    -   :button_link: ../../workflows/run_work_in_parallel.html
    -   :height: 180
    -   :tag: Basic
    -
    -.. displayitem::
    -   :header: Sharing files between works
    -   :description: Learn more about data transfer works.
    -   :col_css: col-md-4
    -   :button_link: ../../glossary/storage/storage.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -.. displayitem::
    -   :header: Sharing Python Objects between works
    -   :description: Learn more about sharing objects.
    -   :col_css: col-md-4
    -   :button_link: payload.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -.. displayitem::
    -   :header: Checking Work Status
    -   :description: Learn more about work status.
    -   :col_css: col-md-4
    -   :button_link: status.html
    -   :height: 180
    -   :tag: Advanced
    -
    -.. displayitem::
    -   :header: Handling App Exceptions
    -   :description: Learn more about exception capturing.
    -   :col_css: col-md-4
    -   :button_link: handling_app_exception.html
    -   :height: 180
    -   :tag: Advanced
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: Customize your Cloud Compute
    -   :description: Learn more about changing hardware and requirements.
    -   :col_css: col-md-4
    -   :button_link: compute.html
    -   :height: 180
    -   :tag: Cloud
    -
    -.. raw:: html
    -
    -      </div>
    -   </div>
    -
    -
    -----
    -
    -******************
    -Lightning Work API
    -******************
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: LightningWork API
    -   :description: Look into the Lightning API reference.
    -   :col_css: col-md-4
    -   :button_link: lightning_work.html
    -   :height: 180
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/core_api/lightning_work/lightning_work.rst+0 11 removed
    @@ -1,11 +0,0 @@
    -:orphan:
    -
    -.. _lightning_work:
    -
    -#############
    -LightningWork
    -#############
    -
    -.. autoclass:: lightning.app.core.work.LightningWork
    -    :exclude-members: _aggregate_status_timeout, _is_state_attribute, _is_state_attribute, set_state
    -    :noindex:
    
  • docs/source-app/core_api/lightning_work/payload_content.rst+0 75 removed
    @@ -1,75 +0,0 @@
    -
    -**************************************
    -What transferring objects does for you
    -**************************************
    -
    -Imagine your application is processing some data using `pandas DaFrame <https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html>`_ and you want to pass that data to another LightningWork (Work). This is what the **Payload API** is meant for.
    -
    -----
    -
    -*************************
    -Use the Lightning Payload
    -*************************
    -
    -The Payload enables non JSON-serializable attribute objects to be part of your Work's state and to be communicated to other Works.
    -
    -Here is an example:
    -
    -.. code-block:: python
    -
    -    import lightning as L
    -    import pandas as pd
    -
    -
    -    class SourceWork(L.LightningWork):
    -        def __init__(self):
    -            super().__init__()
    -            self.df = None
    -
    -        def run(self):
    -            # do some processing
    -
    -            df = pd.DataFrame(data={"col1": [1, 2], "col2": [3, 4]})
    -
    -            # The object you care about needs to be wrapped into a Payload object.
    -            self.df = L.storage.Payload(df)
    -
    -            # You can access the original object from the payload using its value property.
    -            print("src", self.df.value)
    -            # src  col1  col2
    -            # 0     1     3
    -            # 1     2     4
    -
    -Once the Payload object is attached to your Work's state, it can be passed to another work using the LightningFlow (Flow) as follows:
    -
    -.. code-block:: python
    -
    -    import lightning as L
    -    import pandas as pd
    -
    -
    -    class DestinationWork(L.LightningWork):
    -        def run(self, df: L.storage.Payload):
    -            # You can access the original object from the payload using its value property.
    -            print("dst", df.value)
    -            # dst  col1  col2
    -            # 0     1     3
    -            # 1     2     4
    -
    -
    -    class Flow(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.src = SourceWork()
    -            self.dst = DestinationWork()
    -
    -        def run(self):
    -            self.src.run()
    -            # The pandas DataFrame created by the ``SourceWork``
    -            # is passed to the ``DestinationWork``.
    -            # Internally, Lightning pickles and un-pickle the python object,
    -            # so you receive a copy of the original object.
    -            self.dst.run(df=self.src.df)
    -
    -
    -    app = L.LightningApp(Flow())
    
  • docs/source-app/core_api/lightning_work/payload.rst+0 15 removed
    @@ -1,15 +0,0 @@
    -:orphan:
    -
    -######################################
    -Sharing Objects between LightningWorks
    -######################################
    -
    -**Audience:** Users who want to know how to transfer Python objects between their LightningWorks.
    -
    -**Level:** Advanced
    -
    -**Prerequisite**: Reach Level 16+, know about the `pandas DataFrames <https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html>`_ and read and read the :doc:`Access app state guide <../../workflows/access_app_state>`.
    -
    -----
    -
    -.. include:: payload_content.rst
    
  • docs/source-app/core_api/lightning_work/status_content.rst+0 197 removed
    @@ -1,197 +0,0 @@
    -
    -*************************************
    -Everything about LightningWork Status
    -*************************************
    -
    -Statuses indicate transition points in the life of a LightningWork (Work) and contain metadata.
    -
    -The different stages are:
    -
    -.. code-block:: python
    -
    -    class WorkStageStatus:
    -        NOT_STARTED = "not_started"
    -        STOPPED = "stopped"
    -        PENDING = "pending"
    -        RUNNING = "running"
    -        SUCCEEDED = "succeeded"
    -        FAILED = "failed"
    -
    -And a single status is as follows:
    -
    -.. code-block:: python
    -
    -    @dataclass
    -    class WorkStatus:
    -        stage: WorkStageStatus
    -        timestamp: float
    -        reason: Optional[str] = None
    -        message: Optional[str] = None
    -        count: int = 1
    -
    -
    -On creation, the Work's status flags all evaluate to ``False`` (in particular ``has_started``) and when calling ``work.run`` in your Lightning Flow (Flow),
    -the Work transitions from ``is_pending`` to ``is_running`` and then to ``has_succeeded`` if everything went well or ``has_failed`` otherwise.
    -
    -.. code-block:: python
    -
    -    from time import sleep
    -    import lightning as L
    -
    -
    -    class Work(L.LightningWork):
    -        def run(self, value: int):
    -            sleep(1)
    -            if value == 0:
    -                return
    -            raise Exception(f"The provided value was {value}")
    -
    -
    -    class Flow(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.work = Work(raise_exception=False)
    -            self.counter = 0
    -
    -        def run(self):
    -            if not self.work.has_started:
    -                print("NOT STARTED")
    -
    -            elif self.work.is_pending:
    -                print("PENDING")
    -
    -            elif self.work.is_running:
    -                print("RUNNING")
    -
    -            elif self.work.has_succeeded:
    -                print("SUCCESS")
    -
    -            elif self.work.has_failed:
    -                print("FAILED")
    -
    -            elif self.work.has_stopped:
    -                print("STOPPED")
    -                self.stop()
    -
    -            print(self.work.status)
    -            self.work.run(self.counter)
    -            self.counter += 1
    -
    -
    -    app = L.LightningApp(Flow())
    -
    -Run this app as follows:
    -
    -.. code-block:: bash
    -
    -    lightning run app test.py > app_log.txt
    -
    -And here is the expected output inside ``app_log.txt`` and as expected,
    -we are observing the following transition ``has_started``, ``is_pending``, ``is_running``, ``has_succeeded``, ``is_running`` and ``has_failed``
    -
    -.. code-block:: console
    -
    -    NOT STARTED
    -    WorkStatus(stage='not_started', timestamp=1653498225.18468, reason=None, message=None, count=1)
    -    PENDING
    -    WorkStatus(stage='pending', timestamp=1653498225.217413, reason=None, message=None, count=1)
    -    PENDING
    -    WorkStatus(stage='pending', timestamp=1653498225.217413, reason=None, message=None, count=1)
    -    PENDING
    -    ...
    -    PENDING
    -    WorkStatus(stage='pending', timestamp=1653498225.217413, reason=None, message=None, count=1)
    -    PENDING
    -    WorkStatus(stage='pending', timestamp=1653498225.217413, reason=None, message=None, count=1)
    -    RUNNING
    -    WorkStatus(stage='running', timestamp=1653498228.825194, reason=None, message=None, count=1)
    -    ...
    -    SUCCESS
    -    WorkStatus(stage='succeeded', timestamp=1653498229.831793, reason=None, message=None, count=1)
    -    SUCCESS
    -    WorkStatus(stage='succeeded', timestamp=1653498229.831793, reason=None, message=None, count=1)
    -    SUCCESS
    -    WorkStatus(stage='succeeded', timestamp=1653498229.831793, reason=None, message=None, count=1)
    -    RUNNING
    -    WorkStatus(stage='running', timestamp=1653498229.846451, reason=None, message=None, count=1)
    -    RUNNING
    -    ...
    -    WorkStatus(stage='running', timestamp=1653498229.846451, reason=None, message=None, count=1)
    -    RUNNING
    -    WorkStatus(stage='running', timestamp=1653498229.846451, reason=None, message=None, count=1)
    -    FAILED
    -    WorkStatus(stage='failed', timestamp=1653498230.852565, reason='user_exception', message='The provided value was 1', count=1)
    -    FAILED
    -    WorkStatus(stage='failed', timestamp=1653498230.852565, reason='user_exception', message='The provided value was 1', count=1)
    -    FAILED
    -    WorkStatus(stage='failed', timestamp=1653498230.852565, reason='user_exception', message='The provided value was 1', count=1)
    -    FAILED
    -    WorkStatus(stage='failed', timestamp=1653498230.852565, reason='user_exception', message='The provided value was 1', count=1)
    -    ...
    -
    -In order to access all statuses:
    -
    -.. code-block:: python
    -
    -    from time import sleep
    -    import lightning as L
    -
    -
    -    class Work(L.LightningWork):
    -        def run(self, value: int):
    -            sleep(1)
    -            if value == 0:
    -                return
    -            raise Exception(f"The provided value was {value}")
    -
    -
    -    class Flow(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.work = Work(raise_exception=False)
    -            self.counter = 0
    -
    -        def run(self):
    -            print(self.statuses)
    -            self.work.run(self.counter)
    -            self.counter += 1
    -
    -
    -    app = L.LightningApp(Flow())
    -
    -
    -Run this app as follows:
    -
    -.. code-block:: bash
    -
    -    lightning run app test.py > app_log.txt
    -
    -And here is the expected output inside ``app_log.txt``:
    -
    -
    -.. code-block:: console
    -
    -    # First execution with value = 0
    -
    -    []
    -    [WorkStatus(stage='pending', timestamp=1653498622.252016, reason=None, message=None, count=1)]
    -    ...
    -    [WorkStatus(stage='pending', timestamp=1653498622.252016, reason=None, message=None, count=1)]
    -    [WorkStatus(stage='pending', timestamp=1653498622.252016, reason=None, message=None, count=1)]
    -    [WorkStatus(stage='pending', timestamp=1653498622.252016, reason=None, message=None, count=1), WorkStatus(stage='running', timestamp=1653498626.185683, reason=None, message=None, count=1)]
    -    [WorkStatus(stage='pending', timestamp=1653498622.252016, reason=None, message=None, count=1), WorkStatus(stage='running', timestamp=1653498626.185683, reason=None, message=None, count=1)]
    -    ...
    -    [WorkStatus(stage='pending', timestamp=1653498622.252016, reason=None, message=None, count=1), WorkStatus(stage='running', timestamp=1653498626.185683, reason=None, message=None, count=1)]
    -    [WorkStatus(stage='pending', timestamp=1653498622.252016, reason=None, message=None, count=1), WorkStatus(stage='running', timestamp=1653498626.185683, reason=None, message=None, count=1)]
    -    [WorkStatus(stage='pending', timestamp=1653498622.252016, reason=None, message=None, count=1), WorkStatus(stage='running', timestamp=1653498626.185683, reason=None, message=None, count=1), WorkStatus(stage='succeeded', timestamp=1653498627.191053, reason=None, message=None, count=1)]
    -    [WorkStatus(stage='pending', timestamp=1653498622.252016, reason=None, message=None, count=1), WorkStatus(stage='running', timestamp=1653498626.185683, reason=None, message=None, count=1), WorkStatus(stage='succeeded', timestamp=1653498627.191053, reason=None, message=None, count=1)]
    -    [WorkStatus(stage='pending', timestamp=1653498622.252016, reason=None, message=None, count=1), WorkStatus(stage='running', timestamp=1653498626.185683, reason=None, message=None, count=1), WorkStatus(stage='succeeded', timestamp=1653498627.191053, reason=None, message=None, count=1)]
    -
    -    # Second execution with value = 1
    -
    -    [WorkStatus(stage='pending', timestamp=1653498627.204636, reason=None, message=None, count=1), WorkStatus(stage='running', timestamp=1653498627.205509, reason=None, message=None, count=1)]
    -    [WorkStatus(stage='pending', timestamp=1653498627.204636, reason=None, message=None, count=1), WorkStatus(stage='running', timestamp=1653498627.205509, reason=None, message=None, count=1)]
    -    ...
    -    [WorkStatus(stage='pending', timestamp=1653498627.204636, reason=None, message=None, count=1), WorkStatus(stage='running', timestamp=1653498627.205509, reason=None, message=None, count=1)]
    -    [WorkStatus(stage='pending', timestamp=1653498627.204636, reason=None, message=None, count=1), WorkStatus(stage='running', timestamp=1653498627.205509, reason=None, message=None, count=1), WorkStatus(stage='running', timestamp=1653498627.205509, reason=None, message=None, count=1), WorkStatus(stage='failed', timestamp=1653498628.210164, reason='user_exception', message='The provided value was 1', count=1)]
    -    [WorkStatus(stage='pending', timestamp=1653498627.204636, reason=None, message=None, count=1), WorkStatus(stage='running', timestamp=1653498627.205509, reason=None, message=None, count=1), WorkStatus(stage='running', timestamp=1653498627.205509, reason=None, message=None, count=1), WorkStatus(stage='failed', timestamp=1653498628.210164, reason='user_exception', message='The provided value was 1', count=1)]
    
  • docs/source-app/core_api/lightning_work/status.rst+0 13 removed
    @@ -1,13 +0,0 @@
    -:orphan:
    -
    -####################
    -LightningWork Status
    -####################
    -
    -**Audience:** Users who want to understand ``LightningWork`` under the hood.
    -
    -**Level:** Advanced
    -
    -----
    -
    -.. include:: status_content.rst
    
  • docs/source-app/core_api/overview.rst+0 40 removed
    @@ -1,40 +0,0 @@
    -:orphan:
    -
    -.. _core_api:
    -
    -###############################
    -Learn more about Lightning Core
    -###############################
    -
    -.. raw:: html
    -
    -   <div class="display-card-container">
    -      <div class="row">
    -
    -.. displayitem::
    -   :header: Level-up with Lightning Apps
    -   :description: From Basics to Advanced Skills
    -   :col_css: col-md-6
    -   :button_link: ../levels/basic/index.html
    -   :height: 180
    -
    -.. displayitem::
    -   :header: Understand Lightning App
    -   :description: Detailed description
    -   :col_css: col-md-6
    -   :button_link: lightning_app/index.html
    -   :height: 180
    -
    -.. displayitem::
    -   :header: Understand Lightning Flow
    -   :description: Detailed description
    -   :col_css: col-md-6
    -   :button_link: lightning_flow.html
    -   :height: 180
    -
    -.. displayitem::
    -   :header: Understand Lightning Work
    -   :description: Detailed description
    -   :col_css: col-md-6
    -   :button_link: lightning_work/index.html
    -   :height: 180
    
  • docs/source-app/examples/dag/dag_from_scratch.rst+0 53 removed
    @@ -1,53 +0,0 @@
    -:orphan:
    -
    -###################################################
    -Scheduled DAG with pandas and sklearn from scratch.
    -###################################################
    -
    -**Audience:** Users coming from MLOps to Lightning Apps, looking for more flexibility.
    -
    -**Level:** Intermediate.
    -
    -In this example, you will learn how to create a simple DAG which:
    -
    -* Download and process some data
    -* Train several models and report their associated metrics
    -
    -and learn how to schedule this entire process.
    -
    -Find the complete example `here <https://github.com/Lightning-AI/lightning/blob/master/examples/app/dag/app.py>`_.
    -
    -----
    -
    -**************************
    -Step 1: Implement your DAG
    -**************************
    -
    -Here is an illustration of the DAG to implement:
    -
    -.. figure:: https://pl-public-data.s3.amazonaws.com/assets_lightning/simple_dag.png
    -    :alt: Simple DAG
    -    :width: 100 %
    -
    -First, let's define the component we need:
    -
    -* DataCollector is responsible to download the data
    -* 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
    -    :lines: 52-74
    -
    -And its run method executes the steps described above.
    -
    -.. literalinclude:: ../../../../examples/app/dag/app.py
    -    :lines: 76-99
    -
    -----
    -
    -*****************************
    -Step 2: Define the scheduling
    -*****************************
    -
    -.. literalinclude:: ../../../../examples/app/dag/app.py
    -    :lines: 102-130
    
  • docs/source-app/examples/dag/dag.rst+0 81 removed
    @@ -1,81 +0,0 @@
    -:orphan:
    -
    -######################################
    -Develop a Directed Acyclic Graph (DAG)
    -######################################
    -
    -.. _dag_example:
    -
    -**Audience:** Users coming from MLOps to Lightning Apps, looking for more flexibility.
    -
    -A typical ML training workflow can be implemented with a simple DAG.
    -
    -Below is a pseudo-code using the lightning framework that uses a LightningFlow to orchestrate the serial workflow: process data, train a model, and serve the model.
    -
    -.. code-block:: python
    -
    -    import lightning as L
    -
    -    class DAGFlow(L.LightningFlow):
    -
    -        def __init__(self):
    -            super().__init__()
    -            self.processor = DataProcessorWork(...)
    -            self.train_work = TrainingWork(...)
    -            self.serve_work = ServeWork(...)
    -
    -        def run(self):
    -            self.processor.run(...)
    -            self.train_work.run(...)
    -            self.serve_work.run(...)
    -
    -Below is a pseudo-code to run several works in parallel using a built-in :class:`~lightning.app.structures.Dict`.
    -
    -.. code-block:: python
    -
    -    import lightning as L
    -
    -    class DAGFlow(L.LightningFlow):
    -
    -        def __init__(self):
    -            super().__init__()
    -            ...
    -            self.train_works = L.structures.Dict(**{
    -                "1": TrainingWork(..., parallel=True),
    -                "2": TrainingWork(..., parallel=True),
    -                "3": TrainingWork(..., parallel=True),
    -                ...
    -                })
    -            ...
    -
    -        def run(self):
    -            self.processor.run(...)
    -
    -            # The flow runs through them all, so we need to guard self.serve_work.run
    -            for work in self.train_works.values():
    -                work.run(...)
    -
    -            # Wait for all to have finished without errors.
    -            if not all(w.has_succeeded for w in self.train_works):
    -                continue
    -
    -            self.serve_work.run(...)
    -
    -----
    -
    -**********
    -Next Steps
    -**********
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: Scheduled DAG with pandas and sklearn from scratch.
    -   :description: DAG example in pure Lightning.
    -   :col_css: col-md-4
    -   :button_link: dag_from_scratch.html
    -   :height: 180
    -   :tag: intermediate
    
  • docs/source-app/examples/data_explore_app.rst+0 5 removed
    @@ -1,5 +0,0 @@
    -:orphan:
    -
    -##########################
    -Build a Data Exploring App
    -##########################
    
  • docs/source-app/examples/etl_app.rst+0 5 removed
    @@ -1,5 +0,0 @@
    -:orphan:
    -
    -###############
    -Build a ETL App
    -###############
    
  • docs/source-app/examples/file_server/app.py+0 243 removed
    @@ -1,243 +0,0 @@
    -import json
    -import os
    -import tarfile
    -import uuid
    -import zipfile
    -from pathlib import Path
    -
    -from lightning.app import LightningWork, LightningApp
    -from lightning.app.storage import Drive
    -
    -
    -class FileServer(LightningWork):
    -    def __init__(
    -        self,
    -        drive: Drive,
    -        base_dir: str = "file_server",
    -        chunk_size=10240,
    -        **kwargs
    -    ):
    -        """This component uploads, downloads files to your application.
    -
    -        Arguments:
    -            drive: The drive can share data inside your application.
    -            base_dir: The local directory where the data will be stored.
    -            chunk_size: The quantity of bytes to download/upload at once.
    -
    -        """
    -        super().__init__(
    -            cloud_build_config=BuildConfig(["flask, flask-cors"]),
    -            parallel=True,
    -            **kwargs,
    -        )
    -        # 1: Attach the arguments to the state.
    -        self.drive = drive
    -        self.base_dir = base_dir
    -        self.chunk_size = chunk_size
    -
    -        # 2: Create a folder to store the data.
    -        os.makedirs(self.base_dir, exist_ok=True)
    -
    -        # 3: Keep a reference to the uploaded filenames.
    -        self.uploaded_files = dict()
    -
    -    def get_filepath(self, path: str) -> str:
    -        """Returns file path stored on the file server."""
    -        return os.path.join(self.base_dir, path)
    -
    -    def get_random_filename(self) -> str:
    -        """Returns a random hash for the file name."""
    -        return uuid.uuid4().hex
    -
    -    def upload_file(self, file):
    -        """Upload a file while tracking its progress."""
    -        # 1: Track metadata about the file
    -        filename = file.filename
    -        uploaded_file = self.get_random_filename()
    -        meta_file = uploaded_file + ".meta"
    -        self.uploaded_files[filename] = {
    -            "progress": (0, None), "done": False
    -        }
    -
    -        # 2: Create a stream and write bytes of
    -        # the file to the disk under `uploaded_file` path.
    -        with open(self.get_filepath(uploaded_file), "wb") as out_file:
    -            content = file.read(self.chunk_size)
    -            while content:
    -                # 2.1 Write the file bytes
    -                size = out_file.write(content)
    -
    -                # 2.2 Update the progress metadata
    -                self.uploaded_files[filename]["progress"] = (
    -                    self.uploaded_files[filename]["progress"][0] + size,
    -                    None,
    -                )
    -                # 4: Read next chunk of data
    -                content = file.read(self.chunk_size)
    -
    -        # 3: Update metadata that the file has been uploaded.
    -        full_size = self.uploaded_files[filename]["progress"][0]
    -        self.drive.put(self.get_filepath(uploaded_file))
    -        self.uploaded_files[filename] = {
    -            "progress": (full_size, full_size),
    -            "done": True,
    -            "uploaded_file": uploaded_file,
    -        }
    -
    -        # 4: Write down the metadata about the file to the disk
    -        meta = {
    -            "original_path": filename,
    -            "display_name": os.path.splitext(filename)[0],
    -            "size": full_size,
    -            "drive_path": uploaded_file,
    -        }
    -        with open(self.get_filepath(meta_file), "w") as f:
    -            json.dump(meta, f)
    -
    -        # 5: Put the file to the drive.
    -        # It means other components can access get or list them.
    -        self.drive.put(self.get_filepath(meta_file))
    -        return meta
    -
    -    def list_files(self, file_path: str):
    -        # 1: Get the local file path of the file server.
    -        file_path = self.get_filepath(file_path)
    -
    -        # 2: If the file exists in the drive, transfer it locally.
    -        if not os.path.exists(file_path):
    -            self.drive.get(file_path)
    -
    -        if os.path.isdir(file_path):
    -            result = set()
    -            for _, _, f in os.walk(file_path):
    -                for file in f:
    -                    if not file.endswith(".meta"):
    -                        for filename, meta in self.uploaded_files.items():
    -                            if meta["uploaded_file"] == file:
    -                                result.add(filename)
    -            return {"asset_names": [v for v in result]}
    -
    -        # 3: If the filepath is a tar or zip file, list their contents
    -        if zipfile.is_zipfile(file_path):
    -            with zipfile.ZipFile(file_path, "r") as zf:
    -                result = zf.namelist()
    -        elif tarfile.is_tarfile(file_path):
    -            with tarfile.TarFile(file_path, "r") as tf:
    -                result = tf.getnames()
    -        else:
    -            raise ValueError("Cannot open archive file!")
    -
    -        # 4: Returns the matching files.
    -        return {"asset_names": result}
    -
    -    def run(self):
    -        # 1: Imports flask requirements.
    -        from flask import Flask, request
    -        from flask_cors import CORS
    -
    -        # 2: Create a flask app
    -        flask_app = Flask(__name__)
    -        CORS(flask_app)
    -
    -        # 3: Define the upload file endpoint
    -        @flask_app.post("/upload_file/")
    -        def upload_file():
    -            """Upload a file directly as form data."""
    -            f = request.files["file"]
    -            return self.upload_file(f)
    -
    -        @flask_app.get("/")
    -        def list_files():
    -            return self.list_files(str(Path(self.base_dir).resolve()))
    -
    -        # 5: Start the flask app while providing the `host` and `port`.
    -        flask_app.run(host=self.host, port=self.port, load_dotenv=False)
    -
    -    def alive(self):
    -        """Hack: Returns whether the server is alive."""
    -        return self.url != ""
    -
    -
    -import requests
    -
    -from lightning import LightningWork
    -
    -
    -class TestFileServer(LightningWork):
    -    def __init__(self, drive: Drive):
    -        super().__init__(cache_calls=True)
    -        self.drive = drive
    -
    -    def run(self, file_server_url: str, first=True):
    -        if first:
    -            with open("test.txt", "w") as f:
    -                f.write("Some text.")
    -
    -            response = requests.post(
    -                file_server_url + "/upload_file/",
    -                files={'file': open("test.txt", 'rb')}
    -            )
    -            assert response.status_code == 200
    -        else:
    -            response = requests.get(file_server_url)
    -            assert response.status_code == 200
    -            assert response.json() == {"asset_names": ["test.txt"]}
    -
    -
    -from lightning import LightningApp, LightningFlow
    -
    -
    -class Flow(LightningFlow):
    -    def __init__(self):
    -        super().__init__()
    -        # 1: Create a drive to share data between works
    -        self.drive = Drive("lit://file_server")
    -        # 2: Create  the filer server
    -        self.file_server = FileServer(self.drive)
    -        # 3: Create the file ser
    -        self.test_file_server = TestFileServer(self.drive)
    -
    -    def run(self):
    -        # 1: Start the file server.
    -        self.file_server.run()
    -
    -        # 2: Trigger the test file server work when ready.
    -        if self.file_server.alive():
    -            # 3 Execute the test file server work.
    -            self.test_file_server.run(self.file_server.url)
    -            self.test_file_server.run(self.file_server.url, first=False)
    -
    -        # 4 When both execution are successful, exit the app.
    -        if self.test_file_server.num_successes == 2:
    -            self.stop()
    -
    -    def configure_layout(self):
    -        # Expose the file_server component
    -        # in the UI using its `/` endpoint.
    -        return {"name": "File Server", "content": self.file_server}
    -
    -
    -from lightning.app.runners import MultiProcessRuntime
    -
    -
    -def test_file_server():
    -    app = LightningApp(Flow())
    -    MultiProcessRuntime(app).dispatch()
    -
    -
    -from lightning.app.testing import run_app_in_cloud
    -
    -
    -def test_file_server_in_cloud():
    -    # You need to provide the directory containing the app file.
    -    app_dir = "docs/source-app/examples/file_server"
    -    with run_app_in_cloud(app_dir) as (admin_page, view_page, get_logs_fn, name):
    -        """# 1. `admin_page` and `view_page` are playwright Page Objects.
    -
    -        # Check out https://playwright.dev/python/ doc to learn more.
    -        # You can click the UI and trigger actions.
    -
    -        # 2. By calling logs = get_logs_fn(),
    -        # you get all the logs currently on the admin page.
    -
    -        """
    
  • docs/source-app/examples/file_server/file_server_content.rst+0 85 removed
    @@ -1,85 +0,0 @@
    -
    -
    -*********
    -Our Goal
    -*********
    -
    -Create a simple Lightning App (App) that allows users to upload files and list the uploaded files.
    -
    -----
    -
    -*************
    -Completed App
    -*************
    -
    -Here is a recording of the final App built in this example, tested with pytest.
    -
    -.. video:: https://pl-public-data.s3.amazonaws.com/assets_lightning/file_server.mp4
    -    :poster: https://pl-public-data.s3.amazonaws.com/assets_lightning/file_server.png
    -    :width: 600
    -    :class: background-video
    -    :autoplay:
    -    :loop:
    -    :muted:
    -
    -----
    -
    -**********
    -App Design
    -**********
    -
    -In order to create this App, we need to develop two components and an App:
    -
    -* A **File Server Component** that gives you the ability to download or list files shared with your App. This is particularly useful when you want to trigger an ML job but your users need to provide their own data or if the user wants to download the trained checkpoints.
    -
    -* A **Test File Server** Component to interact with the file server.
    -
    -* An App putting everything together and the App's associated pytest tests.
    -
    -----
    -
    -********
    -Tutorial
    -********
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: Step 1: Implement the File Server general structure
    -   :description: Put together the shape of the Component
    -   :col_css: col-md-4
    -   :button_link: file_server_step_1.html
    -   :height: 180
    -   :tag: Basic
    -
    -.. displayitem::
    -   :header: Step 2: Implement the File Server upload and list files methods
    -   :description: Add the core functionalities to the Component
    -   :col_css: col-md-4
    -   :button_link: file_server_step_2.html
    -   :height: 180
    -   :tag: Basic
    -
    -.. displayitem::
    -   :header: Step 3: Implement a File Server Testing Component
    -   :description: Create a Component to test the file server
    -   :col_css: col-md-4
    -   :button_link: file_server_step_3.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -.. displayitem::
    -   :header: Step 4: Implement tests for the File Server component with pytest
    -   :description: Create an App to validate the upload and list files endpoints
    -   :col_css: col-md-4
    -   :button_link: file_server_step_4.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/examples/file_server/file_server.rst+0 13 removed
    @@ -1,13 +0,0 @@
    -:orphan:
    -
    -.. _fileserver_example:
    -
    -#####################
    -Develop a File Server
    -#####################
    -
    -**Prerequisite**: Reach :ref:`level 16+ <intermediate_level>` and read the :ref:`Drive article <drive_storage>`.
    -
    -----
    -
    -.. include:: file_server_content.rst
    
  • docs/source-app/examples/file_server/file_server_step_1.rst+0 49 removed
    @@ -1,49 +0,0 @@
    -:orphan:
    -
    -##################################################
    -Step 1: Implement the FileServer general structure
    -##################################################
    -
    -Let’s dive in on how to develop the component with the following code:
    -
    -.. literalinclude:: ./app.py
    -    :lines: 1-41, 132-158
    -    :emphasize-lines: 16, 51-
    -
    -********
    -Tutorial
    -********
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: Step 2: Implement the File Server upload and list files methods
    -   :description: Add the core functionalities to the Component
    -   :col_css: col-md-4
    -   :button_link: file_server_step_2.html
    -   :height: 180
    -   :tag: Basic
    -
    -.. displayitem::
    -   :header: Step 3: Implement a File Server Testing Component
    -   :description: Create a Component to test the file server
    -   :col_css: col-md-4
    -   :button_link: file_server_step_3.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -.. displayitem::
    -   :header: Step 4: Implement tests for the File Server component with pytest
    -   :description: Create an App to validate the upload and list files endpoints
    -   :col_css: col-md-4
    -   :button_link: file_server_step_4.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/examples/file_server/file_server_step_2.rst+0 75 removed
    @@ -1,75 +0,0 @@
    -:orphan:
    -
    -################################################################
    -Step 2: Implement the File Server upload and list_files methods
    -################################################################
    -
    -Let's dive in on how to implement these methods.
    -
    -***************************
    -Implement the upload method
    -***************************
    -
    -In this method, we are creating a stream between the uploaded file and the uploaded file stored on the file server disk.
    -
    -Once the file is uploaded, we are putting the file into the :class:`~lightning.app.storage.drive.Drive`, so it becomes persistent and accessible to all Components.
    -
    -.. literalinclude:: ./app.py
    -    :lines: 12, 51-99
    -    :emphasize-lines: 49
    -
    -*******************************
    -Implement the fist_files method
    -*******************************
    -
    -First, in this method, we get the file in the file server filesystem, if available in the Drive. Once done, we list the the files under the provided paths and return the results.
    -
    -.. literalinclude:: ./app.py
    -    :lines: 12, 100-130
    -    :emphasize-lines: 9
    -
    -
    -*******************
    -Implement utilities
    -*******************
    -
    -.. literalinclude:: ./app.py
    -    :lines: 12, 43-49
    -
    -********
    -Tutorial
    -********
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: Step 1: Implement the File Server general structure
    -   :description: Put together the shape of the Component
    -   :col_css: col-md-4
    -   :button_link: file_server_step_1.html
    -   :height: 180
    -   :tag: Basic
    -
    -.. displayitem::
    -   :header: Step 3: Implement a File Server Testing Component
    -   :description: Create a Component to test the file server
    -   :col_css: col-md-4
    -   :button_link: file_server_step_3.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -.. displayitem::
    -   :header: Step 4: Implement tests for the File Server component with pytest
    -   :description: Create an App to validate the upload and list files endpoints
    -   :col_css: col-md-4
    -   :button_link: file_server_step_4.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/examples/file_server/file_server_step_3.rst+0 54 removed
    @@ -1,54 +0,0 @@
    -:orphan:
    -
    -#################################################
    -Step 3: Implement a File Server Testing Component
    -#################################################
    -
    -Let's dive in on how to implement a testing component for a server.
    -
    -This component needs to test two things:
    -
    -* The **/upload_file/** endpoint by creating a file and sending its content to it.
    -
    -* The **/** endpoint listing files, by validating the that previously uploaded file is present in the response.
    -
    -.. literalinclude:: ./app.py
    -   :lines: 165-182
    -
    -********
    -Tutorial
    -********
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: Step 1: Implement the File Server general structure
    -   :description: Put together the shape of the Component
    -   :col_css: col-md-4
    -   :button_link: file_server_step_1.html
    -   :height: 180
    -   :tag: Basic
    -
    -.. displayitem::
    -   :header: Step 2: Implement the File Server upload and list files methods
    -   :description: Add the core functionalities to the Component
    -   :col_css: col-md-4
    -   :button_link: file_server_step_2.html
    -   :height: 180
    -   :tag: Basic
    -
    -.. displayitem::
    -   :header: Step 4: Implement tests for the File Server component with pytest
    -   :description: Create an App to validate the upload and list files endpoints
    -   :col_css: col-md-4
    -   :button_link: file_server_step_4.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/examples/file_server/file_server_step_4.rst+0 127 removed
    @@ -1,127 +0,0 @@
    -:orphan:
    -
    -#################################################################
    -Step 4: Implement tests for the File Server component with pytest
    -#################################################################
    -
    -Let's create a simple App with our **File Server** and **File Server Test** components.
    -
    -Once the File Server is up and running, we'll execute the **test_file_server** LightningWork and when both calls are successful, we exit the App using ``self._exit``.
    -
    -.. literalinclude:: ./app.py
    -   :lines: 187-218
    -
    -
    -Simply create a ``test.py`` file with the following code and run ``pytest tests.py``:
    -
    -.. literalinclude:: ./app.py
    -   :lines: 221-226
    -
    -To test the App in the cloud, create a ``cloud_test.py`` file with the following code and run ``pytest cloud_test.py``.
    -Under the hood, we are using the end-to-end testing `playwright <https://playwright.dev/python/>`_ library, so you can interact with the UI.
    -
    -.. literalinclude:: ./app.py
    -   :lines: 229-
    -
    -----
    -
    -********************
    -Test the application
    -********************
    -
    -Clone the Lightning repo and run the following command:
    -
    -.. code-block:: bash
    -
    -   pytest docs/source/examples/file_server/app.py --capture=no -v
    -
    -----
    -
    -********
    -Tutorial
    -********
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: Step 1: Implement the File Server general structure
    -   :description: Put together the shape of the Component
    -   :col_css: col-md-4
    -   :button_link: file_server_step_1.html
    -   :height: 180
    -   :tag: Basic
    -
    -.. displayitem::
    -   :header: Step 2: Implement the File Server upload and list files methods
    -   :description: Add the core functionalities to the Component
    -   :col_css: col-md-4
    -   :button_link: file_server_step_2.html
    -   :height: 180
    -   :tag: Basic
    -
    -.. displayitem::
    -   :header: Step 3: Implement a File Server Testing Component
    -   :description: Create a Component to test the file server
    -   :col_css: col-md-4
    -   :button_link: file_server_step_3.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    -
    -----
    -
    -******************
    -Find more examples
    -******************
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: Develop a DAG
    -   :description: Create a dag pipeline
    -   :col_css: col-md-4
    -   :button_link: ../dag/dag.html
    -   :height: 150
    -   :tag: Intermediate
    -
    -.. displayitem::
    -   :header: Develop a Github Repo Script Runner
    -   :description: Run any script on github in the cloud
    -   :col_css: col-md-4
    -   :button_link: ../github_repo_runner/github_repo_runner.html
    -   :height: 150
    -   :tag: Intermediate
    -
    -
    -.. displayitem::
    -   :header: Develop a HPO Sweeper
    -   :description: Train multiple models with different parameters
    -   :col_css: col-md-4
    -   :button_link: ../hpo/hpo.html
    -   :height: 150
    -   :tag: Intermediate
    -
    -.. displayitem::
    -   :header: Develop a Model Server
    -   :description: Serve multiple models with different parameters
    -   :col_css: col-md-4
    -   :button_link: ../model_server_app/model_server_app.html
    -   :height: 150
    -   :tag: Intermediate
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/examples/github_repo_runner/app.py+0 309 removed
    @@ -1,309 +0,0 @@
    -import io
    -import os
    -import subprocess
    -import sys
    -from copy import deepcopy
    -from functools import partial
    -from subprocess import Popen
    -from typing import Dict, List, Optional
    -
    -from lightning import BuildConfig, CloudCompute, LightningApp, LightningFlow
    -from lightning.app import structures
    -from lightning.app.components import TracerPythonScript
    -from lightning.app.frontend import StreamlitFrontend
    -from lightning.app.storage.path import Path
    -from lightning.app.utilities.state import AppState
    -
    -
    -class GithubRepoRunner(TracerPythonScript):
    -    def __init__(
    -        self,
    -        id: str,
    -        github_repo: str,
    -        script_path: str,
    -        script_args: List[str],
    -        requirements: List[str],
    -        cloud_compute: Optional[CloudCompute] = None,
    -        **kwargs,
    -    ):
    -        """The GithubRepoRunner Component clones a repo, runs a specific script with provided arguments and collect
    -        logs.
    -
    -        Arguments:
    -            id: Identified of the component.
    -            github_repo: The Github Repo URL to clone.
    -            script_path: The path to the script to execute.
    -            script_args: The arguments to be provided to the script.
    -            requirements: The python requirements tp run the script.
    -            cloud_compute: The object to select the cloud instance.
    -
    -        """
    -        super().__init__(
    -            script_path=script_path,
    -            script_args=script_args,
    -            cloud_compute=cloud_compute,
    -            cloud_build_config=BuildConfig(requirements=requirements),
    -            **kwargs,
    -        )
    -        self.id = id
    -        self.github_repo = github_repo
    -        self.logs = []
    -
    -    def run(self, *args, **kwargs):
    -        # 1. Hack: Patch stdout so we can capture the logs.
    -        string_io = io.StringIO()
    -        sys.stdout = string_io
    -
    -        # 2: Use git command line to clone the repo.
    -        repo_name = self.github_repo.split("/")[-1].replace(".git", "")
    -        cwd = os.path.dirname(__file__)
    -        subprocess.Popen(
    -            f"git clone {self.github_repo}", cwd=cwd, shell=True).wait()
    -
    -        # 3: Execute the parent run method of the TracerPythonScript class.
    -        os.chdir(os.path.join(cwd, repo_name))
    -        super().run(*args, **kwargs)
    -
    -        # 4: Get all the collected logs and add them to the state.
    -        # This isn't optimal as heavy, but works for this demo purpose.
    -        self.logs = string_io.getvalue()
    -        string_io.close()
    -
    -    def configure_layout(self):
    -        return {"name": self.id, "content": self}
    -
    -
    -class PyTorchLightningGithubRepoRunner(GithubRepoRunner):
    -    def __init__(self, *args, **kwargs):
    -        super().__init__(*args, **kwargs)
    -        self.best_model_path = None
    -        self.best_model_score = None
    -
    -    def configure_tracer(self):
    -        from lightning.pytorch import Trainer
    -        from lightning.pytorch.callbacks import Callback
    -
    -        tracer = super().configure_tracer()
    -
    -        class TensorboardServerLauncher(Callback):
    -            def __init__(self, work):
    -                # The provided `work` is the
    -                # current ``PyTorchLightningScript`` work.
    -                self.w = work
    -
    -            def on_train_start(self, trainer, *_):
    -                # Add `host` and `port` for tensorboard to work in the cloud.
    -                cmd = f"tensorboard --logdir='{trainer.logger.log_dir}'"
    -                server_args = f"--host {self.w.host} --port {self.w.port}"
    -                Popen(cmd + " " + server_args, shell=True)
    -
    -        def trainer_pre_fn(self, *args, work=None, **kwargs):
    -            # Intercept Trainer __init__ call
    -            # and inject a ``TensorboardServerLauncher`` component.
    -            kwargs["callbacks"].append(TensorboardServerLauncher(work))
    -            return {}, args, kwargs
    -
    -        # 5. Patch the `__init__` method of the Trainer
    -        # to inject our callback with a reference to the work.
    -        tracer.add_traced(
    -            Trainer, "__init__", pre_fn=partial(trainer_pre_fn, work=self))
    -        return tracer
    -
    -    def on_after_run(self, end_script_globals):
    -        import torch
    -
    -        # 1. Once the script has finished to execute,
    -        # we can collect its globals and access any objects.
    -        trainer = end_script_globals["cli"].trainer
    -        checkpoint_callback = trainer.checkpoint_callback
    -        lightning_module = trainer.lightning_module
    -
    -        # 2. From the checkpoint_callback,
    -        # we are accessing the best model weights
    -        checkpoint = torch.load(checkpoint_callback.best_model_path)
    -
    -        # 3. Load the best weights and torchscript the model.
    -        lightning_module.load_state_dict(checkpoint["state_dict"])
    -        lightning_module.to_torchscript(f"{self.name}.pt")
    -
    -        # 4. Use lightning.app.storage.Pathto create a reference to the
    -        # torch scripted model. In the cloud with multiple machines,
    -        # by simply passing this reference to another work,
    -        # it triggers automatically a file transfer.
    -        self.best_model_path = Path(f"{self.name}.pt")
    -
    -        # 5. Keep track of the metrics.
    -        self.best_model_score = float(checkpoint_callback.best_model_score)
    -
    -
    -class KerasGithubRepoRunner(GithubRepoRunner):
    -    """Left to the users to implement."""
    -
    -
    -class TensorflowGithubRepoRunner(GithubRepoRunner):
    -    """Left to the users to implement."""
    -
    -
    -GITHUB_REPO_RUNNERS = {
    -    "PyTorch Lightning": PyTorchLightningGithubRepoRunner,
    -    "Keras": KerasGithubRepoRunner,
    -    "Tensorflow": TensorflowGithubRepoRunner,
    -}
    -
    -
    -class Flow(LightningFlow):
    -    def __init__(self):
    -        super().__init__()
    -        # 1: Keep track of the requests within the state
    -        self.requests = []
    -        # 2: Create a dictionary of components.
    -        self.ws = structures.Dict()
    -
    -    def run(self):
    -        # Iterate continuously over all requests
    -        for request_id, request in enumerate(self.requests):
    -            self._handle_request(request_id, deepcopy(request))
    -
    -    def _handle_request(self, request_id: int, request: Dict):
    -        # 1: Create a name and find selected framework
    -        name = f"w_{request_id}"
    -        ml_framework = request["train"].pop("ml_framework")
    -
    -        # 2: If the component hasn't been created yet, create it.
    -        if name not in self.ws:
    -            work_cls = GITHUB_REPO_RUNNERS[ml_framework]
    -            work = work_cls(id=request["id"], **request["train"])
    -            self.ws[name] = work
    -
    -        # 3: Run the component
    -        self.ws[name].run()
    -
    -        # 4: Once the component has finished,
    -        # add metadata to the original request for the UI.
    -        if self.ws[name].best_model_path:
    -            request = self.requests[request_id]
    -            request["best_model_score"] = self.ws[name].best_model_score
    -            request["best_model_path"] = self.ws[name].best_model_path
    -
    -    def configure_layout(self):
    -        # Create a StreamLit UI for the user to run his Github Repo.
    -        return StreamlitFrontend(render_fn=render_fn)
    -
    -
    -def page_1__create_new_run(state):
    -    import streamlit as st
    -
    -    st.markdown("# Create a new Run 🎈")
    -
    -    # 1: Collect arguments from the users
    -    id = st.text_input("Name your run", value="my_first_run")
    -    github_repo = st.text_input(
    -        "Enter a Github Repo URL", value="https://github.com/Lightning-AI/lightning-quick-start.git"
    -    )
    -
    -    default_script_args = (
    -        "--trainer.max_epochs=5"
    -        " --trainer.limit_train_batches=4"
    -        " --trainer.limit_val_batches=4"
    -        " --trainer.callbacks=ModelCheckpoint"
    -        " --trainer.callbacks.monitor=val_acc"
    -    )
    -    default_requirements = "torchvision, pytorch_lightning, jsonargparse[signatures]"
    -
    -    script_path = st.text_input("Enter your script to run", value="train_script.py")
    -    script_args = st.text_input("Enter your base script arguments", value=default_script_args)
    -    requirements = st.text_input("Enter your requirements", value=default_requirements)
    -    ml_framework = st.radio(
    -        "Select your ML Training Frameworks", options=["PyTorch Lightning", "Keras", "Tensorflow"]
    -    )
    -
    -    if ml_framework not in ("PyTorch Lightning"):
    -        st.write(f"{ml_framework} isn't supported yet.")
    -        return
    -
    -    clicked = st.button("Submit")
    -
    -    # 2: If clicked, create a new request.
    -    if clicked:
    -        new_request = {
    -            "id": id,
    -            "train": {
    -                "github_repo": github_repo,
    -                "script_path": script_path,
    -                "script_args": script_args.split(" "),
    -                "requirements": requirements.split(" "),
    -                "ml_framework": ml_framework,
    -            },
    -        }
    -        # 3: IMPORTANT: Add a new request to the state in-place.
    -        # The flow receives the UI request and dynamically create
    -        # and run the associated work from the request information.
    -        state.requests = state.requests + [new_request]
    -
    -
    -def page_2__view_run_lists(state):
    -    import streamlit as st
    -
    -    st.markdown("# Run Lists 🎈")
    -    # 1: Iterate through all the requests in the state.
    -    for i, r in enumerate(state.requests):
    -        i = str(i)
    -        # 2: Display information such as request, logs, work state, model score.
    -        work = state._state["structures"]["ws"]["works"][f"w_{i}"]
    -        with st.expander(f"Expand to view Run {i}", expanded=False):
    -            if st.checkbox("Expand to view your configuration", key=i):
    -                st.json(r)
    -            if st.checkbox("Expand to view logs", key=i):
    -                st.code(body=work["vars"]["logs"])
    -            if st.checkbox("Expand to view your work state", key=i):
    -                work["vars"].pop("logs")
    -                st.json(work)
    -            best_model_score = r.get("best_model_score", None)
    -            if best_model_score:
    -                if st.checkbox("Expand to view your run performance", key=i):
    -                    st.json({"best_model_score": best_model_score, "best_model_path": r.get("best_model_path")})
    -
    -
    -def page_3__view_app_state(state):
    -    import streamlit as st
    -
    -    st.markdown("# App State 🎈")
    -    st.write(state._state)
    -
    -
    -def render_fn(state: AppState):
    -    import streamlit as st
    -
    -    page_names_to_funcs = {
    -        "Create a new Run": partial(page_1__create_new_run, state=state),
    -        "View your Runs": partial(page_2__view_run_lists, state=state),
    -        "View the App state": partial(page_3__view_app_state, state=state),
    -    }
    -    selected_page = st.sidebar.selectbox(
    -        "Select a page", page_names_to_funcs.keys())
    -    page_names_to_funcs[selected_page]()
    -
    -
    -class RootFlow(LightningFlow):
    -    def __init__(self):
    -        super().__init__()
    -        # Create the flow
    -        self.flow = Flow()
    -
    -    def run(self):
    -        # Run the flow
    -        self.flow.run()
    -
    -    def configure_layout(self):
    -        # 1: Add the main StreamLit UI
    -        selection_tab = [{
    -            "name": "Run your Github Repo",
    -            "content": self.flow,
    -        }]
    -        # 2: Add a new tab whenever a new work is dynamically created
    -        run_tabs = [e.configure_layout() for e in self.flow.ws.values()]
    -        # 3: Returns the list of tabs.
    -        return selection_tab + run_tabs
    -
    -
    -app = LightningApp(RootFlow())
    
  • docs/source-app/examples/github_repo_runner/github_repo_runner_content.rst+0 97 removed
    @@ -1,97 +0,0 @@
    -
    -********
    -Our Goal
    -********
    -
    -Create a simple Lightning App (App) where users can enter information in a UI to run a given PyTorch Lightning Script from a given Github Repo with some optional extra Python requirements and arguments.
    -
    -Users should be able to monitor their training progress in real-time, view the logs, and get the best monitored metric and associated checkpoint for their models.
    -
    -----
    -
    -Completed App
    -^^^^^^^^^^^^^
    -
    -Here is a recording of the final application built in this example. The example is around 200 lines in total and should give you a great foundation to build your own Lightning App.
    -
    -.. video:: https://pl-public-data.s3.amazonaws.com/assets_lightning/github_app.mp4
    -    :poster: "https://pl-public-data.s3.amazonaws.com/assets_lightning/github_app.png
    -    :width: 600
    -    :class: background-video
    -    :autoplay:
    -    :loop:
    -    :muted:
    -
    -----
    -
    -**********
    -App Design
    -**********
    -
    -In order to develop the App, we need to build several components:
    -
    -* A GithubRepoRunner Component that clones a repo, runs a specific script with provided arguments and collect logs.
    -
    -* A PyTorch Lightning GithubRepoRunner Component that augments the GithubRepoRunner component to track PyTorch Lightning Trainer.
    -
    -* A UI for the users to provide to trigger dynamically a new execution.
    -
    -* A Flow to dynamically create GithubRepoRunner once a user submits information from the UI.
    -
    -----
    -
    -********
    -Tutorial
    -********
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: Step 1: Implement the GithubRepoRunner Component
    -   :description: Clone and execute script from a GitHub Repo.
    -   :col_css: col-md-4
    -   :button_link: github_repo_runner_step_1.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -.. displayitem::
    -   :header: Step 2: Implement the PyTorch Lightning GithubRepoRunner Component
    -   :description: Automate PyTorch Lightning execution
    -   :col_css: col-md-4
    -   :button_link: github_repo_runner_step_2.html
    -   :height: 180
    -   :tag: Advanced
    -
    -.. displayitem::
    -   :header: Step 3: Implement the Flow to manage user requests
    -   :description: Dynamically create GithubRepoRunner
    -   :col_css: col-md-4
    -   :button_link: github_repo_runner_step_3.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -
    -.. displayitem::
    -   :header: Step 4: Implement the UI with StreamLit
    -   :description: Several pages application
    -   :col_css: col-md-4
    -   :button_link: github_repo_runner_step_4.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -
    -.. displayitem::
    -   :header: Step 5: Put it all together
    -   :description:
    -   :col_css: col-md-4
    -   :button_link: github_repo_runner_step_5.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/examples/github_repo_runner/github_repo_runner.rst+0 15 removed
    @@ -1,15 +0,0 @@
    -:orphan:
    -
    -.. _github_repo_script_runner_example:
    -
    -###################################
    -Develop a Github Repo Script Runner
    -###################################
    -
    -**Audience:** Users that want to develop interactive applications which runs Github Repo in the cloud at any scale for multiple users.
    -
    -**Prerequisite**: Reach :ref:`level 16+ <intermediate_level>` and read the docstring of of :class:`~lightning.app.components.python.tracer.TracerPythonScript` component.
    -
    -----
    -
    -.. include:: github_repo_runner_content.rst
    
  • docs/source-app/examples/github_repo_runner/github_repo_runner_step_1.rst+0 62 removed
    @@ -1,62 +0,0 @@
    -:orphan:
    -
    -************************************************
    -Step 1: Implement the GithubRepoRunner Component
    -************************************************
    -
    -The GithubRepoRunner Component clones a repo, runs a specific script with provided arguments, and collect logs.
    -
    -Let's dive in on how to develop the component with the following code:
    -
    -.. literalinclude:: ./app.py
    -    :lines: -72
    -
    -----
    -
    -********
    -Tutorial
    -********
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: Step 2: Implement the PyTorch Lightning GithubRepoRunner Component
    -   :description: Automate PyTorch Lightning execution
    -   :col_css: col-md-4
    -   :button_link: github_repo_runner_step_2.html
    -   :height: 180
    -   :tag: Advanced
    -
    -.. displayitem::
    -   :header: Step 3: Implement the Flow to manage user requests
    -   :description: Dynamically create GithubRepoRunner
    -   :col_css: col-md-4
    -   :button_link: github_repo_runner_step_3.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -
    -.. displayitem::
    -   :header: Step 4: Implement the UI with StreamLit
    -   :description: Several pages application
    -   :col_css: col-md-4
    -   :button_link: github_repo_runner_step_4.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -
    -.. displayitem::
    -   :header: Step 5: Put it all together
    -   :description:
    -   :col_css: col-md-4
    -   :button_link: github_repo_runner_step_5.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/examples/github_repo_runner/github_repo_runner_step_2.rst+0 68 removed
    @@ -1,68 +0,0 @@
    -:orphan:
    -
    -******************************************************************
    -Step 2: Implement the PyTorch Lightning GithubRepoRunner Component
    -******************************************************************
    -
    -The PyTorch Lightning GithubRepoRunner Component subclasses the GithubRepoRunner but tailors the execution experience to PyTorch Lightning.
    -
    -As a matter of fact, this component adds two primary tailored features for PyTorch Lightning users:
    -
    -* It injects dynamically a custom callback ``TensorboardServerLauncher`` in the PyTorch Lightning Trainer to start a tensorboard server so it can be exposed in Lightning App UI.
    -
    -* Once the script has run, the ``on_after_run`` hook of the :class:`~lightning.app.components.python.tracer.TracerPythonScript` is invoked with the script globals, meaning we can collect anything we need. In particular, we are reloading the best model, torch scripting it, and storing its path in the state along side the best metric score.
    -
    -Let's dive in on how to develop the component with the following code:
    -
    -.. literalinclude:: ./app.py
    -    :lines: 75-136
    -
    -----
    -
    -********
    -Tutorial
    -********
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: Step 1: Implement the GithubRepoRunner Component
    -   :description: Clone and execute script from a GitHub Repo.
    -   :col_css: col-md-4
    -   :button_link: github_repo_runner_step_1.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -.. displayitem::
    -   :header: Step 3: Implement the Flow to manage user requests
    -   :description: Dynamically create GithubRepoRunner
    -   :col_css: col-md-4
    -   :button_link: github_repo_runner_step_3.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -
    -.. displayitem::
    -   :header: Step 4: Implement the UI with StreamLit
    -   :description: Several pages application
    -   :col_css: col-md-4
    -   :button_link: github_repo_runner_step_4.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -
    -.. displayitem::
    -   :header: Step 5: Put it all together
    -   :description:
    -   :col_css: col-md-4
    -   :button_link: github_repo_runner_step_5.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/examples/github_repo_runner/github_repo_runner_step_3.rst+0 62 removed
    @@ -1,62 +0,0 @@
    -:orphan:
    -
    -**************************************************
    -Step 3: Implement the Flow to manage user requests
    -**************************************************
    -
    -In step 1 and 2, we have implemented the ``GithubRepoRunner`` and ``PyTorchLightningGithubRepoRunner`` components.
    -
    -Now, we are going to develop a component to dynamically handle user requests.
    -Let's dive in on how to develop the component with the following code:
    -
    -.. literalinclude:: ./app.py
    -    :lines: 142-190
    -
    -----
    -
    -********
    -Tutorial
    -********
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: Step 1: Implement the GithubRepoRunner Component
    -   :description: Clone and execute script from a GitHub Repo.
    -   :col_css: col-md-4
    -   :button_link: github_repo_runner_step_1.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -.. displayitem::
    -   :header: Step 2: Implement the PyTorch Lightning GithubRepoRunner Component
    -   :description: Automate PyTorch Lightning execution
    -   :col_css: col-md-4
    -   :button_link: github_repo_runner_step_2.html
    -   :height: 180
    -   :tag: Advanced
    -
    -.. displayitem::
    -   :header: Step 4: Implement the UI with StreamLit
    -   :description: Several pages application
    -   :col_css: col-md-4
    -   :button_link: github_repo_runner_step_4.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -
    -.. displayitem::
    -   :header: Step 5: Put it all together
    -   :description:
    -   :col_css: col-md-4
    -   :button_link: github_repo_runner_step_5.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/examples/github_repo_runner/github_repo_runner_step_4.rst+0 86 removed
    @@ -1,86 +0,0 @@
    -:orphan:
    -
    -***************************************
    -Step 4: Implement the UI with StreamLit
    -***************************************
    -
    -In step 3, we have implemented a Flow which dynamically creates a Work when a new request is added to the requests list.
    -
    -From the UI, we create 3 pages with `StreamLit <https://streamlit.io/>`_:
    -
    -* **Page 1**: Create a form with add a new request to the Flow state **requests**.
    -
    -* **Page 2**: Iterate through all the requests and display the associated information.
    -
    -* **Page 3**: Display the entire App State.
    -
    -
    -Render All Pages
    -^^^^^^^^^^^^^^^^
    -
    -.. literalinclude:: ./app.py
    -    :lines: 274-284
    -
    -**Page 1**
    -
    -.. literalinclude:: ./app.py
    -    :lines: 193-241
    -    :emphasize-lines: 43
    -
    -**Page 2**
    -
    -.. literalinclude:: ./app.py
    -    :lines: 244-264
    -
    -**Page 3**
    -
    -.. literalinclude:: ./app.py
    -    :lines: 267-271
    -
    -----
    -
    -********
    -Tutorial
    -********
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: 1. Implement the GithubRepoRunner Component
    -   :description: Clone and execute script from a GitHub Repo.
    -   :col_css: col-md-4
    -   :button_link: github_repo_runner_step_1.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -.. displayitem::
    -   :header: 2. Implement the PyTorch Lightning GithubRepoRunner Component
    -   :description: Automate PyTorch Lightning execution
    -   :col_css: col-md-4
    -   :button_link: github_repo_runner_step_2.html
    -   :height: 180
    -   :tag: Advanced
    -
    -.. displayitem::
    -   :header: 3. Implement the Flow to manage user requests
    -   :description: Dynamically create GithubRepoRunner
    -   :col_css: col-md-4
    -   :button_link: github_repo_runner_step_3.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -.. displayitem::
    -   :header: Step 5: Put it all together
    -   :description:
    -   :col_css: col-md-4
    -   :button_link: github_repo_runner_step_5.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/examples/github_repo_runner/github_repo_runner_step_5.rst+0 75 removed
    @@ -1,75 +0,0 @@
    -:orphan:
    -
    -***************************
    -Step 5: Put it all together
    -***************************
    -
    -Let's dive in on how to develop the component with the following code:
    -
    -.. literalinclude:: ./app.py
    -    :lines: 287-
    -
    -Run the application
    -^^^^^^^^^^^^^^^^^^^
    -
    -Clone the Lightning repo and run the following command:
    -
    -.. code-block:: bash
    -
    -   lightning run app docs/source/examples/github_repo_runner/app.py
    -
    -Add ``--cloud`` to run this application in the cloud.
    -
    -.. code-block:: bash
    -
    -   lightning run app docs/source/examples/github_repo_runner/app.py --cloud
    -
    -----
    -
    -**********************
    -More hands-on examples
    -**********************
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: Develop a DAG
    -   :description: Create a dag pipeline
    -   :col_css: col-md-4
    -   :button_link: ../dag/dag.html
    -   :height: 150
    -   :tag: Intermediate
    -
    -.. displayitem::
    -   :header: Develop a File Server
    -   :description: Train multiple models with different parameters
    -   :col_css: col-md-4
    -   :button_link: ../file_server/file_server.html
    -   :height: 150
    -   :tag: Intermediate
    -
    -.. displayitem::
    -   :header: Develop a HPO Sweeper
    -   :description: Train multiple models with different parameters
    -   :col_css: col-md-4
    -   :button_link: ../hpo/hpo.html
    -   :height: 150
    -   :tag: Intermediate
    -
    -.. displayitem::
    -   :header: Develop a Model Server
    -   :description: Serve multiple models with different parameters
    -   :col_css: col-md-4
    -   :button_link: ../model_server/model_server.html
    -   :height: 150
    -   :tag: Intermediate
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/examples/hands_on_example.rst+0 50 removed
    @@ -1,50 +0,0 @@
    -:orphan:
    -
    -#################
    -Hands-on Examples
    -#################
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: Build a DAG
    -   :description: Learn how to orchestrate workflows
    -   :col_css: col-md-6
    -   :button_link: dag/dag.html
    -   :height: 180
    -
    -.. displayitem::
    -   :header: Build a File Server
    -   :description: Learn how to upload and download files
    -   :col_css: col-md-6
    -   :button_link: file_server/file_server.html
    -   :height: 180
    -
    -.. displayitem::
    -   :header: Build a Github Repo Script Runner
    -   :description: Learn how to configure dynamic execution from the UI
    -   :col_css: col-md-6
    -   :button_link: github_repo_runner/github_repo_runner.html
    -   :height: 180
    -
    -.. displayitem::
    -   :header: Build a HPO Sweeper
    -   :description: Learn how to scale your training
    -   :col_css: col-md-6
    -   :button_link: hpo/hpo.html
    -   :height: 180
    -
    -.. displayitem::
    -   :header: Build a Model Server
    -   :description: Learn how to server your models
    -   :col_css: col-md-6
    -   :button_link: model_server_app_content.html
    -   :height: 180
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/examples/index.rst+0 36 removed
    @@ -1,36 +0,0 @@
    -########
    -Examples
    -########
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: Develop a DAG workflow
    -   :description: Develop sequential, non-reactive workflows
    -   :col_css: col-md-4
    -   :button_link: dag/dag.html
    -   :height: 150
    -
    -.. displayitem::
    -   :header:  Develop a File Server
    -   :description: Develop a file server
    -   :col_css: col-md-4
    -   :button_link: file_server/file_server.html
    -   :height: 150
    -
    -.. displayitem::
    -   :header: Develop a Github Repo Script Runner
    -   :description: Build an app to run a Github repo
    -   :col_css: col-md-4
    -   :button_link: github_repo_runner/github_repo_runner.html
    -   :height: 150
    -
    -.. displayitem::
    -   :header: Deploy a model
    -   :description: Learn how to deploy a model
    -   :col_css: col-md-4
    -   :button_link: model_server_app/model_server_app.html
    -   :height: 150
    
  • docs/source-app/examples/model_server_app/app.py+0 34 removed
    @@ -1,34 +0,0 @@
    -from locust_component import Locust
    -from model_server import MLServer
    -from train import TrainModel
    -
    -from lightning import LightningApp, LightningFlow
    -
    -
    -class TrainAndServe(LightningFlow):
    -    def __init__(self):
    -        super().__init__()
    -        self.train_model = TrainModel()
    -        self.model_server = MLServer(
    -            name="mnist-svm",
    -            implementation="mlserver_sklearn.SKLearnModel",
    -            workers=8,
    -        )
    -        self.performance_tester = Locust(num_users=100)
    -
    -    def run(self):
    -        self.train_model.run()
    -        self.model_server.run(self.train_model.best_model_path)
    -        if self.model_server.alive():
    -            # The performance tester needs the model server to be up
    -            # and running to be started, so the URL is added in the UI.
    -            self.performance_tester.run(self.model_server.url)
    -
    -    def configure_layout(self):
    -        return [
    -            {"name": "Server", "content": self.model_server.url + "/docs"},
    -            {"name": "Server Testing", "content": self.performance_tester},
    -        ]
    -
    -
    -app = LightningApp(TrainAndServe())
    
  • docs/source-app/examples/model_server_app/load_testing.rst+0 57 removed
    @@ -1,57 +0,0 @@
    -:orphan:
    -
    -***********************************
    -3. Build the Load Testing Component
    -***********************************
    -
    -Now, we are going to create a component to test the performance of your model server.
    -
    -We are going to use a python performance testing tool called `Locust <https://github.com/locustio/locust>`_.
    -
    -.. literalinclude:: ./locust_component.py
    -
    -
    -Finally, once the component is done, we need to create a ``locustfile.py`` file which defines the format of the request to send to your model server.
    -
    -The endpoint to hit has the following format: ``/v2/models/{MODEL_NAME}/versions/{VERSION}/infer``.
    -
    -.. literalinclude:: ./locustfile.py
    -
    -
    -----
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: 1.  Build a Train Component
    -   :description: Train a model and store its checkpoints with SKlearn
    -   :col_css: col-md-4
    -   :button_link: train.html
    -   :height: 150
    -   :tag: Intermediate
    -
    -.. displayitem::
    -   :header: 2. Build a Model Server Component
    -   :description: Use MLServer to server your models
    -   :col_css: col-md-4
    -   :button_link: model_server.html
    -   :height: 150
    -   :tag: Intermediate
    -
    -.. displayitem::
    -   :header: 4. Putting everything together.
    -   :description: Ensemble the components together and run the app
    -   :col_css: col-md-4
    -   :button_link: putting_everything_together.html
    -   :height: 150
    -   :tag: basic
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/examples/model_server_app/locust_component.py+0 43 removed
    @@ -1,43 +0,0 @@
    -import os
    -import subprocess
    -
    -from lightning import BuildConfig, LightningWork
    -
    -
    -class Locust(LightningWork):
    -    def __init__(self, num_users: int = 100):
    -        """This component checks the performance of a server. The server url is passed to its run method.
    -
    -        Arguments:
    -            num_users: Number of users emulated by Locust
    -
    -        """
    -        # Note: Using the default port 8089 of Locust.
    -        super().__init__(
    -            port=8089,
    -            parallel=True,
    -            cloud_build_config=BuildConfig(requirements=["locust"]),
    -        )
    -        self.num_users = num_users
    -
    -    def run(self, load_tested_url: str):
    -        # 1: Create the locust command line.
    -        cmd = " ".join(
    -            [
    -                "locust",
    -                "--master-host",
    -                str(self.host),
    -                "--master-port",
    -                str(self.port),
    -                "--host",
    -                str(load_tested_url),
    -                "-u",
    -                str(self.num_users),
    -            ]
    -        )
    -        # 2: Create another process with locust
    -        process = subprocess.Popen(cmd, cwd=os.path.dirname(__file__), shell=True)
    -
    -        # 3: Wait for the process to finish. As locust is a server,
    -        # this waits infinitely or if killed.
    -        process.wait()
    
  • docs/source-app/examples/model_server_app/locustfile.py+0 41 removed
    @@ -1,41 +0,0 @@
    -from locust import FastHttpUser, task
    -from sklearn import datasets
    -from sklearn.model_selection import train_test_split
    -
    -
    -class HelloWorldUser(FastHttpUser):
    -    def __init__(self, *args, **kwargs):
    -        super().__init__(*args, **kwargs)
    -        self._prepare_inference_request()
    -
    -    @task
    -    def predict(self):
    -        self.client.post(
    -            "/v2/models/mnist-svm/versions/v0.0.1/infer",
    -            json=self.inference_request,
    -        )
    -
    -    def _prepare_inference_request(self):
    -        # The digits dataset
    -        digits = datasets.load_digits()
    -
    -        # To apply a classifier on this data,
    -        # we need to flatten the image, to
    -        # turn the data in a (samples, feature) matrix:
    -        n_samples = len(digits.images)
    -        data = digits.images.reshape((n_samples, -1))
    -
    -        # Split data into train and test subsets
    -        _, X_test, _, _ = train_test_split(data, digits.target, test_size=0.5, shuffle=False)
    -
    -        x_0 = X_test[0:1]
    -        self.inference_request = {
    -            "inputs": [
    -                {
    -                    "name": "predict",
    -                    "shape": x_0.shape,
    -                    "datatype": "FP32",
    -                    "data": x_0.tolist(),
    -                }
    -            ]
    -        }
    
  • docs/source-app/examples/model_server_app/model_server_app_content.rst+0 84 removed
    @@ -1,84 +0,0 @@
    -
    -*********
    -Objective
    -*********
    -
    -Create a simple application that trains and serves a `Sklearn <https://scikit-learn.org/stable/>`_ machine learning model with `MLServer from SeldonIO <https://github.com/SeldonIO/MLServer>`_
    -
    -----
    -
    -*****************
    -Final Application
    -*****************
    -
    -Here is a gif of the final application built in this example.
    -
    -.. figure::  https://pl-public-data.s3.amazonaws.com/assets_lightning/ml_server_2.gif
    -
    -----
    -
    -*************
    -System Design
    -*************
    -
    -In order to create such application, we need to build several components:
    -
    -* A Model Train Component that trains a model and provides its trained weights
    -
    -* A Model Server Component that serves as an API endpoint for the model generated by the **Model Train Component**.
    -
    -* A Load Testing Component that tests the model server works as expected. This could be used to CI/CD the performance of newly generated models (left to the users).
    -
    -.. figure::  https://pl-public-data.s3.amazonaws.com/assets_lightning/model_server_app_2.png
    -
    -Let's dive into the tutorial.
    -
    -----
    -
    -********
    -Tutorial
    -********
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: 1.  Build a Train Component
    -   :description: Train a model and store its checkpoints with SKlearn
    -   :col_css: col-md-4
    -   :button_link: train.html
    -   :height: 150
    -   :tag: Intermediate
    -
    -.. displayitem::
    -   :header: 2. Build a Model Server Component
    -   :description: Use MLServer to server your models
    -   :col_css: col-md-4
    -   :button_link: model_server.html
    -   :height: 150
    -   :tag: Intermediate
    -
    -.. displayitem::
    -   :header: 3. Build a Load Testing Component
    -   :description: Use Locust to test your model servers
    -   :col_css: col-md-4
    -   :button_link: load_testing.html
    -   :height: 150
    -   :tag: Intermediate
    -
    -.. displayitem::
    -   :header: 4. Putting everything together.
    -   :description: Ensemble the components together and run the app
    -   :col_css: col-md-4
    -   :button_link: putting_everything_together.html
    -   :height: 150
    -   :tag: basic
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/examples/model_server_app/model_server_app.rst+0 15 removed
    @@ -1,15 +0,0 @@
    -:orphan:
    -
    -.. _model_server_example:
    -
    -######################
    -Develop a Model Server
    -######################
    -
    -**Audience:** Users who want to serve their trained models.
    -
    -**Prerequisite**: Reach :ref:`level 16+ <intermediate_level>`.
    -
    -----
    -
    -.. include:: model_server_app_content.rst
    
  • docs/source-app/examples/model_server_app/model_server.py+0 90 removed
    @@ -1,90 +0,0 @@
    -import json
    -import subprocess
    -
    -from lightning import BuildConfig, LightningWork
    -from lightning.app.storage.path import Path
    -
    -# ML_SERVER_URL = https://github.com/SeldonIO/MLServer
    -
    -
    -class MLServer(LightningWork):
    -    """This components uses SeldonIO MLServer library.
    -
    -    The model endpoint: /v2/models/{MODEL_NAME}/versions/{VERSION}/infer.
    -
    -    Arguments:
    -        name: The name of the model for the endpoint.
    -        implementation: The model loader class.
    -            Example: "mlserver_sklearn.SKLearnModel".
    -            Learn more here: $ML_SERVER_URL/tree/master/runtimes
    -        workers: Number of server worker.
    -
    -    """
    -
    -    def __init__(
    -        self,
    -        name: str,
    -        implementation: str,
    -        workers: int = 1,
    -        **kwargs,
    -    ):
    -        super().__init__(
    -            parallel=True,
    -            cloud_build_config=BuildConfig(
    -                requirements=["mlserver", "mlserver-sklearn"],
    -            ),
    -            **kwargs,
    -        )
    -        # 1: Collect the config's.
    -        self.settings = {
    -            "debug": True,
    -            "parallel_workers": workers,
    -        }
    -        self.model_settings = {
    -            "name": name,
    -            "implementation": implementation,
    -        }
    -        # 2: Keep track of latest version
    -        self.version = 1
    -
    -    def run(self, model_path: Path):
    -        """The model is downloaded when the run method is invoked.
    -
    -        Arguments:
    -            model_path: The path to the trained model.
    -
    -        """
    -        # 1: Use the host and port at runtime so it works in the cloud.
    -        # $ML_SERVER_URL/blob/master/mlserver/settings.py#L50
    -        if self.version == 1:
    -            # TODO: Reload the next version model of the model.
    -
    -            self.settings.update({"host": self.host, "http_port": self.port})
    -
    -            with open("settings.json", "w") as f:
    -                json.dump(self.settings, f)
    -
    -            # 2. Store the model-settings
    -            # $ML_SERVER_URL/blob/master/mlserver/settings.py#L120
    -            self.model_settings["parameters"] = {
    -                "version": f"v0.0.{self.version}",
    -                "uri": str(model_path.absolute()),
    -            }
    -            with open("model-settings.json", "w") as f:
    -                json.dump(self.model_settings, f)
    -
    -            # 3. Launch the Model Server
    -            subprocess.Popen("mlserver start .", shell=True)
    -
    -            # 4. Increment the version for the next time run is called.
    -            self.version += 1
    -
    -        else:
    -            # TODO: Load the next model and unload the previous one.
    -            pass
    -
    -    def alive(self):
    -        # Current hack, when the url is available,
    -        # the server is up and running.
    -        # This would be cleaned out and automated.
    -        return self.url != ""
    
  • docs/source-app/examples/model_server_app/model_server.rst+0 48 removed
    @@ -1,48 +0,0 @@
    -:orphan:
    -
    -*************************************
    -2. Develop the Model Server Component
    -*************************************
    -
    -In the code below, we use `MLServer <https://github.com/SeldonIO/MLServer>`_ which aims to provide an easy way to start serving your machine learning models through a REST and gRPC interface,
    -fully compliant with KFServing's V2 Dataplane spec.
    -
    -.. literalinclude:: ./model_server.py
    -
    -----
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: 1.  Develop a Train Component
    -   :description: Train a model and store its checkpoints with SKlearn
    -   :col_css: col-md-4
    -   :button_link: train.html
    -   :height: 150
    -   :tag: Intermediate
    -
    -.. displayitem::
    -   :header: 3. Develop a Load Testing Component
    -   :description: Use Locust to test your model servers
    -   :col_css: col-md-4
    -   :button_link: load_testing.html
    -   :height: 150
    -   :tag: Intermediate
    -
    -.. displayitem::
    -   :header: 4. Putting everything together.
    -   :description: Ensemble the Components together and run the App
    -   :col_css: col-md-4
    -   :button_link: putting_everything_together.html
    -   :height: 150
    -   :tag: basic
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/examples/model_server_app/putting_everything_together.rst+0 80 removed
    @@ -1,80 +0,0 @@
    -:orphan:
    -
    -******************************
    -4. Putting everything together
    -******************************
    -
    -In the code below, we put together the **TrainWork**, the **MLServer** and the **Locust** components in an ``app.py`` file.
    -
    -.. literalinclude:: ./app.py
    -
    -
    -***********
    -Run the App
    -***********
    -
    -To run the app, simply open a terminal and execute this command:
    -
    -.. code-block:: bash
    -
    -    lightning run app docs/source/examples/model_deploy_app/app.py
    -
    -Here is a gif of the UI.
    -
    -.. figure::  https://pl-public-data.s3.amazonaws.com/assets_lightning/ml_server_2.gif
    -
    -.. raw:: html
    -
    -    <br />
    -
    -Congrats, you have finished the **Build a Model Server** example !
    -
    -----
    -
    -******************
    -Find more examples
    -******************
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: Develop a DAG
    -   :description: Develop a DAG pipeline
    -   :col_css: col-md-4
    -   :button_link: ../dag/dag.html
    -   :height: 150
    -   :tag: Intermediate
    -
    -.. displayitem::
    -   :header: Develop a File Server
    -   :description: Train multiple models with different parameters
    -   :col_css: col-md-4
    -   :button_link: ../file_server/file_server.html
    -   :height: 150
    -   :tag: Intermediate
    -
    -.. displayitem::
    -   :header: Develop a Github Repo Script Runner
    -   :description: Run code from the internet in the cloud
    -   :col_css: col-md-4
    -   :button_link: ../github_repo_runner/github_repo_runner.html
    -   :height: 150
    -   :tag: Intermediate
    -
    -.. displayitem::
    -   :header: Develop a HPO Sweeper
    -   :description: Train multiple models with different parameters
    -   :col_css: col-md-4
    -   :button_link: ../hpo/hpo.html
    -   :height: 150
    -   :tag: Intermediate
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/examples/model_server_app/train.py+0 41 removed
    @@ -1,41 +0,0 @@
    -import joblib
    -from sklearn import datasets, svm
    -from sklearn.model_selection import train_test_split
    -
    -from lightning import LightningWork
    -from lightning.app.storage.path import Path
    -
    -
    -class TrainModel(LightningWork):
    -    """This component trains a Sklearn SVC model on digits dataset."""
    -
    -    def __init__(self):
    -        super().__init__()
    -        # 1: Add element to the state.
    -        self.best_model_path = None
    -
    -    def run(self):
    -        # 2: Load the Digits
    -        digits = datasets.load_digits()
    -
    -        # 3: To apply a classifier on this data,
    -        # we need to flatten the image, to
    -        # turn the data in a (samples, feature) matrix:
    -        n_samples = len(digits.images)
    -        data = digits.images.reshape((n_samples, -1))
    -
    -        # 4: Create a classifier: a support vector classifier
    -        classifier = svm.SVC(gamma=0.001)
    -
    -        # 5: Split data into train and test subsets
    -        X_train, _, y_train, _ = train_test_split(data, digits.target, test_size=0.5, shuffle=False)
    -
    -        # 6: We learn the digits on the first half of the digits
    -        classifier.fit(X_train, y_train)
    -
    -        # 7: Save the Sklearn model with `joblib`.
    -        model_file_name = "mnist-svm.joblib"
    -        joblib.dump(classifier, model_file_name)
    -
    -        # 8: Keep a reference the the generated model.
    -        self.best_model_path = Path("mnist-svm.joblib")
    
  • docs/source-app/examples/model_server_app/train.rst+0 49 removed
    @@ -1,49 +0,0 @@
    -:orphan:
    -
    -****************************
    -1. Build the Train Component
    -****************************
    -
    -In the code below, we create a work which trains a simple `SVC <https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html>`_ model on the digits dataset (classification).
    -
    -Once the model is trained, it is saved and a reference :class:`~lightning.app.storage.path.Path` with ``best_model_path`` state attribute.
    -
    -.. literalinclude:: ./train.py
    -
    -----
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: 2. Build a Model Server Component
    -   :description: Use MLServer to server your models
    -   :col_css: col-md-4
    -   :button_link: model_server.html
    -   :height: 150
    -   :tag: Intermediate
    -
    -.. displayitem::
    -   :header: 3. Build a Load Testing Component
    -   :description: Use Locust to test your model servers
    -   :col_css: col-md-4
    -   :button_link: load_testing.html
    -   :height: 150
    -   :tag: Intermediate
    -
    -.. displayitem::
    -   :header: 4. Putting everything together.
    -   :description: Ensemble the components together and run the app
    -   :col_css: col-md-4
    -   :button_link: putting_everything_together.html
    -   :height: 150
    -   :tag: basic
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/examples/research_demo_app.rst+0 5 removed
    @@ -1,5 +0,0 @@
    -:orphan:
    -
    -#########################
    -Build a Research Demo App
    -#########################
    
  • docs/source-app/get_started/add_an_interactive_demo.rst+0 15 removed
    @@ -1,15 +0,0 @@
    -:orphan:
    -
    -#######################
    -Add an Interactive Demo
    -#######################
    -
    -.. _add_an_interactive_Demo:
    -
    -**Required background:** Basic Python familiarity and complete the install guide.
    -
    -**Goal:** We'll walk you through the 4 key steps to run a Lightning App that trains and demos a model.
    -
    -----
    -
    -.. include:: go_beyond_training_content.rst
    
  • docs/source-app/get_started/build_model.rst+0 73 removed
    @@ -1,73 +0,0 @@
    -:orphan:
    -
    -.. _build_model:
    -
    -#######################
    -Build and Train a Model
    -#######################
    -
    -**Required background:** Basic Python familiarity and complete the  guide.
    -
    -**Goal:** We'll walk you through the creation of a model using PyTorch Lightning.
    -
    -----
    -
    -*********************************
    -A simple PyTorch Lightning script
    -*********************************
    -
    -Let's assume you already have a folder with those two files.
    -
    -.. code-block:: bash
    -
    -    pl_project/
    -        train.py            # your own script to train your models
    -        requirements.txt    # your python requirements.
    -
    -If you don't, simply create a ``pl_project`` folder with those two files and add the following `PyTorch Lightning <https://lightning.ai/docs/pytorch/latest/>`_ code  in the ``train.py`` file. This code trains a simple ``AutoEncoder`` on `MNIST Dataset <https://en.wikipedia.org/wiki/MNIST_database>`_.
    -
    -.. literalinclude:: ../code_samples/convert_pl_to_app/train.py
    -
    -Add the following to the ``requirements.txt`` file.
    -
    -.. literalinclude:: ../code_samples/convert_pl_to_app/requirements.txt
    -
    -Simply run the following commands in your terminal to install the requirements and train the model.
    -
    -.. code-block:: bash
    -
    -    pip install -r requirements.txt
    -    python train.py
    -
    -Get through `PyTorch Lightning Introduction <https://lightning.ai/docs/pytorch/stable/starter/introduction.html#step-1-define-lightningmodule>`_ to learn more.
    -
    -----
    -
    -**********
    -Next Steps
    -**********
    -
    -.. raw:: html
    -
    -   <br />
    -   <div class="display-card-container">
    -      <div class="row">
    -
    -.. displayitem::
    -   :header: Evolve a Model into an ML System
    -   :description: Develop an App to train a model in the cloud
    -   :col_css: col-md-6
    -   :button_link: training_with_apps.html
    -   :height: 180
    -
    -.. displayitem::
    -   :header: Start from a Template ML System
    -   :description: Learn about Apps, from a template.
    -   :col_css: col-md-6
    -   :button_link: go_beyond_training.html
    -   :height: 180
    -
    -.. raw:: html
    -
    -      </div>
    -   </div>
    
  • docs/source-app/get_started/go_beyond_training_content.rst+0 405 removed
    @@ -1,405 +0,0 @@
    -************************************************
    -The *Train & Demo PyTorch Lightning* Application
    -************************************************
    -
    -Find the *Train & Demo PyTorch Lightning* application in the `Lightning.ai App Gallery <https://lightning.ai/app/AU3WoWwdAP-Train%20%26%20Demo%20PyTorch%20Lightning>`_.
    -
    -Here is a recording of this App running locally and in the cloud with the same behavior.
    -
    -.. video:: https://pl-public-data.s3.amazonaws.com/assets_lightning/lightning_app_experience_cut.mp4
    -    :poster: https://pl-public-data.s3.amazonaws.com/assets_lightning/lightning_app_experience_cut.png
    -    :width: 600
    -    :class: background-video
    -    :autoplay:
    -    :loop:
    -    :muted:
    -
    -In the steps below, we are going to show you how to build this application.
    -
    -Here are `the entire App's code <https://github.com/Lightning-AI/lightning-quick-start>`_ and `its commented components. <https://github.com/Lightning-AI/lightning-quick-start/blob/main/quick_start/components.py>`_
    -
    -----
    -
    -*************************
    -Step 1: Install Lightning
    -*************************
    -
    -If you are using a virtual env, don't forget to activate it before running commands.
    -You must do so in every new shell.
    -
    -.. tip:: We highly recommend using virtual environments.
    -
    -.. code:: bash
    -
    -    pip install lightning
    -
    -----
    -
    -****************************************
    -Step 2: Install the *Train and Demo* App
    -****************************************
    -The first Lightning App we'll explore is an App to train and demo a machine learning model.
    -
    -..
    -    [|qs_code|], [|qs_live_app|].
    -
    -    .. |qs_live_app| raw:: html
    -
    -       <a href="https://01g3w6gqdvjqjnqw05ccy69nwy.litng-ai-03.litng.ai/view/Interactive%20demo" target="_blank">live app</a>
    -
    -    .. |qs_code| raw:: html
    -
    -       <a href="https://github.com/Lightning-AI/lightning-quick-start" target="_blank">code</a>
    -
    -
    -Install this App by typing:
    -
    -.. code-block:: bash
    -
    -    lightning_app install app lightning/quick-start
    -
    -Verify the App was successfully installed:
    -
    -.. code-block:: bash
    -
    -    cd lightning-quick-start
    -
    -----
    -
    -***************************
    -Step 3: Run the App locally
    -***************************
    -
    -Run the app locally with the ``run`` command 🤯
    -
    -.. code:: bash
    -
    -    lightning_app run app app.py
    -
    -----
    -
    -********************************
    -Step 4: Run the App in the cloud
    -********************************
    -
    -Add the ``--cloud`` argument to run on the `Lightning.AI cloud <http://lightning.ai/>`_. 🤯🤯🤯
    -
    -.. code:: bash
    -
    -    lightning_app run app app.py --cloud
    -
    -..
    -    Your app should look like this one (|qs_live_app|)
    -
    -----
    -
    -*******************
    -Understand the code
    -*******************
    -The App that we just launched trained a PyTorch Lightning model (although any framework works), then added an interactive demo.
    -
    -This is the App's code:
    -
    -.. code:: python
    -
    -    # lightning-quick-start/app.py
    -    import os.path as ops
    -    import lightning as L
    -    from quick_start.components import PyTorchLightningScript, ImageServeGradio
    -
    -    class TrainDeploy(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.train_work = PyTorchLightningScript(
    -                script_path=ops.join(ops.dirname(__file__), "./train_script.py"),
    -                script_args=["--trainer.max_epochs=5"],
    -            )
    -
    -            self.serve_work = ImageServeGradio(L.CloudCompute())
    -
    -        def run(self):
    -            # 1. Run the python script that trains the model
    -            self.train_work.run()
    -
    -            # 2. when a checkpoint is available, deploy
    -            if self.train_work.best_model_path:
    -                self.serve_work.run(self.train_work.best_model_path)
    -
    -        def configure_layout(self):
    -            tab_1 = {"name": "Model training", "content": self.train_work}
    -            tab_2 = {"name": "Interactive demo", "content": self.serve_work}
    -            return [tab_1, tab_2]
    -
    -    app = L.LightningApp(TrainDeploy())
    -
    -Let's break down the code section by section to understand what it is doing.
    -
    -----
    -
    -1: Define root component
    -^^^^^^^^^^^^^^^^^^^^^^^^
    -
    -A Lightning App provides a cohesive product experience for a set of unrelated components.
    -
    -The top-level component (Root) must subclass ``L.LightningFlow``
    -
    -
    -.. code:: python
    -    :emphasize-lines: 6
    -
    -    # lightning-quick-start/app.py
    -    import os.path as ops
    -    import lightning as L
    -    from quick_start.components import PyTorchLightningScript, ImageServeGradio
    -
    -    class TrainDeploy(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.train_work = PyTorchLightningScript(
    -                script_path=ops.join(ops.dirname(__file__), "./train_script.py"),
    -                script_args=["--trainer.max_epochs=5"],
    -            )
    -
    -            self.serve_work = ImageServeGradio(L.CloudCompute("cpu-small"))
    -
    -        def run(self):
    -            # 1. Run the python script that trains the model
    -            self.train_work.run()
    -
    -            # 2. when a checkpoint is available, deploy
    -            if self.train_work.best_model_path:
    -                self.serve_work.run(self.train_work.best_model_path)
    -
    -        def configure_layout(self):
    -            tab_1 = {"name": "Model training", "content": self.train_work}
    -            tab_2 = {"name": "Interactive demo", "content": self.serve_work}
    -            return [tab_1, tab_2]
    -
    -    app = L.LightningApp(TrainDeploy())
    -
    -----
    -
    -2: Define components
    -^^^^^^^^^^^^^^^^^^^^
    -In the __init__ method, we define the components that make up the App. In this case, we have 2 components,
    -a component to execute any PyTorch Lightning script (model training) and a second component to
    -start a Gradio server for demo purposes.
    -
    -.. code:: python
    -    :emphasize-lines: 9, 14
    -
    -    # lightning-quick-start/app.py
    -    import os.path as ops
    -    import lightning as L
    -    from quick_start.components import PyTorchLightningScript, ImageServeGradio
    -
    -    class TrainDeploy(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.train_work = PyTorchLightningScript(
    -                script_path=ops.join(ops.dirname(__file__), "./train_script.py"),
    -                script_args=["--trainer.max_epochs=5"],
    -            )
    -
    -            self.serve_work = ImageServeGradio(L.CloudCompute("cpu-small"))
    -
    -        def run(self):
    -            # 1. Run the python script that trains the model
    -            self.train_work.run()
    -
    -            # 2. when a checkpoint is available, deploy
    -            if self.train_work.best_model_path:
    -                self.serve_work.run(self.train_work.best_model_path)
    -
    -        def configure_layout(self):
    -            tab_1 = {"name": "Model training", "content": self.train_work}
    -            tab_2 = {"name": "Interactive demo", "content": self.serve_work}
    -            return [tab_1, tab_2]
    -
    -    app = L.LightningApp(TrainDeploy())
    -
    -----
    -
    -3: Define how components Flow
    -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    -Every component has a ``run`` method. The run method defines the 🌊 Flow 🌊 of how components interact together.
    -
    -In this case, we train a model (until completion). When it's done AND there exists a checkpoint, we launch a
    -demo server:
    -
    -.. code:: python
    -    :emphasize-lines: 18, 21, 22
    -
    -    # lightning-quick-start/app.py
    -    import os.path as ops
    -    import lightning as L
    -    from quick_start.components import PyTorchLightningScript, ImageServeGradio
    -
    -    class TrainDeploy(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.train_work = PyTorchLightningScript(
    -                script_path=ops.join(ops.dirname(__file__), "./train_script.py"),
    -                script_args=["--trainer.max_epochs=5"],
    -            )
    -
    -            self.serve_work = ImageServeGradio(L.CloudCompute("cpu-small"))
    -
    -        def run(self):
    -            # 1. Run the python script that trains the model
    -            self.train_work.run()
    -
    -            # 2. when a checkpoint is available, deploy
    -            if self.train_work.best_model_path:
    -                self.serve_work.run(self.train_work.best_model_path)
    -
    -        def configure_layout(self):
    -            tab_1 = {"name": "Model training", "content": self.train_work}
    -            tab_2 = {"name": "Interactive demo", "content": self.serve_work}
    -            return [tab_1, tab_2]
    -
    -    app = L.LightningApp(TrainDeploy())
    -
    -.. note:: If you've used other ML systems you'll be pleasantly surprised to not find decorators or YAML files.
    -
    -----
    -
    -4: Connect web user interfaces
    -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    -All our favorite tools normally have their own web user interfaces (UI).
    -
    -Implement the ``configure_layout`` method to connect them together:
    -
    -.. code:: python
    -    :emphasize-lines: 24-27
    -
    -    # lightning-quick-start/app.py
    -    import os.path as ops
    -    import lightning as L
    -    from quick_start.components import PyTorchLightningScript, ImageServeGradio
    -
    -    class TrainDeploy(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.train_work = PyTorchLightningScript(
    -                script_path=ops.join(ops.dirname(__file__), "./train_script.py"),
    -                script_args=["--trainer.max_epochs=5"],
    -            )
    -
    -            self.serve_work = ImageServeGradio(L.CloudCompute("cpu-small"))
    -
    -        def run(self):
    -            # 1. Run the python script that trains the model
    -            self.train_work.run()
    -
    -            # 2. when a checkpoint is available, deploy
    -            if self.train_work.best_model_path:
    -                self.serve_work.run(self.train_work.best_model_path)
    -
    -        def configure_layout(self):
    -            tab_1 = {"name": "Model training", "content": self.train_work}
    -            tab_2 = {"name": "Interactive demo", "content": self.serve_work}
    -            return [tab_1, tab_2]
    -
    -    app = L.LightningApp(TrainDeploy())
    -
    -----
    -
    -5: Init the ``app`` object
    -^^^^^^^^^^^^^^^^^^^^^^^^^^
    -Initialize an ``app`` object with the ``TrainDeploy`` component (this won't run the App yet):
    -
    -.. code:: python
    -    :emphasize-lines: 29
    -
    -    # lightning-quick-start/app.py
    -    import os.path as ops
    -    import lightning as L
    -    from quick_start.components import PyTorchLightningScript, ImageServeGradio
    -
    -    class TrainDeploy(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.train_work = PyTorchLightningScript(
    -                script_path=ops.join(ops.dirname(__file__), "./train_script.py"),
    -                script_args=["--trainer.max_epochs=5"],
    -            )
    -
    -            self.serve_work = ImageServeGradio(L.CloudCompute("cpu-small"))
    -
    -        def run(self):
    -            # 1. Run the python script that trains the model
    -            self.train_work.run()
    -
    -            # 2. when a checkpoint is available, deploy
    -            if self.train_work.best_model_path:
    -                self.serve_work.run(self.train_work.best_model_path)
    -
    -        def configure_layout(self):
    -            tab_1 = {"name": "Model training", "content": self.train_work}
    -            tab_2 = {"name": "Interactive demo", "content": self.serve_work}
    -            return [tab_1, tab_2]
    -
    -    app = L.LightningApp(TrainDeploy())
    -
    -----
    -
    -******************************
    -What components are supported?
    -******************************
    -Any component can work with Lightning AI!
    -
    -.. figure:: https://pl-public-data.s3.amazonaws.com/assets_lightning/Lightning.gif
    -    :alt: What is Lightning gif.
    -    :width: 100 %
    -
    -----
    -
    -**********
    -Next Steps
    -**********
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: Add components to your App
    -   :description: Expand your App by adding components.
    -   :col_css: col-md-4
    -   :button_link: ../workflows/extend_app.html
    -   :height: 180
    -
    -.. displayitem::
    -   :header: Build a component
    -   :description: Learn to build your own component.
    -   :col_css: col-md-4
    -   :button_link: ../workflows/build_lightning_component/index.html
    -   :height: 180
    -
    -.. displayitem::
    -   :header: Explore more Apps
    -   :description: Explore more apps for inspiration.
    -   :col_css: col-md-4
    -   :button_link: https://lightning.ai/apps
    -   :height: 180
    -
    -.. displayitem::
    -   :header: Under the hood
    -   :description: Explore how it works under the hood.
    -   :col_css: col-md-4
    -   :button_link: ../core_api/lightning_app/index.html
    -   :height: 180
    -
    -.. displayitem::
    -   :header: Run on your private cloud
    -   :description: Run Lightning Apps on your private VPC or on-prem.
    -   :button_link: ../workflows/run_on_private_cloud.html
    -   :col_css: col-md-4
    -   :height: 180
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/get_started/go_beyond_training.rst+0 14 removed
    @@ -1,14 +0,0 @@
    -:orphan:
    -
    -################################
    -Start from an ML system template
    -################################
    -
    -.. _go_beyond_training:
    -
    -**Required background:** Basic Python familiarity and complete the install guide.
    -
    -**Goal:** We'll walk you through the 4 key steps to run a Lightning App that trains and demos a model.
    -
    -
    -.. include:: go_beyond_training_content.rst
    
  • docs/source-app/get_started/jumpstart_from_app_gallery.rst+0 123 removed
    @@ -1,123 +0,0 @@
    -:orphan:
    -
    -#####################################
    -Start from Ready-to-Run Template Apps
    -#####################################
    -
    -.. _jumpstart_from_app_gallery:
    -
    -Anyone can build Apps for their own use cases and promote them on the `App Gallery <https://lightning.ai/apps>`_.
    -
    -In return, you can benefit from the work of others and get started faster by re-using a ready-to-run App close to your own use case.
    -
    -
    -*************
    -User Workflow
    -*************
    -
    -#. Visit the `App Gallery <https://lightning.ai/apps>`_ and look for an App close to your own use case.
    -
    -    .. raw:: html
    -
    -       <br />
    -
    -#. If **Launch** is available, it means the App is live and ready to be used! Take it for a spin.
    -
    -    .. figure:: https://pl-public-data.s3.amazonaws.com/assets_lightning/launch_button.png
    -        :alt: Launch Button on lightning.ai
    -        :width: 100 %
    -
    -#. By clicking **Clone & Run**, a copy of the App is added to your account and an instance starts running.
    -
    -
    -    .. video:: https://pl-public-data.s3.amazonaws.com/assets_lightning/clone_and_run.mp4
    -        :poster: https://pl-public-data.s3.amazonaws.com/assets_lightning/clone_and_run.png
    -        :width: 600
    -        :class: background-video
    -        :autoplay:
    -        :loop:
    -        :muted:
    -
    -#. If you found an App that matches what you need, move to **step 5**! Otherwise, go back to **step 1**.
    -
    -    .. raw:: html
    -
    -       <br />
    -
    -#. Copy the installation command (optionally from the clipboard on the right).
    -
    -    .. figure:: https://pl-public-data.s3.amazonaws.com/assets_lightning/install_command.png
    -        :alt: Install command on lightning.ai
    -        :width: 100 %
    -
    -#. Copy the command to your local terminal.
    -
    -    .. code-block:: bash
    -
    -        lightning_app install app lightning/hackernews-app
    -
    -#. Go through the installation steps.
    -
    -    .. video:: https://pl-public-data.s3.amazonaws.com/assets_lightning/install_an_app.mp4
    -        :poster: https://pl-public-data.s3.amazonaws.com/assets_lightning/install_an_app.png
    -        :width: 600
    -        :class: background-video
    -        :autoplay:
    -        :loop:
    -        :muted:
    -
    -#. Run the App locally.
    -
    -    .. code-block:: bash
    -
    -        cd LAI-Hackernews-App
    -        lightning_app run app app.py
    -
    -    .. video:: https://pl-public-data.s3.amazonaws.com/assets_lightning/hackernews.mp4
    -        :poster: https://pl-public-data.s3.amazonaws.com/assets_lightning/hackernews.png
    -        :width: 600
    -        :class: background-video
    -        :autoplay:
    -        :loop:
    -        :muted:
    -
    -#. Open the code with your favorite IDE, modify it, and run it back in the cloud.
    -
    -    .. video:: https://pl-public-data.s3.amazonaws.com/assets_lightning/hackernews_modified.mp4
    -        :poster: https://pl-public-data.s3.amazonaws.com/assets_lightning/hackernews_modified.png
    -        :width: 600
    -        :class: background-video
    -        :autoplay:
    -        :loop:
    -        :muted:
    -
    -----
    -
    -**********
    -Next Steps
    -**********
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: Add Component made by others to your App
    -   :description: Add more functionality to your projects
    -   :col_css: col-md-6
    -   :button_link: jumpstart_from_component_gallery.html
    -   :height: 180
    -
    -.. displayitem::
    -   :header: Level-up your skills with Lightning Apps
    -   :description: From Basic to Advanced Skills
    -   :col_css: col-md-6
    -   :button_link: ../levels/basic/index.html
    -   :height: 180
    -
    -.. raw:: html
    -
    -      </div>
    -   </div>
    -   <br />
    
  • docs/source-app/get_started/jumpstart_from_component_gallery.rst+0 151 removed
    @@ -1,151 +0,0 @@
    -:orphan:
    -
    -########################################
    -Add Component made by others to your App
    -########################################
    -
    -.. _jumpstart_from_component_gallery:
    -
    -Anyone can build components for their own use case and promote them on the `Component Gallery <https://lightning.ai/components>`_.
    -
    -In return, you can benefit from the work of others and add new functionalities to your Apps with minimal effort.
    -
    -
    -*************
    -User Workflow
    -*************
    -
    -#. Visit the `Component Gallery <https://lightning.ai/components>`_ and look for a Component close to something you want to do.
    -
    -    .. raw:: html
    -
    -       <br />
    -
    -#. Check out the code for inspiration or simply install the component from PyPi and use it.
    -
    -----
    -
    -*************
    -Success Story
    -*************
    -
    -The default `Train and Demo Application <https://github.com/Lightning-AI/lightning-quick-start>`_ trains a PyTorch Lightning
    -model and then starts a demo with `Gradio <https://gradio.app/>`_.
    -
    -.. code-block:: python
    -
    -    import os.path as ops
    -    import lightning as L
    -    from quick_start.components import PyTorchLightningScript, ImageServeGradio
    -
    -
    -    class TrainDeploy(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.train_work = PyTorchLightningScript(
    -                script_path=ops.join(ops.dirname(__file__), "./train_script.py"),
    -                script_args=["--trainer.max_epochs=5"],
    -            )
    -
    -            self.serve_work = ImageServeGradio(L.CloudCompute("cpu"))
    -
    -        def run(self):
    -            # 1. Run the python script that trains the model
    -            self.train_work.run()
    -
    -            # 2. when a checkpoint is available, deploy
    -            if self.train_work.best_model_path:
    -                self.serve_work.run(self.train_work.best_model_path)
    -
    -        def configure_layout(self):
    -            tab_1 = {"name": "Model training", "content": self.train_work}
    -            tab_2 = {"name": "Interactive demo", "content": self.serve_work}
    -            return [tab_1, tab_2]
    -
    -
    -    app = L.LightningApp(TrainDeploy())
    -
    -However, someone who wants to use this Aop (maybe you) found `Lightning HPO <https://lightning.ai/component/BA2slXI093-Lightning%20HPO>`_
    -from browsing the `Component Gallery <https://lightning.ai/components>`_ and decided to give it a spin after checking the associated
    -`Github Repository <https://github.com/Lightning-AI/LAI-lightning-hpo-App>`_.
    -
    -Once ``lightning_hpo`` installed, they improved the default App by easily adding HPO support to their project.
    -
    -Here is the resulting App. It is almost the same code, but it's way more powerful now!
    -
    -This is the power of `lightning.ai <https://lightning.ai/>`_ ecosystem 🔥⚡🔥
    -
    -.. code-block:: python
    -
    -    import os.path as ops
    -    import lightning as L
    -    from quick_start.components import PyTorchLightningScript, ImageServeGradio
    -    import optuna
    -    from optuna.distributions import LogUniformDistribution
    -    from lightning_hpo import Optimizer, BaseObjective
    -
    -
    -    class HPOPyTorchLightningScript(PyTorchLightningScript, BaseObjective):
    -        @staticmethod
    -        def distributions():
    -            return {"model.lr": LogUniformDistribution(0.0001, 0.1)}
    -
    -
    -    class TrainDeploy(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.train_work = Optimizer(
    -                script_path=ops.join(ops.dirname(__file__), "./train_script.py"),
    -                script_args=["--trainer.max_epochs=5"],
    -                objective_cls=HPOPyTorchLightningScript,
    -                n_trials=4,
    -            )
    -
    -            self.serve_work = ImageServeGradio(L.CloudCompute("cpu"))
    -
    -        def run(self):
    -            # 1. Run the python script that trains the model
    -            self.train_work.run()
    -
    -            # 2. when a checkpoint is available, deploy
    -            if self.train_work.best_model_path:
    -                self.serve_work.run(self.train_work.best_model_path)
    -
    -        def configure_layout(self):
    -            tab_1 = {"name": "Model training", "content": self.train_work.hi_plot}
    -            tab_2 = {"name": "Interactive demo", "content": self.serve_work}
    -            return [tab_1, tab_2]
    -
    -
    -    app = L.LightningApp(TrainDeploy())
    -
    -----
    -
    -**********
    -Next Steps
    -**********
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: Start from Ready-to-Run Template Apps
    -   :description: Jump-start your projects development
    -   :col_css: col-md-6
    -   :button_link: jumpstart_from_app_gallery.html
    -   :height: 180
    -
    -.. displayitem::
    -   :header: Level-up your skills with Lightning Apps
    -   :description: From Basic to Advanced Skills
    -   :col_css: col-md-6
    -   :button_link: ../levels/basic/index.html
    -   :height: 180
    -
    -.. raw:: html
    -
    -      </div>
    -   </div>
    -   <br />
    
  • docs/source-app/get_started/training_with_apps.rst+0 125 removed
    @@ -1,125 +0,0 @@
    -:orphan:
    -
    -################################
    -Evolve a model into an ML system
    -################################
    -
    -.. _convert_pl_to_app:
    -
    -**Required background:** Basic Python familiarity and complete the :ref:`build_model` guide.
    -
    -**Goal:** We'll walk you through the two key steps to build your first Lightning App from your existing PyTorch Lightning scripts.
    -
    -
    -*******************
    -Training and beyond
    -*******************
    -
    -With `PyTorch Lightning <https://github.com/Lightning-AI/lightning/tree/master/src/lightning/pytorch>`__, we abstracted distributed training and hardware, by organizing PyTorch code.
    -With `Lightning Apps <https://github.com/Lightning-AI/lightning/tree/master/src/lightning/app>`__, we unified the local and cloud experience while abstracting infrastructure.
    -
    -By using `PyTorch Lightning <https://github.com/Lightning-AI/lightning/tree/master/src/lightning/pytorch>`__ and `Lightning Apps <https://github.com/Lightning-AI/lightning/tree/master/src/lightning/app>`__
    -together, a completely new world of possibilities emerges.
    -
    -.. figure:: https://pl-public-data.s3.amazonaws.com/assets_lightning/pl_to_app_4.png
    -    :alt: From PyTorch Lightning to Lightning App
    -    :width: 100 %
    -
    -----
    -
    -******************************************
    -1. Write an App to run the train.py script
    -******************************************
    -
    -This article continues where the :ref:`build_model` guide finished.
    -
    -Create an additional file ``app.py`` in the ``pl_project`` folder as follows:
    -
    -.. code-block:: bash
    -
    -    pl_project/
    -        app.py
    -        train.py
    -        requirements.txt
    -
    -Inside the ``app.py`` file, add the following code.
    -
    -.. literalinclude:: ../code_samples/convert_pl_to_app/app.py
    -
    -This App runs the PyTorch Lightning script contained in the ``train.py`` file using the powerful :class:`~lightning.app.components.python.tracer.TracerPythonScript` component. This is really worth checking out!
    -
    -----
    -
    -************************************************
    -2. Run the train.py file locally or in the cloud
    -************************************************
    -
    -First, go to the ``pl_folder`` folder from the local terminal and install the requirements.
    -
    -.. code-block:: bash
    -
    -    cd pl_folder
    -    pip install -r requirements.txt
    -
    -To run your app, copy the following command to your local terminal:
    -
    -.. code-block:: bash
    -
    -    lightning_app run app app.py
    -
    -Simply add ``--cloud`` to run this application in the cloud with a GPU machine 🤯
    -
    -.. code-block:: bash
    -
    -    lightning_app run app app.py --cloud
    -
    -
    -Congratulations! Now, you know how to run a `PyTorch Lightning <https://github.com/Lightning-AI/lightning/tree/master/src/lightning/pytorch>`_ script with Lightning Apps.
    -
    -Lightning Apps can make your ML system way more powerful, keep reading to learn how.
    -
    -----
    -
    -**********
    -Next Steps
    -**********
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: Level-up with Lightning Apps
    -   :description: From Basics to Advanced Skills
    -   :col_css: col-md-4
    -   :button_link: ../levels/basic/index.html
    -   :height: 180
    -
    -.. displayitem::
    -   :header: Add an Interactive Demo
    -   :description: Add a Gradio Demo once the training is finished
    -   :col_css: col-md-4
    -   :button_link: add_an_interactive_demo.html
    -   :height: 180
    -
    -.. displayitem::
    -   :header: Add Model Serving
    -   :description: Serve and load testing with MLServer and Locust
    -   :col_css: col-md-4
    -   :button_link: ../examples/model_server_app/model_server_app.html
    -   :height: 180
    -
    -.. displayitem::
    -   :header: Add DAG Orchestration
    -   :description: Organize your processing, training and metrics collection
    -   :col_css: col-md-4
    -   :button_link: ../examples/dag/dag.html
    -   :height: 180
    -
    -.. displayitem::
    -   :header: Add Team Collaboration
    -   :description: Create an app to run any PyTorch Lightning Script from Github
    -   :col_css: col-md-4
    -   :button_link: ../examples/github_repo_runner/github_repo_runner.html
    -   :height: 180
    
  • docs/source-app/get_started/what_app_can_do.rst+0 187 removed
    @@ -1,187 +0,0 @@
    -:orphan:
    -
    -############################################
    -Discover what Lightning Apps can do in 5 min
    -############################################
    -
    -.. _what_app_can_do:
    -
    -Lightning Apps can be plenty things, and while a picture is worth a thousand words, videos showing you examples should be worth even more.
    -
    -
    -*****************************
    -Flashy - Auto ML App (Public)
    -*****************************
    -
    -Train a model on any image or text dataset without writing any code. Flashy uses `React.js <https://reactjs.org/>`_ for its frontend.
    -
    -Find `Flashy <https://lightning.ai/app/PgM82rHUWu-Flashy>`_ on the App Gallery and the `Flashy codebase. <https://github.com/Lightning-AI/LAI-Flashy-App>`_ on GitHub.
    -
    -.. video:: https://pl-public-data.s3.amazonaws.com/assets_lightning/flashy.mp4
    -    :poster: https://pl-public-data.s3.amazonaws.com/assets_lightning/flashy.png
    -    :width: 600
    -    :class: background-video
    -    :autoplay:
    -    :loop:
    -    :muted:
    -
    -.. ----
    -
    -.. ***************************************
    -.. NVIDIA Omniverse Sampling App (Private)
    -.. ***************************************
    -
    -.. Use `Nvidia Sampling Omniverse <https://www.nvidia.com/en-gb/omniverse/>`_ to generate synthetic samples from 3D meshes and train an object detector on that data.
    -
    -.. .. video:: https://pl-public-data.s3.amazonaws.com/assets_lightning/Omniverse-Sampling.mp4
    -        :poster: https://pl-public-data.s3.amazonaws.com/assets_lightning/Omniverse-Sampling.png
    -        :width: 600
    -        :class: background-video
    -        :autoplay:
    -        :loop:
    -        :muted:
    -
    -----
    -
    -*********************
    -Research App (Public)
    -*********************
    -
    -Share your paper ``bundled`` with the arxiv link, poster, live jupyter notebook, interactive demo to try the model, and more!
    -
    -Find the `Research App <https://lightning.ai/app/KDKgKk3HVW-Research%20Poster>`_  on the App Gallery and the `Research App codebase. <https://github.com/Lightning-AI/LAI-research-template-App>`_ on GitHub.
    -
    -.. video:: https://pl-public-data.s3.amazonaws.com/assets_lightning/research_app.mp4
    -    :poster: https://pl-public-data.s3.amazonaws.com/assets_lightning/research_app.png
    -    :width: 600
    -    :class: background-video
    -    :autoplay:
    -    :loop:
    -    :muted:
    -
    -----
    -
    -************************************************
    -ScratchPad - Notebook Manager for Team  (Public)
    -************************************************
    -
    -Run multiple Jupyter Notebooks on cloud CPUs or machines with multiple GPUs.
    -
    -Find the `ScratchPad App <https://lightning.ai/app/hvUwbEG70B-ScratchPad%2C%20Notebook%20Manager%20for%20Teams>`_  on the App Gallery and the `ScratchPad App codebase <https://github.com/Lightning-AI/LAI-lightning-template-jupyterlab-App>`_ on GitHub.
    -
    -.. note:: ScratchPad is `tested end-to-end <https://github.com/Lightning-AI/LAI-lightning-template-jupyterlab-App/blob/master/tests/test_template_jupyterlab.py#L6>`_ on every Lightning App commit with `pytest <https://docs.pytest.org/en/7.1.x/>`_.
    -
    -.. video:: https://pl-public-data.s3.amazonaws.com/assets_lightning/notebook_apps.mp4
    -    :poster: https://pl-public-data.s3.amazonaws.com/assets_lightning/notebook_apps.png
    -    :width: 600
    -    :class: background-video
    -    :autoplay:
    -    :loop:
    -    :muted:
    -
    -----
    -
    -***********************
    -InVideo Search (Public)
    -***********************
    -
    -This App lets you find anything you're looking for inside a video. The engine is powered by `Open AI CLIP <https://www.openai.com/index/clip/>`_.
    -
    -Find the `InVideo Search App <https://lightning.ai/app/7pmQNIDxAE-InVideo%20Search>`_  on the App Gallery and the `InVideo Search App codebase. <https://github.com/Lightning-AI/LAI-InVideo-search-App>`_ in GitHub.
    -
    -.. video:: https://pl-public-data.s3.amazonaws.com/assets_lightning/video_search_2.mp4
    -    :poster: https://pl-public-data.s3.amazonaws.com/assets_lightning/video_search_2.png
    -    :width: 600
    -    :class: background-video
    -    :autoplay:
    -    :loop:
    -    :muted:
    -
    -----
    -
    -******************************
    -AI-powered HackerNews (Public)
    -******************************
    -
    -Save yourself time, and get Hacker News story recommendations, chosen for you specifically. This Lightning App was designed to illustrate a full end-to-end MLOPs workflow aimed at enterprise recommendation systems.
    -
    -Find the `AI-powered HackerNews App <https://lightning.ai/app/g1VJ8GZ7XF-AI-powered%20HackerNews>`_  on the App Gallery and the `AI-powered HackerNews App codebase. <https://github.com/Lightning-AI/LAI-Hackernews-App>`_ on GitHub.
    -
    -.. video:: https://pl-public-data.s3.amazonaws.com/assets_lightning/hackernews_app.mp4
    -    :poster: https://pl-public-data.s3.amazonaws.com/assets_lightning/hackernews_app.png
    -    :width: 600
    -    :class: background-video
    -    :autoplay:
    -    :loop:
    -    :muted:
    -
    -----
    -
    -*********************************************************************
    -Lightning Apps can turn ML into scalable systems in days — not months
    -*********************************************************************
    -
    -Use the Lightning framework to develop any ML system: train and deploy a model, create an ETL pipeline,
    -or spin up a research demo — using the intuitive principles we pioneered with PyTorch Lightning.
    -
    -.. figure:: https://pl-public-data.s3.amazonaws.com/assets_lightning/apps_logos_2.png
    -   :alt: Apps with Logos
    -   :width: 100 %
    -
    -Anyone who knows Python can build a Lightning App, even without machine learning experience.
    -
    -Lightning Apps are:
    -
    -- cloud agnostic
    -- fault-tolerant, distributed, cost optimized
    -- production ready
    -- local and cloud debuggable
    -- highly reactive & interactive
    -- connect multiple UIs together
    -- built for team collaboration
    -- framework agnostic, use your own stack
    -- and much more
    -
    -.. video:: https://pl-public-data.s3.amazonaws.com/assets_lightning/lightning_app_experience_cut.mp4
    -    :poster: https://pl-public-data.s3.amazonaws.com/assets_lightning/lightning_app_experience_cut.png
    -    :width: 600
    -    :class: background-video
    -    :autoplay:
    -    :loop:
    -    :muted:
    -
    -**********
    -Next Steps
    -**********
    -
    -.. raw:: html
    -
    -   <br />
    -   <div class="display-card-container">
    -      <div class="row">
    -
    -.. displayitem::
    -   :header: Build & Train a Model
    -   :description: Discover PyTorch Lightning and train your first Model.
    -   :col_css: col-md-4
    -   :button_link: build_model.html
    -   :height: 180
    -
    -.. displayitem::
    -   :header: Evolve a Model into an ML System
    -   :description: Develop an App to train a model in the cloud
    -   :col_css: col-md-4
    -   :button_link: training_with_apps.html
    -   :height: 180
    -
    -.. displayitem::
    -   :header: Start from an ML system template
    -   :description: Learn about Apps, from a template.
    -   :col_css: col-md-4
    -   :button_link: go_beyond_training.html
    -   :height: 180
    -
    -.. raw:: html
    -
    -      </div>
    -   </div>
    
  • docs/source-app/glossary/app_tree.rst+0 113 removed
    @@ -1,113 +0,0 @@
    -:orphan:
    -
    -.. _app_component_tree:
    -
    -###################
    -App Component Tree
    -###################
    -
    -**Audience:** Users who want to know how components can be composed with each other.
    -
    -**Level:** Basic
    -
    -----
    -
    -**************************************
    -What is an Application Component Tree?
    -**************************************
    -
    -Components can be nested to form component trees where the LightningFlows are its branches and LightningWorks are its leaves.
    -
    -This design enables users to organize and maintain their code with more ease, but more importantly, this helps creating an ecosystem with reusable components.
    -
    -Here's a basic application with four flows and two works (associated tree structure):
    -
    -.. figure:: https://pl-public-data.s3.amazonaws.com/assets_lightning/tree.gif
    -    :alt: Basic App Components
    -    :width: 100 %
    -
    -
    -.. literalinclude:: ../code_samples/quickstart/app_comp.py
    -
    -A Lightning app runs all flows into a single process. Its flows coordinate the execution of the works each running in their own independent processes.
    -
    -----
    -
    -***********************************************
    -How do I define my application component tree?
    -***********************************************
    -
    -In order to define your application component tree, you need create a tree of components and attach them to your root flow.
    -
    -You can attach your components in the **__init__** method of a flow.
    -
    -.. code-block:: python
    -
    -    import lightning as L
    -
    -
    -    class RootFlow(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            # The `Work` component is attached here.
    -            self.work = Work()
    -
    -            # The `NestedFlow` component is attached here.
    -            self.nested_flow = NestedFlow()
    -
    -Once done, simply add the root flow to a Lightning app as follows:
    -
    -.. code-block:: python
    -
    -    app = L.LightningApp(RootFlow())
    -
    -----
    -
    -******************************************
    -Is my application component tree static?
    -******************************************
    -
    -No, Lightning supports dynamic flows and works.
    -
    -You can simply attach your components in the **run** method of a flow using the Python functions **hasattr**, **setattr**, and **getattr**.
    -
    -.. code-block:: python
    -
    -    class RootFlow(L.LightningFlow):
    -        def run(self):
    -
    -            if not hasattr(self, "work"):
    -                # The `Work` component is attached here.
    -                setattr(self, "work", Work())
    -            # Run the `Work` component.
    -            getattr(self, "work").run()
    -
    -            if not hasattr(self, "nested_flow"):
    -                # The `NestedFlow` component is attached here.
    -                setattr(self, "nested_flow", NestedFlow())
    -            # Run the `NestedFlow` component.
    -            getattr(self, "wonested_flowrk").run()
    -
    -
    -But it is usually more readable to use Lightning built-in :class:`~lightning.app.structures.Dict` or :class:`~lightning.app.structures.List` as follows:
    -
    -.. code-block:: python
    -
    -    from lightning.app.structures import Dict
    -
    -
    -    class RootFlow(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.dict = Dict()
    -
    -        def run(self):
    -            if "work" not in self.dict:
    -                # The `Work` component is attached here.
    -                self.dict["work"] = Work()
    -            self.dict["work"].run()
    -
    -            if "nested_flow" not in self.dict:
    -                # The `NestedFlow` component is attached here.
    -                self.dict["nested_flow"] = NestedFlow()
    -            self.dict["nested_flow"].run()
    
  • docs/source-app/glossary/build_config/build_config_advanced.rst+0 63 removed
    @@ -1,63 +0,0 @@
    -:orphan:
    -
    -##############################
    -Build Configuration (Advanced)
    -##############################
    -
    -**Audience:** Users who want full control over the docker image that is being installed in the cloud.
    -
    -**Level:** Advanced
    -
    -Advanced users who need full control over the environment a LightningWork runs in can specify a custom docker image that will be deployed in the cloud.
    -
    -
    -----
    -
    -******************
    -Use a docker image
    -******************
    -
    -Create a :class:`~lightning.app.utilities.packaging.build_config.BuildConfig` and provide a **publicly accessible** link to where the image is hosted:
    -
    -.. code-block:: python
    -
    -    from lightning.app import LightningWork, BuildConfig
    -
    -
    -    class MyWork(LightningWork):
    -        def __init__(self):
    -            super().__init__()
    -
    -            # Using a publicly hosted docker image:
    -            self.cloud_build_config = BuildConfig(
    -                # This is one of the base images Lightning uses by default
    -                image="ghcr.io/gridai/base-images:v1.8-gpu"
    -            )
    -
    -            # Can also be combined with extra requirements
    -            self.cloud_build_config = BuildConfig(image="...", requirements=["torchmetrics"])
    -
    -
    -.. warning::
    -    Many public hosters like DockerHub apply rate limits for public images. We recommend to pull images from your own registry.
    -    For example, you can set up a
    -    `docker registry on GitHub <https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry>`_.
    -
    -
    -.. note::
    -    - The build config only applies when running in the cloud and gets ignored otherwise. A local build config is currently not supported.
    -    - Images from private registries are currently not supported.
    -
    -.. note::
    -    Custom docker images must have python installed. We'll use `virtualenv` from this system python to create a virtual environment.
    -    We'll also configure the `virtualenv` to use the packages installed under system's python so your packages are not lost
    -
    -----
    -
    -
    -*********************
    -Provide a docker file
    -*********************
    -
    -.. note::
    -    Not yet supported. Coming soon.
    
  • docs/source-app/glossary/build_config/build_config_basic.rst+0 68 removed
    @@ -1,68 +0,0 @@
    -:orphan:
    -
    -###########################
    -Build Configuration (Basic)
    -###########################
    -
    -**Audience:** Users who need to install Python packages for an individual LightningWork.
    -
    -**Level:** Basic
    -
    -----
    -
    -***********************************
    -List dependencies in separate files
    -***********************************
    -
    -If you are building an app with multiple LightningWorks that have different or even conflicting requirements, split your dependencies into individual files
    -for more granular control.
    -
    -.. code-block:: bash
    -
    -    ├── app.py
    -    ├── requirements.txt          # Global requirements for the entire app
    -    └── works
    -        ├── serve
    -        │   ├── requirements.txt  # Requirements specific to the 'serve' work
    -        │   └── serve.py          # Source file for the LightningWork
    -        └── train
    -            ├── requirements.txt  # Requirements specific to the 'train' work
    -            └── train.py          # Source file for the LightningWork
    -
    -The requirements.txt file must be located in the same directory as the source file of the LightningWork.
    -When the LightningWork starts up, it will pick up the requirements file if present and install all listed packages.
    -
    -.. note::
    -    This only applies when running in the cloud. The requirements.txt files get ignored when running locally.
    -
    -----
    -
    -***********************************
    -Define the requirements in the code
    -***********************************
    -
    -Instead of listing the requirements in a file, you can also pass them to the LightningWork at runtime using the
    -:class:`~lightning.app.utilities.packaging.build_config.BuildConfig`:
    -
    -.. code-block:: python
    -    :emphasize-lines: 7
    -
    -    from lightning.app import LightningWork, BuildConfig
    -
    -
    -    class MyWork(LightningWork):
    -        def __init__(self):
    -            super().__init__()
    -            self.cloud_build_config = BuildConfig(requirements=["torch>=1.8", "torchmetrics"])
    -
    -.. note::
    -    The build config only applies when running in the cloud and gets ignored otherwise. A local build config is currently not supported.
    -
    -.. warning::
    -     Custom base images are not supported with the default CPU cloud compute. For example:
    -
    -     .. code-block:: py
    -
    -         class MyWork(LightningWork):
    -             def __init__(self):
    -              super().__init__(cloud_build_config=BuildConfig(image="my-custom-image")) # no cloud compute, for example default work
    
  • docs/source-app/glossary/build_config/build_config_intermediate.rst+0 56 removed
    @@ -1,56 +0,0 @@
    -:orphan:
    -
    -##################################
    -Build Configuration (Intermediate)
    -##################################
    -
    -**Audience:** Users who need to execute commands to configure the machine before a LightningWork runs on it.
    -
    -**Level:** Intermediate
    -
    -When a LightningWork machine starts up in the cloud, it uses a lightweight operating system with essential packages pre-installed.
    -If you need to install additional system packages or run other configuration steps before your code executes on that machine, it is possible to do so by creating a custom
    -:class:`~lightning.app.utilities.packaging.build_config.BuildConfig`:
    -
    -1.  Subclass :class:`~lightning.app.utilities.packaging.build_config.BuildConfig`:
    -
    -    .. code-block:: python
    -
    -        from lightning.app import BuildConfig
    -
    -
    -        @dataclass
    -        class CustomBuildConfig(BuildConfig):
    -            def build_commands(self):
    -                return ["sudo apt-get install libsparsehash-dev"]
    -
    -
    -2.  Set the build config on the LightningWork:
    -
    -    .. code-block:: python
    -
    -        from lightning.app import LightningWork
    -
    -
    -        class MyWork(LightningWork):
    -            def __init__(self):
    -                super().__init__()
    -
    -                # Use the custom build config
    -                self.cloud_build_config = CustomBuildConfig()
    -
    -                # Can also be combined with extra requirements
    -                self.cloud_build_config = CustomBuildConfig(requirements=["torchmetrics"])
    -
    -.. note::
    -    - When you need to execute commands or install tools that require more privileges than the current user has, you can use ``sudo`` without needing to provide a password, e.g., when installing system packages.
    -    - The build config only applies when running in the cloud and gets ignored otherwise. A local build config is currently not supported.
    -
    -.. warning::
    -     Custom base images are not supported with the default CPU cloud compute. For example:
    -
    -     .. code-block:: py
    -
    -         class MyWork(LightningWork):
    -             def __init__(self):
    -              super().__init__(cloud_build_config=BuildConfig(image="my-custom-image")) # no cloud compute, for example default work
    
  • docs/source-app/glossary/build_config/build_config.rst+0 43 removed
    @@ -1,43 +0,0 @@
    -:orphan:
    -
    -.. _build_config:
    -
    -###################
    -Build Configuration
    -###################
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: Basic
    -   :description: Learn how to manage Python dependencies for an individual LightningWork
    -   :col_css: col-md-6
    -   :button_link: build_config_basic.html
    -   :height: 150
    -   :tag: basic
    -
    -.. displayitem::
    -   :header: Intermediate
    -   :description: Learn how to run custom build commands for a LightningWork
    -   :col_css: col-md-6
    -   :button_link: build_config_intermediate.html
    -   :height: 150
    -   :tag: intermediate
    -
    -.. displayitem::
    -   :header: Advanced
    -   :description: Learn how to use a custom Docker image for a LightningWork
    -   :col_css: col-md-6
    -   :button_link: build_config_advanced.html
    -   :height: 150
    -   :tag: advanced
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/glossary/command_lines/command_lines.rst+0 69 removed
    @@ -1,69 +0,0 @@
    -:orphan:
    -
    -############################
    -Command-line Interface (CLI)
    -############################
    -
    -**Audience:** Users looking to create a command line interface (CLI) for their application.
    -
    -----
    -
    -**************
    -What is a CLI?
    -**************
    -
    -A Command-line Interface (CLI) is an user interface (UI) in a terminal to interact with a specific program.
    -
    -.. note::
    -
    -    The Lightning guideline to build CLI is `lightning_app <VERB> <NOUN> ...` or `<ACTION> <OBJECT> ...`.
    -
    -As an example, Lightning provides a CLI to interact with your Lightning Apps and the `lightning.ai <https://lightning.ai/>`_ platform as follows:
    -
    -.. code-block:: bash
    -
    -    main
    -    ├── fork - Forks an App.
    -    ├── init - Initializes a Lightning App and/or Component.
    -    │   ├── app
    -    │   ├── component
    -    │   ├── pl-app - Creates an App from your PyTorch Lightning source files.
    -    │   └── react-ui - Creates a React UI to give a Lightning Component a React.js web UI
    -    ├── install - Installs a Lightning App and/or Component.
    -    │   ├── app
    -    │   └── component
    -    ├── list - Lists Lightning AI self-managed resources (apps)
    -    │   └── apps - Lists your Lightning AI Apps.
    -    ├── login - Logs in to your lightning.ai account.
    -    ├── logout - Logs out of your lightning.ai account.
    -    ├── run - Runs a Lightning App locally or on the cloud.
    -    │   └── app - Runs an App from a file.
    -    ├── show - Shows given resource.
    -    │   └── logs - Shows cloud application logs. By default prints logs for all currently available Components.
    -    ├── stop - Stops your App.
    -    └── tree - Shows the command tree of your CLI.
    -
    -Learn more about `Command-line interfaces here <https://en.wikipedia.org/wiki/Command-line_interface>`_.
    -
    -----
    -
    -**********
    -Learn more
    -**********
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: Develop a Command Line Interface
    -   :description: Learn how to develop a CLI for your App.
    -   :col_css: col-md-6
    -   :button_link: ../../workflows/build_command_line_interface/index_content.html
    -   :height: 150
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/glossary/dag.rst+0 46 removed
    @@ -1,46 +0,0 @@
    -######################
    -Directed Acyclic Graph
    -######################
    -**Audience:** Users coming from MLOps to Lightning Apps, looking for more flexibility.
    -
    -----
    -
    -*****************************
    -Is Lightning a DAG framework?
    -*****************************
    -No.
    -
    -A Lightning App enables developers to express complex, interactive applications that are impossible to create with DAGs.
    -
    -----
    -
    -*********************************
    -Can I Build a DAG with Lightning?
    -*********************************
    -Yes!
    -
    -DAGs are one of the easiest Lightning Apps to build. For example, here's a :doc:`full app that defines a DAG <../examples/dag/dag>`.
    -
    -----
    -
    -********
    -Examples
    -********
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: Build a DAG
    -   :description: Learn how to create a DAG with Lightning
    -   :col_css: col-md-4
    -   :button_link: ../examples/dag/dag.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/glossary/debug_app.rst+0 3 removed
    @@ -1,3 +0,0 @@
    -:orphan:
    -
    -.. include:: ../workflows/debug_locally.rst
    
  • docs/source-app/glossary/distributed_fe.rst+0 5 removed
    @@ -1,5 +0,0 @@
    -:orphan:
    -
    -#####################
    -Distributed Front-End
    -#####################
    
  • docs/source-app/glossary/distributed_hardware.rst+0 5 removed
    @@ -1,5 +0,0 @@
    -:orphan:
    -
    -####################
    -Distributed Hardware
    -####################
    
  • docs/source-app/glossary/environment_variables.rst+0 27 removed
    @@ -1,27 +0,0 @@
    -.. _environment_variables:
    -
    -*********************
    -Environment Variables
    -*********************
    -
    -If your App is using configuration values you don't want to commit with your App source code, you can use environment variables.
    -
    -Lightning allows you to set environment variables when running the App from the CLI with the `lightning_app run app` command. You can use environment variables to pass any values to the App, and avoiding sticking those values in the source code.
    -
    -Set one or multiple variables using the **--env** option:
    -
    -.. code:: bash
    -
    -    lightning_app run app app.py --cloud --env FOO=BAR --env BAZ=FAZ
    -
    -Environment variables are available in all Flows and Works, and can be accessed as follows:
    -
    -.. code:: python
    -
    -    import os
    -
    -    print(os.environ["FOO"])  # BAR
    -    print(os.environ["BAZ"])  # FAZ
    -
    -.. note::
    -    Environment variables are not encrypted. For sensitive values, we recommend using :ref:`Encrypted Secrets <secrets>`.
    
  • docs/source-app/glossary/event_loop.rst+0 11 removed
    @@ -1,11 +0,0 @@
    -##########
    -Event loop
    -##########
    -
    -Drawing inspiration from modern web frameworks like `React.js <https://reactjs.org/>`_, the Lightning App runs all flows in an **event loop** (forever), which is triggered several times a second after collecting any works' state change.
    -
    -.. figure::  https://pl-public-data.s3.amazonaws.com/assets_lightning/lightning_loop.gif
    -
    -When running a Lightning App in the cloud, the ``LightningWork`` run on different machines. LightningWork communicates any state changes to the **event loop** which re-executes the flow with the newly-collected works' state.
    -
    -.. _app_event_loop:
    
  • docs/source-app/glossary/fault_tolerance.rst+0 7 removed
    @@ -1,7 +0,0 @@
    -:orphan:
    -
    -###############
    -Fault tolerance
    -###############
    -
    -.. note:: documentation under construction
    
  • docs/source-app/glossary/index.rst+0 155 removed
    @@ -1,155 +0,0 @@
    -.. toctree::
    -   :maxdepth: 1
    -   :hidden:
    -
    -   ios_and_android
    -   app_tree
    -   build_config/build_config
    -   command_lines/command_lines
    -   dag
    -   event_loop
    -   environment_variables
    -   secrets
    -   front ends <../workflows/add_web_ui/glossary_front_end>
    -   Lightning app <../core_api/lightning_app/index>
    -   sharing_components
    -   scheduling
    -   storage/storage
    -   restful_api/restful_api
    -   add web ui <../workflows/add_web_ui/glossary_ui>
    -   use_local_lightning
    -
    -########
    -Glossary
    -########
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: Android Lightning App
    -   :description: Use Lightning with android apps.
    -   :col_css: col-md-12
    -   :button_link: ios_and_android.html
    -   :height: 100
    -
    -.. displayitem::
    -   :header: App Components Tree
    -   :description: Learn how components can be nested to form component trees where the LightningFlows are its branches and LightningWorks are its leaves.
    -   :col_css: col-md-12
    -   :button_link: app_tree.html
    -   :height: 100
    -
    -.. displayitem::
    -   :header: Build Configuration
    -   :description: Prepare your requirements, add custom build commands or use docker image
    -   :col_css: col-md-12
    -   :button_link: build_config/build_config.html
    -   :height: 100
    -
    -.. displayitem::
    -   :header: Command Line Interface (CLI)
    -   :description: Learn about the Lightning CLI
    -   :col_css: col-md-12
    -   :button_link: command_lines/command_lines.html
    -   :height: 100
    -
    -.. displayitem::
    -   :header: DAG
    -   :description: Learn about directed acyclic graph, their properties and usage
    -   :col_css: col-md-12
    -   :button_link: dag.html
    -   :height: 100
    -
    -.. displayitem::
    -   :header: Event Loop
    -   :description: Learn how the Infinite Event Loop enables high distributed reactivity by triggering after collecting state changes.
    -   :col_css: col-md-12
    -   :button_link: event_loop.html
    -   :height: 100
    -
    -.. displayitem::
    -   :header: Environment Variables
    -   :description: Add secrets such as API keys or access tokens
    -   :col_css: col-md-12
    -   :button_link: environment_variables.html
    -   :height: 100
    -
    -.. displayitem::
    -   :header: Encrypted Secrets
    -   :description: Learn how to add passwords to your Lightning apps
    -   :col_css: col-md-12
    -   :button_link: secrets.html
    -   :height: 100
    -
    -.. displayitem::
    -   :header: Frontend
    -   :description: Customize your App View with any framework you want
    -   :col_css: col-md-12
    -   :button_link: ../workflows/add_web_ui/glossary_front_end.html
    -   :height: 100
    -
    -.. displayitem::
    -   :header: iOS Lightning App
    -   :description: Use Lightning with iOS apps.
    -   :col_css: col-md-12
    -   :button_link: ios_and_android.html
    -   :height: 100
    -
    -.. displayitem::
    -   :header: Lightning App
    -   :description: A Lightning app is a collection of connected components that form a workflow
    -   :col_css: col-md-12
    -   :button_link: ../core_api/lightning_app/index.html
    -   :height: 100
    -
    -.. displayitem::
    -   :header: Mounts
    -   :description: Mount Cloud Data
    -   :col_css: col-md-12
    -   :button_link: mount.html
    -   :height: 100
    -
    -.. displayitem::
    -   :header: Sharing Components
    -   :description: Let's create an ecosystem altogether
    -   :col_css: col-md-12
    -   :button_link: sharing_components.html
    -   :height: 100
    -
    -.. displayitem::
    -   :header: Scheduling
    -   :description: Orchestrate execution at specific times
    -   :col_css: col-md-12
    -   :button_link: scheduling.html
    -   :height: 100
    -
    -.. displayitem::
    -   :header: Storage
    -   :description: Easily share files even across multiple machines
    -   :col_css: col-md-12
    -   :button_link: storage/storage.html
    -   :height: 100
    -
    -.. displayitem::
    -   :header: REST API
    -   :description: Learn how to set up a RESTful API endpoint
    -   :col_css: col-md-12
    -   :button_link: restful_api/restful_api.html
    -   :height: 100
    -
    -.. displayitem::
    -   :header: UI
    -   :description: Combine multiple frameworks to create your own UI
    -   :col_css: col-md-12
    -   :button_link: ../workflows/add_web_ui/glossary_ui.html
    -   :height: 100
    -
    -.. displayitem::
    -   :header: Using a development branch of Lightning on the Cloud
    -   :description: Learn how to contribute to the Lightning framework in the cloud
    -   :col_css: col-md-12
    -   :button_link: use_local_lightning.html
    -   :height: 100
    
  • docs/source-app/glossary/ios_and_android.rst+0 26 removed
    @@ -1,26 +0,0 @@
    -
    -###############################################
    -Apple and Android mobile devices with Lightning
    -###############################################
    -
    -Audience: Users who want to develop Lightning Apps for Apple or Android mobile devices.
    -
    -----
    -
    -***********************************************************
    -Develop a Lightning App for Apple or Android mobile devices
    -***********************************************************
    -
    -There are a couple of ways you can go about building Lightning Apps that work on Apple or Android mobile devices.
    -
    -Option 1
    -^^^^^^^^
    -
    -You can develop a Lightning App that interacts with an iOS or Android app.
    -The ML and backend services live on the Lightning App, but the iOS or Android code (obj-c/swift or android) lives on the mobile devices.
    -
    -Option 2
    -^^^^^^^^
    -
    -You can build a mobile-first React Lightning App that works on both Apple and Android mobile devices.
    -The `InVideo app <https://lightning.ai/app/7pmQNIDxAE-InVideo%20Search>`_ is a good example of a Lightning App that does just that.
    
  • docs/source-app/glossary/lightning_app_overview/index.rst+0 11 removed
    @@ -1,11 +0,0 @@
    -:orphan:
    -
    -###########################
    -Lightning Apps Key concepts
    -###########################
    -
    -**Audience:** Users who want to know how the 🤯 magic works under the hood.
    -
    -----
    -
    -.. note:: This page is under construction
    
  • docs/source-app/glossary/mount.rst+0 1 removed
    @@ -1 +0,0 @@
    -.. include:: ../workflows/mount_cloud_object_store.rst
    
  • docs/source-app/glossary/restful_api/restful_api.rst+0 53 removed
    @@ -1,53 +0,0 @@
    -:orphan:
    -
    -###########
    -RESTful API
    -###########
    -
    -**Audience:** Users looking to create an API in their App to allow users to activate functionalities from external sources.
    -
    -----
    -
    -**********************
    -What is a RESTful API?
    -**********************
    -
    -A RESTful API is a set of external URL routes exposed by a server that enables clients to trigger some functionalities, such as getting or putting some data, uploading files, etc..
    -
    -This provides great flexibility for users as they can easily discover functionalities made available by the App Builders.
    -
    -The Lightning App framework supports the four primary HTTP methods: `GET`, `POST`, `PUT`, `DELETE`.
    -
    -These methods are guidelines to organize your RESTful Services and help users understand your functionalities.
    -
    -* **`GET`:** Reads data from the server.
    -* **`POST`:** Creates new resources.
    -* **`PUT`:** Updates/replaces existing resources.
    -* **`DELETE`:** Deletes resources.
    -
    -Learn more about `HTTP Methods for RESTful Services here <https://www.restapitutorial.com/introduction/whatisrest>`_.
    -
    -The Lightning App framework uses the popular `FastAPI <https://fastapi.tiangolo.com/>`_ and `Pydantic <https://pydantic-docs.helpmanual.io/>`_ frameworks under the hood. This means you can use all their features while building your App.
    -
    -----
    -
    -**********
    -Learn more
    -**********
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: Develop a RESTful API
    -   :description: Learn how to develop an API for your App.
    -   :col_css: col-md-6
    -   :button_link: ../../workflows/build_rest_api/index_content.html
    -   :height: 150
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/glossary/scheduling.rst+0 185 removed
    @@ -1,185 +0,0 @@
    -:orphan:
    -
    -##########
    -Scheduling
    -##########
    -
    -The Lightning Scheduling system makes it easy to schedule your components execution with any arbitrary conditions.
    -
    -
    -----
    -
    -************************
    -Schedule your components
    -************************
    -
    -The LightningFlow has a ``schedule`` method which can be used to schedule your components.
    -
    -.. code-block:: python
    -
    -    from lightning.app import LightningWork, LightningFlow
    -    from lightning.app.storage import Path
    -
    -
    -    class MyFlow(LightningFlow):
    -
    -        def run(self):
    -            if self.schedule("hourly"):
    -                # run some code once every hour.
    -
    -            if self.schedule("daily"):
    -                # run some code once day.
    -
    -            if self.schedule("daily") and anything_else:
    -                # run some code once day if the anything else is also True.
    -
    -            if self.schedule("2 4 * * mon,fri"):
    -                # defined with cron syntax, run some code at 04:02 on every Monday and Friday.
    -
    -Learn more about the cron syntax `here <https://github.com/kiorky/croniter>`_
    -
    -----
    -
    -**************
    -Best Practices
    -**************
    -
    -In the example above, the line ``self.schedule("hourly")`` will return ``True`` for a **single** flow execution every hour. Mathematically, this is known as a dirac.
    -
    -1. Instantiate your component under the schedule method and run outside as follows:
    -
    -.. code-block:: python
    -
    -    from lightning.app import LightningFlow
    -    from lightning.app.structures import List
    -
    -    class ScheduledDAG(LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.list = List()
    -
    -        def run(self):
    -            if self.schedule("hourly"):
    -                # dynamically instantiate
    -                # don't forget to always attach
    -                # your components to the flow !!!
    -                self.list.append(MyDAGFlow(...))
    -
    -            # run all dags, but the completed ones
    -            # are cached and don't re-execute.
    -            for dag in self.list:
    -                dag.run()
    -
    -
    -2. Run a single work under the schedule with different arguments to have it re-run.
    -
    -.. code-block:: python
    -
    -    from lightning.app import LightningFlow
    -    from time import time
    -
    -    class ScheduledDAG(LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.data_processor = DataProcessorWork(...)
    -
    -        def run(self):
    -            ...
    -            if self.schedule("hourly"):
    -                self.data_processor.run(trigger_time=time())
    -
    -
    -3. Capture the event in the state and execute your sequential works outside.
    -
    -.. code-block:: python
    -
    -    from lightning.app import LightningFlow
    -    from time import time
    -
    -    class ScheduledDAG(LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.should_execute = False
    -            self.data_processor = DataProcessorWork(...)
    -            self.training_work = KerasTrainingWork(...)
    -
    -        def run(self):
    -            ...
    -            if self.schedule("hourly"):
    -                self.should_execute = True
    -
    -            # Runs in 10 min
    -            if self.should_execute:
    -                # Runs in 5 min
    -                self.data_processor.run(trigger_time=time())
    -                if self.data_processor.has_succeeded:
    -                    # Runs in 5 min
    -                    self.training_work.run(self.data_processor.data)
    -                if self.training_work.has_succeeded:
    -                    self.should_execute = False
    -
    -----
    -
    -***********
    -Limitations
    -***********
    -
    -As stated above, the schedule acts as a dirac and is **True** for a single flow execution.
    -Therefore, sequential works execution under the schedule won't work as they don't complete within a single flow execution.
    -
    -Here is an example of something which **WON'T** work:
    -
    -.. code-block:: python
    -
    -    from lightning.app import LightningFlow
    -    from time import time
    -
    -    class ScheduledDAG(LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.data_processor = DataProcessorWork(...)
    -            self.training_work = KerasTrainingWork(...)
    -
    -        def run(self):
    -            ...
    -            if self.schedule("hourly"):
    -                # This finishes 5 min later
    -                self.data_processor.run(trigger_time=time())
    -                if self.data_processor.has_succeeded:
    -                    # This will never be reached as the
    -                    # data processor will keep processing forever...
    -                    self.training_work.run(self.data_processor.data)
    -
    -----
    -
    -**************************
    -Frequently Asked Questions
    -**************************
    -
    -- **Q: Can I use multiple nested scheduler?** No, as they might cancel themselves out, but you can capture the event of one to trigger the next one.
    -
    -- **Q: Can I use any arbitrary logic to schedule?** Yes, this design enables absolute flexibility, but you need to be careful to avoid bad practices.
    -
    -----
    -
    -********
    -Examples
    -********
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: Build a DAG
    -   :description: Learn how to schedule a DAG execution
    -   :col_css: col-md-4
    -   :button_link: ../examples/dag/dag.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/glossary/secrets.rst+0 74 removed
    @@ -1,74 +0,0 @@
    -.. _secrets:
    -
    -#################
    -Encrypted Secrets
    -#################
    -
    -Encrypted Secrets allow you to pass private data to your apps, like API keys, access tokens, database passwords, or other credentials, in a secure way without exposing them in your code.
    -Secrets provide you with a secure way to store this data in a way that is accessible to Apps so that they can authenticate third-party services/solutions.
    -
    -.. tip::
    -    For non-sensitive configuration values, we recommend using :ref:`plain-text Environment Variables <environment_variables>`.
    -
    -************
    -Add a secret
    -************
    -
    -Add the secret to your profile on lightning.ai.
    -Log in to your lightning.ai account > **Profile** > **Secrets** tab > click the **+New** button.
    -Provide a name and value to your secret, for example, name could be "github_api_token".
    -
    -.. note::
    -    Secret names must start with a letter and can only contain letters, numbers, dashes, and periods. The Secret names must comply with `RFC1123 naming conventions <https://www.rfc-editor.org/rfc/rfc1123>`_. The Secret value has no restrictions.
    -
    -.. video:: https://pl-public-data.s3.amazonaws.com/assets_lightning//encrypted_secrets_login.mp4
    -    :poster: https://pl-public-data.s3.amazonaws.com/assets_lightning//encrypted_secrets_login.png
    -    :width: 600
    -    :class: background-video
    -    :autoplay:
    -    :loop:
    -    :muted:
    -
    -************
    -Use a secret
    -************
    -
    -1. Add an environment variable to your app to read the secret. For example, add an "api_token" environment variable:
    -
    -.. code:: python
    -
    -    import os
    -
    -    component.connect(api_token=os.environ["api_token"])
    -
    -2. Pass the secret to your app run with the following command:
    -
    -.. code:: bash
    -
    -    lightning_app run app app.py --cloud --secret <environment-variable>=<secret-name>
    -
    -In this example, the command would be:
    -
    -.. code:: bash
    -
    -    lightning_app run app app.py --cloud --secret api_token=github_api_token
    -
    -
    -The ``--secret`` option can be used for multiple Secrets, and alongside the ``--env`` option.
    -
    -Here's an example:
    -
    -.. code:: bash
    -
    -    lightning_app run app app.py --cloud --env FOO=bar --secret MY_APP_SECRET=my-secret --secret ANOTHER_SECRET=another-secret
    -
    -
    -----
    -
    -******************
    -How does this work
    -******************
    -
    -When a Lightning App (App) **runs in the cloud**, a Secret can be exposed to the App using environment variables.
    -The value of the Secret is encrypted in the Lightning.ai database, and is only decrypted and accessible to
    -LightningFlow (Flow) or LightningWork (Work) processes in the cloud (when you use the ``--cloud`` option running your App).
    
  • docs/source-app/glossary/sharing_components.rst+0 50 removed
    @@ -1,50 +0,0 @@
    -#####################
    -Sharing my components
    -#####################
    -
    -**Audience:** Users who want to know how to share component.
    -
    -**Level:** Basic
    -
    -----
    -
    -********************************************
    -Why should I consider sharing my components?
    -********************************************
    -
    -Lightning is community driven and its core objective is to make AI accessible to everyone.
    -
    -By creating components and sharing them with everyone else, the barrier to entry will go down.
    -
    -----
    -
    -************************************
    -How should I organize my components?
    -************************************
    -
    -By design, Lightning components are nested to form component trees where the ``LightningFlows`` are its branches and ``LightningWorks`` are its leaves.
    -
    -This design has two primary advantages:
    -
    -* This helps users organize and maintain their code with more ease.
    -* This also helps create an ecosystem with **reusable** components.
    -
    -
    -Now, imagine you have implemented a **KerasScriptRunner** component for training any `Keras <https://github.com/keras-team/keras>`_ model with `Tensorboard UI <https://github.com/tensorflow/tensorboard>`_ integrated.
    -
    -Here are the best practices steps before sharing the component:
    -
    -* **Testing**: Ensure your component is well tested by following the :doc:`../testing` guide.
    -* **Documented**: Ensure your component has a docstring and comes with some usage explications.
    -
    -.. Note:: As a Lightning user, it helps to implement your components thinking someone else is going to use them.
    -
    -----
    -
    -*****************************************
    -How should I proceed to share components?
    -*****************************************
    -
    -Once your component is ready, create a *PiPy* package with your own library and then it can be reused by anyone else.
    -
    -Here is a `Component Template <https://github.com/Lightning-AI/LAI-slack-messenger>`_ from `William Falcon <https://www.williamfalcon.com/>`_ to guide your component.
    
  • docs/source-app/glossary/storage/differences.rst+0 78 removed
    @@ -1,78 +0,0 @@
    -:orphan:
    -
    -##################################
    -Differences between Drive and Path
    -##################################
    -
    -**Audience:** Users who want to share files between components.
    -
    -
    -The Lightning Storage system makes it easy to share files between LightningWork so you can run your app both locally and in the cloud without changing the code.
    -
    -
    -Lightning storage provides two solutions :class:`~lightning.app.storage.drive.Drive` and :class:`~lightning.app.storage.path.Path` to deal with files locally and in the cloud likewise.
    -
    -
    -----
    -
    -*****************
    -What is a Drive ?
    -*****************
    -
    -The Drive object provides a central place for your components to share data.
    -
    -The drive acts as an isolate folder and any component can access it by knowing its name.
    -
    -Your components can put, list, get, delete files from and to the Drive (except LightningFlow's).
    -
    -----
    -
    -****************
    -What is a Path ?
    -****************
    -
    -The Path object is a reference to a specific file or directory from a LightningWork and can be used to transfer those files to another LightningWork (one way, from source to destination).
    -
    -A good mental representation of the Path Object usage is the `relay race <https://en.wikipedia.org/wiki/Relay_race>`_.
    -To make a transfer, the LightningWork Receiver asks (e.g when the path object is passed by the flow to the Receiver)
    -for a copy of the files (baton) owned by their LightningWork Producer (e.g the work that created the files).
    -
    -----
    -
    -*********************************
    -When should I use Drive vs Path ?
    -*********************************
    -
    -The Drive should be used when you want to easily share data between components but the Path enables to create cleaner shareable
    -component where you want to exposes some files to be transferred (like an HPO component sharing the best model weights) for anyone else to use.
    -
    -The Drive is more intuitive and easier to get on-boarded with, but in more advanced use cases, you might appreciate the Path Object
    -which makes uni-directional files transfer simpler.
    -
    -----
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: The Drive Object.
    -   :description: Put, List and Get Files From a Shared Drive Disk.
    -   :col_css: col-md-4
    -   :button_link: drive.html
    -   :height: 180
    -   :tag: Basic
    -
    -.. displayitem::
    -   :header: The Path Object.
    -   :description: Transfer Files From One Component to Another by Reference.
    -   :col_css: col-md-4
    -   :button_link: path.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/glossary/storage/drive_content_old.rst+0 199 removed
    @@ -1,199 +0,0 @@
    -:orphan:
    -
    -
    -************
    -About Drives
    -************
    -
    -Lightning Drive storage makes it easy to share files between LightningWorks so you can run your Lightning App both locally and in the cloud without changing the code.
    -
    -The Drive object provides a central place for your components to share data.
    -
    -The Drive acts as an isolate folder and any component can access it by knowing its name.
    -
    -Your components can put, list, get, and delete files from and to the Drive (except LightningFlows).
    -
    -----
    -
    -***********************
    -What Drive does for you
    -***********************
    -
    -Think of every instance of the Drive object acting like a Google Drive or like Dropbox.
    -
    -By sharing the Drive between components through the LightningFlow,
    -several components can have a shared place to read and write files from.
    -
    -----
    -
    -**************
    -Create a Drive
    -**************
    -
    -In order to create a Drive, you simply need to pass its name with the prefix ``lit://`` as follows:
    -
    -.. code-block:: python
    -
    -    from lightning.app.storage import Drive
    -
    -    # The identifier of this Drive is ``drive_1``
    -    # Note: You need to add Lightning protocol ``lit://`` as a prefix.
    -
    -    drive_1 = Drive("lit://drive_1")
    -
    -    # The identifier of this Drive is ``drive_2``
    -    drive_2 = Drive("lit://drive_2")
    -
    -Any components can create a drive object.
    -
    -.. code-block:: python
    -
    -    from lightning.app import LightningFlow, LightningWork
    -    from lightning.app.storage import Drive
    -
    -
    -    class Flow(LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.drive_1 = Drive("lit://drive_1")
    -
    -        def run(self):
    -            ...
    -
    -
    -    class Work(LightningWork):
    -        def __init__(self):
    -            super().__init__()
    -            self.drive_1 = Drive("lit://drive_1")
    -
    -        def run(self):
    -            ...
    -
    -----
    -
    -*****************************
    -Supported actions with Drives
    -*****************************
    -
    -A Drive supports put, list, get, and delete actions.
    -
    -.. code-block:: python
    -
    -    from lightning.app.storage import Drive
    -
    -    drive = Drive("lit://drive")
    -
    -    drive.list(".")  # Returns [] as empty
    -
    -    # Created file.
    -    with open("a.txt", "w") as f:
    -        f.write("Hello World !")
    -
    -    drive.put("a.txt")
    -
    -    drive.list(".")  # Returns ["a.txt"] as the file copied in the Drive during the put action.
    -
    -    drive.get("a.txt")  # Get the file into the current worker
    -
    -    drive.delete("a.txt")
    -
    -    drive.list(".")  # Returns [] as empty
    -
    -----
    -
    -**********************************
    -Component interactions with Drives
    -**********************************
    -
    -Here is an illustrated code example on how to create drives within works.
    -
    -.. figure::  https://pl-public-data.s3.amazonaws.com/assets_lightning/drive_2.png
    -
    -.. code-block:: python
    -
    -    from lightning.app import LightningFlow, LightningWork, LightningApp
    -    from lightning.app.storage import Drive
    -
    -
    -    class Work_A(LightningWork):
    -        def __init__(self):
    -            super().__init__()
    -            # The identifier of the Drive is ``drive_1``
    -            # Note: You need to add Lightning protocol ``lit://`` as a prefix.
    -            self.drive_1 = Drive("lit://drive_1")
    -
    -        def run(self):
    -            # 1. Create a file.
    -            with open("a.txt", "w") as f:
    -                f.write("Hello World !")
    -
    -            # 2. Put the file into the drive.
    -            self.drive_1.put("a.txt")
    -
    -
    -    class Work_B(LightningWork):
    -        def __init__(self):
    -            super().__init__()
    -
    -            # Note: Work B has access 2 drives.
    -
    -            # The identifier of this Drive is ``drive_1``
    -            self.drive_1 = Drive("lit://drive_1")
    -            # The identifier of this Drive is ``drive_2``
    -            self.drive_2 = Drive("lit://drive_2")
    -
    -        def run(self):
    -            # 1. Create a file.
    -            with open("b.txt", "w") as f:
    -                f.write("Hello World !")
    -
    -            # 2. Put the file into both drives.
    -            self.drive_1.put("b.txt")
    -            self.drive_2.put("b.txt")
    -
    -
    -    class Work_C(LightningWork):
    -        def __init__(self):
    -            super().__init__()
    -            self.drive_2 = Drive("lit://drive_2")
    -
    -        def run(self):
    -            # 1. Create a file.
    -            with open("c.txt", "w") as f:
    -                f.write("Hello World !")
    -
    -            # 2. Put the file into the drive.
    -            self.drive_2.put("c.txt")
    -
    -----
    -
    -*****************************
    -Transfer files with Drive
    -*****************************
    -
    -In the example below, the Drive is created by the flow and passed to its LightningWork's.
    -
    -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
    -
    -
    -----
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: Learn about the Path Object.
    -   :description: Transfer Files From One Component to Another by Reference.
    -   :col_css: col-md-4
    -   :button_link: path.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/glossary/storage/drive_content.rst+0 223 removed
    @@ -1,223 +0,0 @@
    -:orphan:
    -
    -**************************
    -What are Lightning Drives?
    -**************************
    -
    -Lightning Drives are shared app storage that allow you to share files between :doc:`LightningWork (Work) <../../core_api/lightning_work/index>` components, so that you distributed components can share files when running on the cloud. Using drives, you can run your Lightning App both locally and in the cloud without changing the code.
    -
    -The Drive object provides a central place for your components to share data.
    -
    -The Drive acts as an isolated folder and any component can access it by knowing its name.
    -
    -We currently support two types of Drives: Lightning-managed (``lit://``) and S3 (``s3://``).
    -
    -+-----------------------------------+-------------------------------------------------------------------------------------------------------------------------------+
    -| Lightning-managed (``lit://``)    | Allows read-write operations and are accessible through the Drive API from a Work.                                            |
    -|                                   |                                                                                                                               |
    -|                                   | They allow your components to put, list, get, and delete files from and to the Drive (except LightningFlows).                 |
    -+-----------------------------------+-------------------------------------------------------------------------------------------------------------------------------+
    -| S3 (``s3://``)                    | S3 is AWS S3 storage mounted at a filesystem mount point. S3 is read-only (for now) and its primary purpose is                |
    -|                                   | to give you a permanent location to access your training data.                                                                |
    -|                                   |                                                                                                                               |
    -|                                   | They allow your components to list and get files located on the Drive.                                                        |
    -+-----------------------------------+-------------------------------------------------------------------------------------------------------------------------------+
    -
    -----
    -
    -**********************
    -What Drives do for you
    -**********************
    -
    -Think of every instance of the Drive object acting like a Google Drive or like Dropbox.
    -
    -By sharing the Drive between components through the LightningFlow,
    -several components can have a shared place to read (S3 Drives) or read and write (Lightning-managed Drives) files from.
    -
    -S3 Drive Limitations
    -^^^^^^^^^^^^^^^^^^^^
    -
    -These limitations only apply to S3 Drives:
    -
    -* There is no top level “shareable” S3 drive object. Each S3 Drive is owned by a particular Work.  However, it’s possible to create a Drive with the same location across multiple Works.
    -
    -* S3 buckets cannot be mounted as Drives once a Work has been instantiated. The `Drive` object must be initialized passed to a Work at creation time.
    -
    -* Whenever a Drive is mounted to a Work, an indexing process will be done again for the provided S3 bucket. This may lead to performance issues with particularly large S3 buckets. For context, 1M files with 2-3 levels of nesting takes less than 1 second to index.
    -
    -----
    -
    -**************
    -Create a Drive
    -**************
    -
    -In order to create a Drive, you simply need to pass its name with the prefix ``lit://`` or ``s3://``.
    -
    -.. note:: We do not support mounting single objects for S3 buckets, so there must be a trailing `/` in the s3:// URL. For example: ``s3://foo/bar/``.
    -
    -.. code-block:: python
    -
    -    from lightning.app.storage import Drive
    -
    -    # The identifier of this Drive is ``drive_1``
    -    # Note: You need to add Lightning protocol ``lit://`` as a prefix.
    -
    -    drive_1 = Drive("lit://drive_1")
    -
    -    # The identifier of this Drive is ``drive_2``
    -    drive_2 = Drive("s3://drive_2/")
    -
    -Any component can create a drive object for ``lit://`` Drives.
    -
    -.. code-block:: python
    -
    -    from lightning.app import LightningFlow, LightningWork
    -    from lightning.app.storage import Drive
    -
    -
    -    class Flow(LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.drive_1 = Drive("lit://drive_1")
    -
    -        def run(self):
    -            ...
    -
    -
    -    class Work(LightningWork):
    -        def __init__(self):
    -            super().__init__()
    -            self.drive_1 = Drive("lit://drive_1")
    -
    -        def run(self):
    -            ...
    -
    -----
    -
    -*****************************
    -Supported actions with Drives
    -*****************************
    -
    -A Lightning-managed Drive supports put, list, get, and delete actions.
    -
    -An S3 Drive supports list and get actions (for now).
    -
    -.. code-block:: python
    -
    -    from lightning.app.storage import Drive
    -
    -    drive = Drive("lit://drive")
    -
    -    drive.list(".")  # Returns [] as empty
    -
    -    # Created file.
    -    with open("a.txt", "w") as f:
    -        f.write("Hello World !")
    -
    -    drive.put("a.txt")
    -
    -    drive.list(".")  # Returns ["a.txt"] as the file copied in the Drive during the put action.
    -
    -    drive.get("a.txt")  # Get the file into the current worker
    -
    -    drive.delete("a.txt")
    -
    -    drive.list(".")  # Returns [] as empty
    -
    -----
    -
    -**********************************
    -Component interactions with Drives
    -**********************************
    -
    -Here is an illustrated code example on how to create drives within Works.
    -
    -.. figure::  https://pl-public-data.s3.amazonaws.com/assets_lightning/drive_2.png
    -
    -.. code-block:: python
    -
    -    from lightning.app import LightningFlow, LightningWork, LightningApp
    -    from lightning.app.storage import Drive
    -
    -
    -    class Work_A(LightningWork):
    -        def __init__(self):
    -            super().__init__()
    -            # The identifier of the Drive is ``drive_1``
    -            # Note: You need to add Lightning protocol ``lit://`` as a prefix.
    -            self.drive_1 = Drive("lit://drive_1")
    -
    -        def run(self):
    -            # 1. Create a file.
    -            with open("a.txt", "w") as f:
    -                f.write("Hello World !")
    -
    -            # 2. Put the file into the drive.
    -            self.drive_1.put("a.txt")
    -
    -
    -    class Work_B(LightningWork):
    -        def __init__(self):
    -            super().__init__()
    -
    -            # Note: Work B has access 2 drives.
    -
    -            # The identifier of this Drive is ``drive_1``
    -            self.drive_1 = Drive("lit://drive_1")
    -            # The identifier of this Drive is ``drive_2``
    -            self.drive_2 = Drive("lit://drive_2")
    -
    -        def run(self):
    -            # 1. Create a file.
    -            with open("b.txt", "w") as f:
    -                f.write("Hello World !")
    -
    -            # 2. Put the file into both drives.
    -            self.drive_1.put("b.txt")
    -            self.drive_2.put("b.txt")
    -
    -
    -    class Work_C(LightningWork):
    -        def __init__(self):
    -            super().__init__()
    -            self.drive_2 = Drive("lit://drive_2")
    -
    -        def run(self):
    -            # 1. Create a file.
    -            with open("c.txt", "w") as f:
    -                f.write("Hello World !")
    -
    -            # 2. Put the file into the drive.
    -            self.drive_2.put("c.txt")
    -
    -----
    -
    -*************************
    -Transfer files with Drive
    -*************************
    -
    -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
    -
    -----
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: Learn about the Path Object.
    -   :description: Transfer Files From One Component to Another by Reference.
    -   :col_css: col-md-4
    -   :button_link: path.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/glossary/storage/drive.rst+0 13 removed
    @@ -1,13 +0,0 @@
    -:orphan:
    -
    -.. _drive_storage:
    -
    -#############
    -Drive Storage
    -#############
    -
    -**Audience:** Users who want to put, list, and get files from a shared disk space.
    -
    -----
    -
    -.. include:: ../../glossary/storage/drive_content_old.rst
    
  • docs/source-app/glossary/storage/path.rst+0 326 removed
    @@ -1,326 +0,0 @@
    -:orphan:
    -
    -############
    -Path Storage
    -############
    -
    -**Audience:** Users who want to share files between components.
    -
    -
    -The Lightning Storage system makes it easy to share files between LightningWork so you can run your app both locally and in the cloud without changing the code.
    -
    -----
    -
    -***********************
    -What is a Path Object ?
    -***********************
    -
    -The Path object is a reference to a specific file or directory from a LightningWork and can be used to transfer those files to another LightningWork (one way, from source to destination).
    -
    -A good mental representation of the Path Object usage is the `relay race <https://en.wikipedia.org/wiki/Relay_race>`_.
    -To make a transfer, the receiver asks (e.g when the path object is passed by the flow to the receiver)
    -for a copy of the files (baton) owned by their producer (e.g the LightningWork which created the files).
    -
    -.. figure::  https://pl-public-data.s3.amazonaws.com/assets_lightning/path2.png
    -
    -*******************************************
    -How does the Path Object works internally ?
    -*******************************************
    -
    -To understand the Path Object internal, let's first answer this question: How do you locate a specific file or folder within a distributed system made of multiple machines ?
    -
    -You need to know on which machine the file or folder is located (e.g the LightningWork name uniquely identify its own machine in the cloud) and
    -then you need the local path of the file or folder on that machine.
    -
    -In simple words, the Lightning Path augments :class:`pathlib.Path` object by tracking on which machine the file or folder is located.
    -
    -----
    -
    -**************************
    -When to use Path storage ?
    -**************************
    -
    -In the cloud, every :class:`~lightning.app.core.work.LightningWork` runs in a separate machine with its own filesystem.
    -This means files in one Work cannot be directly accessed in another like you would be able to when running the app locally.
    -But with Lightning Storage, this is easy: Simply declare which files need to be shared and Lightning will take care of the rest.
    -
    -.. video:: https://pl-public-data.s3.amazonaws.com/assets_lightning/path.mp4
    -    :width: 600
    -    :autoplay:
    -    :loop:
    -    :muted:
    -
    -
    -----
    -
    -
    -***********************************
    -Tell Lightning where your files are
    -***********************************
    -
    -Convert every filesystem path you want to share with other LightningWorks to by adding ``lit://`` in front of it.
    -
    -.. code-block:: python
    -
    -    from lightning.app import LightningWork
    -    from lightning.app.storage import Path
    -
    -
    -    class SourceWork(LightningWork):
    -        def __init__(self):
    -            super().__init__()
    -            self.checkpoint_dir = None
    -
    -        def run(self):
    -            # Normally you would do:
    -            # self.checkpoint_dir = "outputs/checkpoints"
    -            # os.makedirs("outputs/checkpoints")
    -            # ...
    -
    -            # In Lightning, do:
    -            self.checkpoint_dir = "lit://outputs/checkpoints"
    -            os.makedirs(self.checkpoint_dir)
    -            ...
    -
    -
    -Under the hood, we convert this string to a :class:`~lightning.app.storage.path.Path` object, which is a drop-in replacement for :class:`pathlib.Path` meaning it will work with :mod:`os`, :mod:`os.path` and :mod:`pathlib` filesystem operations out of the box!
    -
    -
    -----
    -
    -
    -****************************
    -Access files in another Work
    -****************************
    -
    -Accessing files from another LightningWork is as easy as handing the path over by reference.
    -For example, share a directory by passing it as an input to the run method of the destination work:
    -
    -.. code-block:: python
    -    :emphasize-lines: 12
    -
    -    from lightning.app import LightningFlow
    -
    -
    -    class Flow(LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.source = SourceWork()
    -            self.destination = DestinationWork()
    -
    -        def run(self):
    -            self.source.run()
    -            # Pass the Path reference from one work to another
    -            self.destination.run(self.source.checkpoint_dir)
    -
    -
    -When the destination Work starts, Lightning will automatically transfer the files to its filesystem (if they exist on the other end):
    -
    -.. code-block:: python
    -
    -    class DestinationWork(LightningWork):
    -        def run(self, checkpoint_dir):
    -            # The directory is now accessible inside this Work
    -            files = os.listdir(checkpoint_dir)
    -            ...
    -
    -
    -The automatic transfer only happens if the referenced files already exist in the originating LightningWork and it will overwrite any files that already exist locally.
    -In all other cases, you can trigger the transfer manually.
    -
    -
    -----
    -
    -
    -******************
    -Get files manually
    -******************
    -
    -If you need to access files at a specific time or transfer them multiple times, use ``.get()`` method:
    -
    -.. code-block:: python
    -
    -        def run(self, checkpoint_dir):
    -            ...
    -            # Make the directory available
    -            checkpoint_dir.get()
    -
    -            # If the path already exists locally, you can force overwriting it
    -            checkpoint_dir.get(overwrite=True)
    -
    -            files = os.listdir(checkpoint_dir)
    -            ...
    -
    -
    -Multiple calls to the ``.get()`` method will always result in file transfers, regardless of whether the files have changed or not.
    -If the path does not exist remotely, it will raise a ``FileNotFoundError``.
    -If you need to handle this case, the Path also offers a method to check if files exist remotely.
    -
    -----
    -
    -
    -********************************
    -Check if a file or folder exists
    -********************************
    -
    -You can check if a path exists locally or remotely in the source Work using the ``.exists_local()`` and ``.exists_remote()`` methods:
    -
    -.. code-block:: python
    -
    -        def run(self, checkpoint_dir):
    -            if checkpoint_dir.exists_remote():
    -                # Get the file only if it exists in the source Work
    -                checkpoint_dir.get()
    -
    -            # OR
    -
    -            if checkpoint_dir.exists_local():
    -                # Do something with the file if it exists locally
    -                files = os.listdir(checkpoint_dir)
    -
    -
    -----
    -
    -
    -*************
    -Persist files
    -*************
    -
    -If a LightningWork finishes or stops due to an interruption (e.g., due to insufficient credits), the filesystem and all files in it get deleted (unless running locally).
    -Lightning makes sure all Paths that are part of the state get stored and made accessible to the other Works that still need these files.
    -
    -.. code-block:: python
    -
    -    from lightning.app.storage import Path
    -
    -
    -    class Work(LightningWork):
    -        def __init__(self):
    -            super().__init__()
    -            # The files in this path will be saved as an artifact when the Work finishes
    -            self.checkpoint_dir = "lit://outputs/checkpoints"
    -
    -            # The files in this path WON'T be saved because it is not declared as a Lightning Path
    -            self.log_dir = "outputs/logs"
    -
    -
    -----
    -
    -
    -*********************************
    -Example: Share a model checkpoint
    -*********************************
    -
    -A common workflow in ML is to use a checkpoint created by another component.
    -First, define a component that saves a checkpoint:
    -
    -.. code:: python
    -    :emphasize-lines: 14-18
    -
    -    from lightning.app import LightningFlow, LightningWork
    -    from lightning.app.storage import Path
    -    import torch
    -    import os
    -
    -
    -    class ModelTraining(LightningWork):
    -        def __init__(self, *args, **kwargs):
    -            super().__init__(*args, **kwargs)
    -            self.checkpoint_dir = "lit://outputs/checkpoints"
    -
    -        def run(self):
    -            # create a directory
    -            os.makedirs(self.model_checkpoints_path, exist_ok=True)
    -            # make fake checkpoints
    -            checkpoint_1 = torch.tensor([0, 1, 2, 3, 4])
    -            checkpoint_2 = torch.tensor([0, 1, 2, 3, 4])
    -            torch.save(checkpoint_1, os.path.join(self.checkpoint_dir, "checkpoint_1.ckpt"))
    -            torch.save(checkpoint_2, os.path.join(self.checkpoint_dir, "checkpoint_2.ckpt"))
    -
    -
    -Next, define a component that needs the checkpoints:
    -
    -.. code:: python
    -    :emphasize-lines: 4, 7
    -
    -    class ModelDeploy(LightningWork):
    -        def __init__(self, *args, **kwargs):
    -            super().__init__()
    -
    -        def run(self, checkpoint_dir):
    -            ckpts = os.listdir(checkpoint_dir)
    -            checkpoint_1 = torch.load(ckpts[0])
    -            checkpoint_2 = torch.load(ckpts[1])
    -
    -Link both components via a parent component:
    -
    -.. code:: python
    -    :emphasize-lines: 7
    -
    -    class Flow(LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.train = ModelTraining()
    -
    -            # pass the checkpoint path
    -            self.deploy = ModelDeploy()
    -
    -        def run(self):
    -            self.train.run()
    -            self.deploy.run(checkpoint_dir=self.train.checkpoint_dir)
    -
    -
    -    app = L.LightningApp(Flow())
    -
    -
    -----
    -
    -**************************
    -Frequently Asked Questions
    -**************************
    -
    -- **Q: Can files in a LightningWork be accessed inside the LightningFlow too?**
    -
    -  No, LightningFlow is intentionally designed not to perform filesystem operations and computations and is intended to exclusively orchestrate Flow and Work.
    -
    -- **Q: Is it possible to reference any file using the Lightning lit:// path notation?**
    -
    -  Yes, but only files for which the app has write permissions can be copied from Work to Work (apps don't run with root privileges).
    -
    -- **Q: Can I access the Lightning Storage in my UI (StreamLit, Web, ...)?**
    -
    -  This is currently not supported but will be in the future.
    -
    -- **Q: Should I define my lit:// path in the __init__ or the run method?**
    -
    -  You can declare a Lightning path anywhere you'd like. However, the ``.get()`` and ``.exists_*()`` methods only work inside of the run method of a LightningWork.
    -
    -- **Q:How often does Lightning synchronize the files between my Work?**
    -
    -  Lightning does not synchronize the files between works. It only transfers the files once when the Work ``run`` method starts.
    -  But you can call ``Path.get()`` as many times as you wish to transfer the latest file into the current Work.
    -
    -- **Does Lightning provide me direct access to the shared cloud folder?**
    -
    -  No, and this is on purpose. This restriction forces developers to build modular components that can be shared and integrated
    -  into apps easily. This would be much harder to achieve if file paths in these components would reference a global shared storage.
    -
    -----
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: Learn about the Drive Object.
    -   :description: Put, List and Get Files From a Shared Drive Disk.
    -   :col_css: col-md-4
    -   :button_link: drive.html
    -   :height: 180
    -   :tag: Basic
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/glossary/storage/storage.rst+0 77 removed
    @@ -1,77 +0,0 @@
    -.. _storage:
    -
    -#######
    -Storage
    -#######
    -
    -**Audience:** Users who want to share files between components.
    -
    -
    -The Lightning Storage system makes it easy to share files between LightningWork so you can run your app both locally and in the cloud without changing the code.
    -
    -
    -Lightning storage provides two solutions :class:`~lightning.app.storage.drive.Drive` and :class:`~lightning.app.storage.path.Path` to deal with files locally and in the cloud likewise.
    -
    -
    -----
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: Learn about the differences between Drive vs Path.
    -   :description: Learn about their differences.
    -   :col_css: col-md-4
    -   :button_link: differences.html
    -   :height: 180
    -   :tag: Basic
    -
    -.. displayitem::
    -   :header: The Drive Object.
    -   :description: Put, List and Get Files From a Shared Drive Disk.
    -   :col_css: col-md-4
    -   :button_link: drive.html
    -   :height: 180
    -   :tag: Basic
    -
    -.. displayitem::
    -   :header: The Path Object.
    -   :description: Transfer Files From One Component to Another by Reference.
    -   :col_css: col-md-4
    -   :button_link: path.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    -
    -
    -----
    -
    -********
    -Examples
    -********
    -
    -
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: Build a File Server
    -   :description: Learn how to use Drive to upload / download files to your app.
    -   :col_css: col-md-4
    -   :button_link: ../../examples/file_server/file_server.html
    -   :height: 180
    -   :tag: Intermediate
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/glossary/use_local_lightning.rst+0 15 removed
    @@ -1,15 +0,0 @@
    -################################################################
    -How to run an app on the cloud with a local version of lightning
    -################################################################
    -
    -The lightning cloud uses the latest release by default. However, you might want to run your app with some local changes you've made to the lightning framework. To use your local version of lightning on the cloud, set the following environment variable:
    -
    -```bash
    -git clone https://github.com/Lightning-AI/lightning.git
    -cd lightning
    -pip install -e .
    -export PACKAGE_LIGHTNING=1  # <- this is the magic to use your version (not mainstream PyPI)!
    -lightning_app run app app.py --cloud
    -```
    -
    -By setting `PACKAGE_LIGHTNING=1`, lightning packages the lightning source code in your local directory in addition to your app source code and uploads them to the cloud.
    
  • docs/source-app/index.rst+0 153 removed
    @@ -1,153 +0,0 @@
    -.. lightning documentation master file, created by
    -   sphinx-quickstart on Sat Sep 19 16:37:02 2020.
    -   You can adapt this file completely to your liking, but it should at least
    -   contain the root `toctree` directive.
    -
    -#######################
    -Welcome to ⚡ Lightning
    -#######################
    -Build models, ML components and full stack AI apps ⚡ *Lightning fast*.
    -
    -**Featured examples of what you can do with Lightning:**
    -
    -|
    -
    -.. raw:: html
    -
    -   <div>
    -      <div class="row" style="display:flex; align-items: center; justify-content: center; gap: 10px">
    -
    -.. app_card::
    -   :title: Develop and Train
    -   :description: Train a model (32 GPUs)
    -   :width: 280
    -   :image: https://lightning-ai-docs.s3.amazonaws.com/develop_n_train_v1.jpg
    -   :target: levels/basic/real_lightning_component_implementations.html#ex-pytorch-lightning-trainer
    -   :preview: levels/basic/real_lightning_component_implementations.html#ex-pytorch-lightning-trainer
    -   :tags: Training
    -
    -.. app_card::
    -   :title: Serve and deploy
    -   :description: Develop a Model Server
    -   :width: 280
    -   :image: https://lightning-ai-docs.s3.amazonaws.com/serve_n_deploy_v1.jpg
    -   :target: examples/model_server_app/model_server_app.html
    -   :preview: examples/model_server_app/model_server_app.html
    -   :tags: Serving
    -
    -.. app_card::
    -   :title: Scale and build a product
    -   :description: Production-ready generative AI app
    -   :width: 280
    -   :app_id: HvUwbEG90E
    -   :image: https://lightning-ai-docs.s3.amazonaws.com/scale_n_build_v1.jpg
    -   :target: https://lightning.ai/app/HvUwbEG90E-Muse
    -   :tags: AI App
    -
    -.. raw:: html
    -
    -      </div>
    -   </div>
    -
    -----
    -
    -********************************
    -Build self-contained, components
    -********************************
    -Use Lightning, the hyper-minimalistic framework, to build machine learning components that can plug into existing ML workflows.
    -A Lightning component organizes arbitrary code to run on the cloud, manage its own infrastructure, cloud costs, networking, and more.
    -Focus on component logic and not engineering.
    -
    -Use components on their own, or compose them into full-stack AI apps with our next-generation Lightning orchestrator.
    -
    -.. raw:: html
    -
    -   <div style="display: flex; align-items: center; justify-content: center;">
    -      <img src="https://lightning-ai-docs.s3.amazonaws.com/intro_components.gif" style="max-width: 800px"></img>
    -   </div>
    -
    -|
    -
    -|
    -
    -**Run an example component on the cloud**:
    -
    -.. include:: ./levels/basic/hero_components.rst
    -
    -|
    -
    -Components run the same on the cloud and locally on your choice of hardware.
    -
    -.. lit_tabs::
    -   :code_files: landing_app_run.bash
    -   :highlights: 5
    -   :height: 150px
    -   :code_only: True
    -
    -Explore pre-built community components in `our gallery <https://lightning.ai/components>`_.
    -
    -|
    -
    -.. raw:: html
    -
    -    <div class="display-card-container" style="padding: 0 20px 0 20px">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: Get started
    -   :description: Learn to build Lightning components step-by-step.
    -   :col_css: col-md-12
    -   :button_link: levels/basic/index.html
    -   :height: 160
    -   :tag: 10 minutes
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    -
    -.. raw:: html
    -
    -   <div style="display:none">
    -
    -.. toctree::
    -   :maxdepth: 1
    -   :caption: Home
    -
    -   self
    -   Install <install/installation>
    -
    -.. toctree::
    -   :maxdepth: 1
    -   :caption: Get started in steps
    -
    -   Basic <levels/basic/index>
    -   Intermediate <levels/intermediate/index>
    -   Advanced <levels/advanced/index>
    -
    -.. toctree::
    -   :maxdepth: 1
    -   :caption: Core API Reference
    -
    -   LightningApp <core_api/lightning_app/index>
    -   LightningFlow <core_api/lightning_flow>
    -   LightningWork <core_api/lightning_work/index>
    -
    -.. toctree::
    -   :maxdepth: 1
    -   :caption: Addons API Reference
    -
    -   api_reference/components
    -   api_reference/frontend
    -   api_reference/runners
    -   api_reference/storage
    -
    -.. toctree::
    -   :maxdepth: 1
    -   :caption: More
    -
    -   Examples <examples/index>
    -   Glossary <glossary/index>
    -   How-to <workflows/index>
    
  • docs/source-app/install/installation.rst+0 29 removed
    @@ -1,29 +0,0 @@
    -
    -.. _install:
    -
    -
    -############
    -Installation
    -############
    -
    -**Prerequisites**: Use Python 3.8.x or later (3.8.x, 3.9.x, 3.10.x). We also recommend you install in a virtual environment (learn how).
    -
    -.. lit_tabs::
    -   :descriptions: Pip; Macs, Apple Silicon (M1/M2/M3); Windows
    -   :code_files: pip.bash; mac.bash; windows.bash
    -   :tab_rows: 4
    -   :height: 180px
    -
    -----
    -
    -************
    -Troubleshoot
    -************
    -If you encounter issues during installation join our community discord and share the output of the following command:
    -
    -.. code:: bash
    -
    -        pip list | grep lightning
    -
    -.. join_slack::
    -   :align: left
    
  • docs/source-app/install/install_beginner.rst+0 117 removed
    @@ -1,117 +0,0 @@
    -:orphan:
    -
    -.. _install_beginner:
    -
    -#############################
    -What is a virtual environment
    -#############################
    -A virtual environment keeps the packages you install isolated from the rest of your system.
    -This allows you to work on multiple projects that have different and potentially conflicting requirements, and it
    -keeps your system Python installation clean.
    -
    -.. raw:: html
    -
    -    <iframe width="560" height="315" src="https://www.youtube.com/embed/WHWsABk4Ejk" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
    -
    -----
    -
    -We will describe two choices here, pick one:
    -
    -
    -1. :ref:`Python virtualenv <python-virtualenv>`.
    -2. :ref:`Conda virtual environment <conda>`.
    -
    -----
    -
    -.. _python-virtualenv:
    -
    -********************
    -1. Python Virtualenv
    -********************
    -
    -First, make sure that you have Python 3.8+ installed on your system.
    -
    -.. code-block:: bash
    -
    -    python3 --version
    -
    -If you can't run the command above or it returns a version older than 3.8,
    -`install the latest version of Python <https://www.python.org/downloads/>`_.
    -After installing it, make sure you can run the above command without errors.
    -
    -----
    -
    -Creating a Virtual Environment
    -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    -
    -When starting with a new Python project, you typically want to create a new Python virtual environment.
    -Navigate to the location of your project and run the following command:
    -
    -.. code-block:: bash
    -
    -    python3 -m venv lightning
    -
    -The name of the environment here is *lightning* but you can choose any other name you like.
    -By running the above command, Python will create a new folder *lightning* in the current working directory.
    -
    -----
    -
    -Activating the Virtual Environment
    -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    -
    -Before you can install packages into the environment, you need to activate it:
    -
    -.. code-block:: bash
    -
    -    source lightning/bin/activate
    -
    -You need to do this step every time you want to work on your project / open the terminal.
    -With your virtual environment activated, you are now ready to
    -:doc:`install Lightning <installation>` and get started with Apps!
    -
    -----
    -
    -.. _conda:
    -
    -********
    -2. Conda
    -********
    -
    -To get started, you first need to download and install the `Miniconda package manager <https://docs.conda.io/en/latest/miniconda.html>`_.
    -To check that the installation was successful, open an new terminal and run:
    -
    -.. code:: bash
    -
    -    conda
    -
    -It should return a list of commands.
    -
    -----
    -
    -Creating a Conda Environment
    -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    -
    -When starting with a new Python project, you typically want to create a new Conda virtual environment.
    -Navigate to the location of your project and run the following command:
    -
    -.. code-block:: bash
    -
    -    conda create --yes --name lightning python=3.8
    -
    -The name of the environment here is *lightning* but you can choose any other name you like.
    -Note how we can also specify the Python version here.
    -
    -----
    -
    -Activating the Conda Environment
    -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    -
    -Before you can install packages into the environment, you need to activate it:
    -
    -.. code-block:: bash
    -
    -    conda activate lightning
    -
    -You need to do this step every time you want to work on your project / open the terminal.
    -With your virtual environment activated, you are now ready to
    -:doc:`install Lightning <installation>` and get started with Apps!
    
  • docs/source-app/install/mac.bash+0 5 removed
    @@ -1,5 +0,0 @@
    -# needed for M1/M2/M3
    -export GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1
    -export GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1
    -
    -pip install lightning
    
  • docs/source-app/install/pip.bash+0 1 removed
    @@ -1 +0,0 @@
    -pip install lightning
    
  • docs/source-app/install/windows.bash+0 4 removed
    @@ -1,4 +0,0 @@
    -# install pip
    -# install git
    -# setup an alias for Python: python=python3
    -# Add the root folder of Lightning to the Environment Variables to PATH
    
  • docs/source-app/intro.rst+0 88 removed
    @@ -1,88 +0,0 @@
    -:orphan:
    -
    -.. _what:
    -
    -###################
    -What is Lightning?
    -###################
    -
    -Lightning is a free, modular, distributed, and open-source framework for building
    -AI applications where the components you want to use interact together.
    -
    -Lightning apps can be built for **any AI use case**, ranging from AI research to
    -production-ready pipelines (and everything in between!).
    -
    -By abstracting the engineering boilerplate, Lightning allows researchers, data scientists, and software engineers to
    -build highly-scalable, production-ready AI apps using the tools and technologies of their choice,
    -regardless of their level of engineering expertise.
    -
    -.. figure:: https://pl-public-data.s3.amazonaws.com/assets_lightning/Lightning.gif
    -    :alt: What is Lightning gif.
    -    :width: 100 %
    -
    -----
    -
    -.. _why:
    -
    -***************
    -Why Lightning?
    -***************
    -
    -
    -Easy to learn
    -^^^^^^^^^^^^^
    -
    -Lightning was built for creating AI apps, not for dev-ops. It offers an intuitive, pythonic
    -and highly composable interface that allows you to focus on solving the problems that are important to you.
    -
    -----
    -
    -Quick to deliver
    -^^^^^^^^^^^^^^^^
    -
    -Lightning speeds the development process by offering testable templates you can build from,
    -accelerating the process of moving from idea to prototype and finally to market.
    -
    -----
    -
    -Easy to scale
    -^^^^^^^^^^^^^
    -
    -Lightning provides a mirrored experience locally and in the cloud. The `lightning.ai <https://lightning.ai>`_.
    -cloud platform abstracts the infrastructure, so you can run your apps at any scale.
    -
    -----
    -
    -Easy to collaborate
    -^^^^^^^^^^^^^^^^^^^
    -
    -Lightning was built for collaboration.
    -By following the best MLOps practices provided through our documentation and example use cases,
    -you can deploy state-of-the-art ML applications that are ready to be used by teams of all sizes.
    -
    -----
    -
    -*****************************
    -What's Novel With Lightning?
    -*****************************
    -
    -
    -Cloud Infra Made Simple and Pythonic
    -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    -
    -Lightning is for building reactive, scalable, cost effective, easy-to-maintain and reliable ML products in the cloud without worrying about infrastructure. Lightning provides several engineering novelties to enable this:
    -
    -#. **Reactivity**: Lightning allows you to run stateful components distributed across different machines, so you can design async, dynamic and reactive workflows in python, without having to define DAGs.
    -
    -#. **Scalable & Cost-Effective**: Lightning provides a granular and simple way to run components preemptively or on-demand and on any desired resource such as CPU or GPU. It also enables you to easily transfer artifacts from one machine to another.
    -
    -#. **Reliability**:
    -
    -    #. **Checkpointing**: Lightning apps can be paused and resumed from generated state and artifact-based checkpoints.
    -    #. **Resilience**: Lightning has a strong fault-tolerance foundation. Your application can be written and tested to be resilient for cloud hazards at the component level.
    -    #. **Testing Tools**: Lightning provides you with tools and best practices you can use to develop and test your application. All of our built-in templates have unit integration and end-to-end tests.
    -
    -#. **Easy to maintain**:
    -
    -    #. **Easy Debugging**: Lightning apps can be debugged locally and in the cloud with **breakpoints** in any components.
    -    #. **Non-Invasive**: Lightning is the glue that connects all parts of your workflow, but this is done in a non-invasive way by formalizing API contracts between components. In other words, your application can run someone else's code with little assumption.
    
  • docs/source-app/landing_app.py+0 12 removed
    @@ -1,12 +0,0 @@
    -# app.py
    -from lightning.app import LightningWork, LightningApp, CloudCompute
    -
    -
    -class YourComponent(LightningWork):
    -   def run(self):
    -      print('RUN ANY PYTHON CODE HERE')
    -
    -
    -# run on a cloud machine ("cpu", "gpu", ...)
    -component = YourComponent(cloud_compute=CloudCompute("cpu"))
    -app = LightningApp(component)
    
  • docs/source-app/landing_app_run.bash+0 5 removed
    @@ -1,5 +0,0 @@
    -# install lightning
    -pip install lightning
    -
    -# run the app on the --cloud (--setup installs deps automatically)
    -lightning_app run app app.py --setup --cloud
    
  • docs/source-app/levels/advanced/index.rst+0 94 removed
    @@ -1,94 +0,0 @@
    -.. _advanced_level:
    -
    -.. toctree::
    -   :maxdepth: 1
    -   :hidden:
    -
    -   start_dynamic_components
    -   level_16
    -   level_17
    -   level_18
    -   level_19
    -   level_20
    -
    -###############
    -Advanced skills
    -###############
    -Learn to build nested components with advanced functionality.
    -
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: Level 9: Start dynamic components
    -   :description: Learn to start works dynamically
    -   :button_link: start_dynamic_components.html
    -   :col_css: col-md-6
    -   :height: 150
    -   :tag: intermediate
    -
    -.. displayitem::
    -   :header: Level 10: Check component status
    -   :description: Learn to use work status to coordinate complex apps.
    -   :button_link: level_16.html
    -   :col_css: col-md-6
    -   :height: 150
    -   :tag: advanced
    -
    -.. displayitem::
    -   :header: Level: Nest flows
    -   :description: Learn to nest flows into other flows.
    -   :button_link: level_14.html
    -   :col_css: col-md-6
    -   :height: 150
    -   :tag: intermediate
    -
    -.. displayitem::
    -   :header: Level: Develop reactive apps.
    -   :description: Learn to develop reactive Lightning Apps. Lightning shines with reactive workflows.
    -   :button_link: level_14.html
    -   :col_css: col-md-6
    -   :height: 150
    -   :tag: intermediate
    -
    -.. displayitem::
    -   :header: Level: Enable CLI commands for your app
    -   :description: Speak to your app from a CLI over the network
    -   :button_link: level_17.html
    -   :col_css: col-md-6
    -   :height: 150
    -   :tag: advanced
    -
    -.. displayitem::
    -   :header: Level 11: Connect two components over the network
    -   :description: Connect two LightningWorks over the network.
    -   :button_link: level_14.html
    -   :col_css: col-md-6
    -   :height: 150
    -   :tag: intermediate
    -
    -.. displayitem::
    -   :header: Level 13: Rerun components
    -   :description: Learn to reuse components by passing different variables.
    -   :button_link: level_17.html
    -   :col_css: col-md-6
    -   :height: 150
    -   :tag: advanced
    -
    -.. displayitem::
    -   :header: Level 14: Handle Lightning App exceptions
    -   :description: Learn to handle Lightning App exceptions.
    -   :button_link: level_19.html
    -   :col_css: col-md-6
    -   :height: 150
    -   :tag: advanced
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/levels/advanced/level_16.rst+0 10 removed
    @@ -1,10 +0,0 @@
    -###########################
    -Level 16: Check Work status
    -###########################
    -**Audience:** Users who want to stop/start Lightning Work based on a status.
    -
    -**Prereqs:** Level 16+
    -
    -----
    -
    -.. include:: ../../core_api/lightning_work/status_content.rst
    
  • docs/source-app/levels/advanced/level_17.rst+0 10 removed
    @@ -1,10 +0,0 @@
    -##########################
    -Level 17: Rerun components
    -##########################
    -**Audience:** Users who want Work.run() to activate multiple times in an app.
    -
    -**Prereqs:** Level 16+ and read the :doc:`Event Loop guide <../../glossary/event_loop>`.
    -
    -----
    -
    -.. include:: ../../workflows/run_work_once_content.rst
    
  • docs/source-app/levels/advanced/level_18.rst+0 10 removed
    @@ -1,10 +0,0 @@
    -##############################################
    -Level 18: Share objects between LightningWorks
    -##############################################
    -**Audience:** Users moving DataFrames or outputs, between Lightning Works (usually data engineers).
    -
    -**Prereqs:** Level 16+ and know about the Pandas library and read the :doc:`Access app state guide <../../workflows/access_app_state>`.
    -
    -----
    -
    -.. include:: ../../core_api/lightning_work/payload_content.rst
    
  • docs/source-app/levels/advanced/level_19.rst+0 11 removed
    @@ -1,11 +0,0 @@
    -#########################################
    -Level 19: Handle Lightning App exceptions
    -#########################################
    -
    -**Audience:** Users who want to make Lightning Apps more robust to potential issues.
    -
    -**Prereqs:** Level 16+
    -
    -----
    -
    -.. include:: ../../core_api/lightning_work/handling_app_exception_content.rst
    
  • docs/source-app/levels/advanced/level_20.rst+0 11 removed
    @@ -1,11 +0,0 @@
    -#######################################
    -Level 20: Enable dynamic LightningWorks
    -#######################################
    -
    -**Audience:** Users who want to create/run/stop multiple LightningWorks not defined at app instantiation.
    -
    -**Prereqs:** Level 16+
    -
    -----
    -
    -.. include:: ../../core_api/lightning_app/dynamic_work_content.rst
    
  • docs/source-app/levels/advanced/start_dynamic_components.rst+0 38 removed
    @@ -1,38 +0,0 @@
    -###############################
    -Level: Start dynamic components
    -###############################
    -**Audience:** Users who want to run a Lightning Component in parallel (asynchronously).
    -
    -**Prereqs:** You must have finished the :doc:`Basic levels <../basic/index>`.
    -
    -----
    -
    -.. include:: ../../workflows/run_work_in_parallel_content.rst
    -
    -----
    -
    -**********************************************
    -Next steps: Share variables between components
    -**********************************************
    -Now that you know how to run components in parallel, we'll learn to share variables
    -across components to simplify complex workflows.
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: Level 6: Share variables between components
    -   :description: Learn to connect components
    -   :col_css: col-md-12
    -   :button_link: share_variables_between_lightning_components.html
    -   :height: 150
    -   :tag: 10 minutes
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/levels/basic/build_a_dag.rst+0 20 removed
    @@ -1,20 +0,0 @@
    -:orphan:
    -
    -###########################
    -Example: Deploy a model API
    -###########################
    -
    -**Prereqs:** You have an app already running locally.
    -
    -----
    -
    -****************************
    -What is the Lightning Cloud?
    -****************************
    -The Lightning Cloud is the platform that we've created to interface with the cloud providers. Today
    -the Lightning Cloud supports AWS.
    -
    -.. note:: Support for GCP and Azure is coming soon!
    -
    -To use the Lightning Cloud, you buy credits that are used to pay the cloud providers. If you want to run
    -on your own AWS credentials, please contact us (support@lightning.ai) so we can get your clusters set up for you.
    
  • docs/source-app/levels/basic/build_a_lightning_component.rst+0 154 removed
    @@ -1,154 +0,0 @@
    -##############################################
    -Level 1: Package code in a lightning component
    -##############################################
    -
    -**Prereqs:** You know *basic* Python.
    -
    -**Goal:** In this guide you'll learn to develop `a Lightning component <https://lightning.ai/components>`_.
    -
    -
    -*********************************
    -Why you need Lightning components
    -*********************************
    -A Lightning component is a self-contained, modular machine-learning component
    -that you can plug into your existing ML workflows. A Lightning component organizes arbitrary code so it can run on the cloud, manages
    -its own infrastructure, cloud costs, networking and more. Connect components using your current workflow management tools or
    -our :doc:`next-generation reactive orchestrator <../intermediate/index>`.
    -
    -Components run on the cloud or your laptop without code changes 🤯🤯.
    -
    -.. raw:: html
    -
    -   <div style="display: flex; align-items: center; justify-content: center;">
    -      <img src="https://lightning-ai-docs.s3.amazonaws.com/intro_components.gif" style="max-width: 800px"></img>
    -   </div>
    -
    -|
    -
    -Organizing your code into Lightning components offers these benefits:
    -
    -.. collapse:: Build systems not scripts
    -
    -   |
    -
    -   The Lightning structure forces best practices so you don't have to be an expert production engineer.
    -   Although it feels like you're writing a script, you are actually building a production-ready system.
    -
    -.. collapse:: Cost control
    -
    -   |
    -
    -   The component run-time has been optimized for cost management to support the largest machine-learning workloads.
    -   Lower your cloud bill with machines that shut down or spin up faster.
    -
    -.. collapse:: For beginners: Code like an expert
    -
    -   |
    -
    -   Lightning embeds the best practices of building production-ready full stack AI apps into your
    -   coding experience. You can write code like you normally do, and the Lightning structure
    -   ensures your code is implicitly production ready... even if you're just doing research.
    -
    -.. collapse:: For experts: Scale with full control
    -
    -   |
    -
    -   if you know what you are doing, Lightning gives you full control to manage your own
    -   scaling logic, fault-tolerance and even pre-provisioning, all from Python.
    -
    -.. collapse:: Integrate into your current workflow tools
    -
    -   |
    -
    -   Lightning components are self-contained pieces of functionality. Add them to your current workflow
    -   tools to quickly fill in gaps in your ML workflow such as monitoring drift, training LLMs and more.
    -   You can (optionally) use the Lightning App to integrate components into a cohesive workflow.
    -
    -.. collapse:: Packaged code
    -
    -   |
    -
    -   Lightning apps bundles components into an app that runs in any environment. The same code will run on your laptop,
    -   or any cloud or private clusters. You don't have to think about the cluster or know anything about the cloud.
    -
    -.. collapse:: Rapid iteration
    -
    -   |
    -
    -   Iterate through ideas in hours not months because you don't have to learn a million other concepts that the components
    -   handle for you such as kubernetes, cost management, auto-scaling and more.
    -
    -.. collapse:: Modularity
    -
    -   |
    -
    -   Components are modular and inter-operable by design. Leverage our vibrant community of components so you don't
    -   have to build each piece of the system yourself.
    -
    -----
    -
    -*****************
    -Install Lightning
    -*****************
    -First, install Lightning.
    -
    -.. lit_tabs::
    -   :descriptions: Pip; Macs, Apple Silicon (M1/M2/M3); Windows
    -   :code_files: /install/pip.bash; /install/mac.bash; /install/windows.bash
    -   :tab_rows: 4
    -   :height: 180px
    -
    -----
    -
    -**************************
    -Build your first component
    -**************************
    -A Lightning component organizes arbitrary code so it can run on the cloud, manages its own infrastructure, cloud costs, networking and more
    -
    -**Run one of these components!**
    -
    -.. include:: ./hero_components.rst
    -
    -----
    -
    -************
    -Key features
    -************
    -You now know enough to build a self-contained component that runs any Python code on the cloud that can be connected to form a
    -powerful Lightning app. Here are a few key features available to super-charge your work:
    -
    -.. lit_tabs::
    -   :titles: 15+ accelerators; Auto-stop idle machines; Auto-timeout submitted work; Use spot machines (~70% discount); Work with massive datasets; Mount cloud storage; Use a custom container
    -   :code_files: ./key_features/accelerators.py; ./key_features/idle_machine.py; ./key_features/auto_timeout.py; ./key_features/spot.py; ./key_features/massive_dataset.py; ./key_features/mount_data.py; ./key_features/custom_container.py;
    -   :highlights: 11;11;11;11;11;2,7,10, 11; 11
    -   :enable_run: true
    -   :tab_rows: 3
    -   :height: 430px
    -
    -----
    -
    -********************************************
    -Next: Explore real component implementations
    -********************************************
    -In this section we introduced components. Let's explore
    -real component implementations in-depth.
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: Level 2: Explore real component implementations
    -   :description: Go deep into real component implementations.
    -   :col_css: col-md-12
    -   :button_link: real_lightning_component_implementations.html
    -   :height: 150
    -   :tag: beginner
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/levels/basic/create_a_model_demo.rst+0 20 removed
    @@ -1,20 +0,0 @@
    -:orphan:
    -
    -############################
    -Example: Create a model demo
    -############################
    -
    -**Prereqs:** You have an app already running locally.
    -
    -----
    -
    -****************************
    -What is the Lightning Cloud?
    -****************************
    -The Lightning Cloud is the platform that we've created to interface with the cloud providers. Today
    -the Lightning Cloud supports AWS.
    -
    -.. note:: Support for GCP and Azure is coming soon!
    -
    -To use the Lightning Cloud, you buy credits that are used to pay the cloud providers. If you want to run
    -on your own AWS credentials, please contact us (support@lightning.ai) so we can get your clusters set up for you.
    
  • docs/source-app/levels/basic/deploy_ai_model_api.rst+0 20 removed
    @@ -1,20 +0,0 @@
    -:orphan:
    -
    -###########################
    -Example: Deploy a model API
    -###########################
    -
    -**Prereqs:** You have an app already running locally.
    -
    -----
    -
    -****************************
    -What is the Lightning Cloud?
    -****************************
    -The Lightning Cloud is the platform that we've created to interface with the cloud providers. Today
    -the Lightning Cloud supports AWS.
    -
    -.. note:: Support for GCP and Azure is coming soon!
    -
    -To use the Lightning Cloud, you buy credits that are used to pay the cloud providers. If you want to run
    -on your own AWS credentials, please contact us (support@lightning.ai) so we can get your clusters set up for you.
    
  • docs/source-app/levels/basic/hello_components/code_run_cloud.bash+0 1 removed
    @@ -1 +0,0 @@
    -lightning_app run app app.py --cloud
    
  • docs/source-app/levels/basic/hello_components/code_run_cloud_setup.bash+0 1 removed
    @@ -1 +0,0 @@
    -lightning_app run app app.py --setup --cloud
    
  • docs/source-app/levels/basic/hello_components/code_run_local.bash+0 1 removed
    @@ -1 +0,0 @@
    -lightning_app run app app.py
    
  • docs/source-app/levels/basic/hello_components/code_run_local_setup.bash+0 1 removed
    @@ -1 +0,0 @@
    -lightning_app run app app.py --setup
    
  • docs/source-app/levels/basic/hello_components/deploy_model.py+0 31 removed
    @@ -1,31 +0,0 @@
    -# !pip install torchvision
    -from lightning.app import LightningApp, CloudCompute
    -from lightning.app.components.serve import PythonServer, Image, Number
    -import base64, io, torchvision, torch
    -from PIL import Image as PILImage
    -
    -
    -class PyTorchServer(PythonServer):
    -    def setup(self):
    -        self._model = torchvision.models.resnet18(pretrained=True)
    -        self._device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
    -        self._model.to(self._device)
    -
    -    def predict(self, request):
    -        image = base64.b64decode(request.image.encode("utf-8"))
    -        image = PILImage.open(io.BytesIO(image))
    -        transforms = torchvision.transforms.Compose([
    -            torchvision.transforms.Resize(224),
    -            torchvision.transforms.ToTensor(),
    -            torchvision.transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
    -        ])
    -        image = transforms(image)
    -        image = image.to(self._device)
    -        prediction = self._model(image.unsqueeze(0))
    -        return {"prediction": prediction.argmax().item()}
    -
    -
    -component = PyTorchServer(
    -   input_type=Image, output_type=Number, cloud_compute=CloudCompute('gpu')
    -)
    -app = LightningApp(component)
    
  • docs/source-app/levels/basic/hello_components/hello_world_gpu.py+0 12 removed
    @@ -1,12 +0,0 @@
    -# app.py
    -from lightning.app import LightningWork, LightningApp, CloudCompute
    -
    -
    -class YourComponent(LightningWork):
    -   def run(self):
    -      print('RUN ANY PYTHON CODE HERE')
    -
    -# run on a cloud machine ("cpu", "gpu", ...)
    -compute = CloudCompute("gpu")
    -component = YourComponent(cloud_compute=compute)
    -app = LightningApp(component)
    
  • docs/source-app/levels/basic/hello_components/hello_world.py+0 12 removed
    @@ -1,12 +0,0 @@
    -# app.py
    -from lightning.app import LightningWork, LightningApp
    -
    -
    -class YourComponent(LightningWork):
    -   def run(self):
    -      print('RUN ANY PYTHON CODE HERE')
    -
    -
    -
    -component = YourComponent()
    -app = LightningApp(component)
    
  • docs/source-app/levels/basic/hello_components/multi_node.py+0 29 removed
    @@ -1,29 +0,0 @@
    -# !pip install torch
    -from lightning.app import LightningWork, LightningApp, CloudCompute
    -from lightning.app.components import MultiNode
    -
    -
    -class MultiNodeComponent(LightningWork):
    -    def run(
    -        self,
    -        main_address: str,
    -        main_port: int,
    -        node_rank: int,
    -        world_size: int,
    -    ):
    -        print(f"ADD YOUR DISTRIBUTED CODE: {main_address=} {main_port=} {node_rank=} {world_size=}")
    -        print("supports ANY ML library")
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -# gpu-multi-fast has 4 GPUs x 8 nodes = 32 GPUs
    -component = MultiNodeComponent(cloud_compute=CloudCompute("gpu-multi-fast"))
    -component = MultiNode(component, nodes=8)
    -app = LightningApp(component)
    
  • docs/source-app/levels/basic/hello_components/pl_multinode.py+0 20 removed
    @@ -1,20 +0,0 @@
    -# app.py
    -from lightning import Trainer
    -from lightning.app import LightningWork, LightningApp, CloudCompute
    -from lightning.app.components import LightningTrainerMultiNode
    -from lightning.pytorch.demos.boring_classes import BoringModel
    -
    -
    -class LightningTrainerDistributed(LightningWork):
    -    def run(self):
    -        model = BoringModel()
    -        trainer = Trainer(max_epochs=10, strategy="ddp")
    -        trainer.fit(model)
    -
    -# 8 GPUs: (2 nodes of 4 x v100)
    -component = LightningTrainerMultiNode(
    -    LightningTrainerDistributed,
    -    num_nodes=4,
    -    cloud_compute=CloudCompute("gpu-fast-multi"), # 4 x v100
    -)
    -app = LightningApp(component)
    
  • docs/source-app/levels/basic/hello_components/pt_multinode.py+0 60 removed
    @@ -1,60 +0,0 @@
    -# app.py
    -# ! pip install torch
    -from lightning.app import LightningWork, LightningApp, CloudCompute
    -from lightning.app.components import MultiNode
    -import torch
    -from torch.nn.parallel.distributed import DistributedDataParallel
    -
    -
    -def distributed_train(local_rank: int, main_address: str, main_port: int, num_nodes: int, node_rank: int, nprocs: int):
    -    # 1. SET UP DISTRIBUTED ENVIRONMENT
    -    global_rank = local_rank + node_rank * nprocs
    -    world_size = num_nodes * nprocs
    -
    -    if torch.distributed.is_available() and not torch.distributed.is_initialized():
    -        torch.distributed.init_process_group(
    -            "nccl" if torch.cuda.is_available() else "gloo",
    -            rank=global_rank,
    -            world_size=world_size,
    -            init_method=f"tcp://{main_address}:{main_port}",
    -        )
    -
    -    # 2. PREPARE DISTRIBUTED MODEL
    -    model = torch.nn.Linear(32, 2)
    -    device = torch.device(f"cuda:{local_rank}") if torch.cuda.is_available() else torch.device("cpu")
    -    model = DistributedDataParallel(model, device_ids=[local_rank] if torch.cuda.is_available() else None).to(device)
    -
    -    # 3. SETUP LOSS AND OPTIMIZER
    -    criterion = torch.nn.MSELoss()
    -    optimizer = torch.optim.SGD(model.parameters(), lr=0.01)
    -
    -    # 4.TRAIN THE MODEL FOR 50 STEPS
    -    for step in range(50):
    -        model.zero_grad()
    -        x = torch.randn(64, 32).to(device)
    -        output = model(x)
    -        loss = criterion(output, torch.ones_like(output))
    -        print(f"global_rank: {global_rank} step: {step} loss: {loss}")
    -        loss.backward()
    -        optimizer.step()
    -
    -    # 5. VERIFY ALL COPIES OF THE MODEL HAVE THE SAME WEIGTHS AT END OF TRAINING
    -    weight = model.module.weight.clone()
    -    torch.distributed.all_reduce(weight)
    -    assert torch.equal(model.module.weight, weight / world_size)
    -
    -    print("Multi Node Distributed Training Done!")
    -
    -class PyTorchDistributed(LightningWork):
    -    def run(self, main_address: str, main_port: int, num_nodes: int, node_rank: int):
    -        nprocs = torch.cuda.device_count() if torch.cuda.is_available() else 1
    -        torch.multiprocessing.spawn(
    -            distributed_train,
    -            args=(main_address, main_port, num_nodes, node_rank, nprocs),
    -            nprocs=nprocs
    -        )
    -
    -# 32 GPUs: (8 nodes x 4 v 100)
    -compute = CloudCompute("gpu-fast-multi")  # 4xV100
    -component = MultiNode(PyTorchDistributed, num_nodes=8, cloud_compute=compute)
    -app = LightningApp(component)
    
  • docs/source-app/levels/basic/hello_components/run_ptl_script.py+0 13 removed
    @@ -1,13 +0,0 @@
    -# app.py
    -# !curl https://raw.githubusercontent.com/Lightning-AI/lightning/master/examples/app/multi_node/pl_boring_script.py -o pl_boring_script.py
    -from lightning.app import LightningApp, CloudCompute
    -from lightning.app.components.training import LightningTrainerScript
    -
    -# run script that trains PyTorch with the Lightning Trainer
    -model_script = 'pl_boring_script.py'
    -component = LightningTrainerScript(
    -   model_script,
    -   num_nodes=1,
    -   cloud_compute=CloudCompute("gpu")
    -)
    -app = LightningApp(component)
    
  • docs/source-app/levels/basic/hello_components/streamlit_demo.py+0 30 removed
    @@ -1,30 +0,0 @@
    -# app.py
    -# !pip install streamlit omegaconf scipy
    -# !pip install torch
    -from lightning.app import LightningApp
    -import torch
    -from io import BytesIO
    -from functools import partial
    -from scipy.io.wavfile import write
    -import streamlit as st
    -
    -
    -class StreamlitApp(app.components.ServeStreamlit):
    -    def build_model(self):
    -        sample_rate = 48000
    -        model, _ = torch.hub.load('snakers4/silero-models', model='silero_tts',speaker="v3_en")
    -        return partial(model.apply_tts, sample_rate=sample_rate, speaker="en_0"), sample_rate
    -
    -    def render(self):
    -        st.title("Text To Speech")
    -        text = st.text_input("Text:", "Lightning Apps are the best!")
    -
    -        if text:
    -            model, sample_rate = self.model
    -            audio_numpy = model(text).numpy()
    -            audio = BytesIO()
    -            write(audio, sample_rate, audio_numpy)
    -            audio.seek(0)
    -            st.audio(audio)
    -
    -app = LightningApp(StreamlitApp())
    
  • docs/source-app/levels/basic/hello_components/train_ptl.py+0 15 removed
    @@ -1,15 +0,0 @@
    -# A hello world component
    -# app.py
    -from lightning.app import LightningWork, LightningApp, CloudCompute
    -
    -
    -class YourComponent(LightningWork):
    -   def run(self):
    -      print('RUN ANY PYTHON CODE HERE')
    -
    -
    -
    -# run on a cloud machine
    -compute = CloudCompute("cpu")
    -worker = YourComponent(cloud_compute=compute)
    -app = LightningApp(worker)
    
  • docs/source-app/levels/basic/hello_components/train_pytorch.py+0 28 removed
    @@ -1,28 +0,0 @@
    -# app.py
    -# ! pip install torch
    -from lightning.app import LightningWork, LightningApp, CloudCompute
    -import torch
    -
    -class PyTorchComponent(LightningWork):
    -   def run(self):
    -      device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
    -      model = torch.nn.Sequential(torch.nn.Linear(1, 1),
    -                                 torch.nn.ReLU(),
    -                                 torch.nn.Linear(1, 1))
    -      model.to(device)
    -      criterion = torch.nn.MSELoss()
    -      optimizer = torch.optim.SGD(model.parameters(), lr=0.1)
    -
    -      for step in range(10000):
    -         model.zero_grad()
    -         x = torch.tensor([0.8]).to(device)
    -         target = torch.tensor([1.0]).to(device)
    -         output = model(x)
    -         loss = criterion(output, target)
    -         print(f'step: {step}.  loss {loss}')
    -         loss.backward()
    -         optimizer.step()
    -
    -compute = CloudCompute('gpu')
    -componet = PyTorchComponent(cloud_compute=compute)
    -app = LightningApp(componet)
    
  • docs/source-app/levels/basic/hello_components/xgboost_gpu.py+0 22 removed
    @@ -1,22 +0,0 @@
    -# app.py
    -# !pip install sklearn xgboost
    -# !conda install py-xgboost-gpu
    -from lightning.app import LightningWork, LightningApp, CloudCompute
    -from sklearn import datasets
    -from sklearn.model_selection import train_test_split
    -from xgboost import XGBClassifier
    -
    -class XGBoostComponent(LightningWork):
    -    def run(self):
    -        iris = datasets.load_iris()
    -        X, y = iris.data, iris.target
    -
    -        X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
    -
    -        bst = XGBClassifier(tree_method='gpu_hist', gpu_id=0, verbosity=3)
    -        bst.fit(X_train, y_train)
    -        preds = bst.predict(X_test)
    -        print(f'preds: {preds}')
    -
    -compute = CloudCompute('gpu')
    -app = LightningApp(XGBoostComponent(cloud_compute=compute))
    
  • docs/source-app/levels/basic/hello_components/xgboost.py+0 21 removed
    @@ -1,21 +0,0 @@
    -# app.py
    -# !pip install scikit-learn xgboost
    -from lightning.app import LightningWork, LightningApp
    -from sklearn import datasets
    -from sklearn.model_selection import train_test_split
    -from xgboost import XGBClassifier
    -
    -class XGBoostComponent(LightningWork):
    -    def run(self):
    -        iris = datasets.load_iris()
    -        X, y = iris.data, iris.target
    -
    -        X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
    -
    -        bst = XGBClassifier(verbosity=3)
    -        bst.fit(X_train, y_train)
    -        preds = bst.predict(X_test)
    -        print(f'preds: {preds}')
    -
    -
    -app = LightningApp(XGBoostComponent())
    
  • docs/source-app/levels/basic/hero_components.rst+0 8 removed
    @@ -1,8 +0,0 @@
    -.. lit_tabs::
    -   :titles: Hello world; Hello GPU world; PyTorch & ⚡⚡⚡ Trainer (1+ cloud GPUs); Train PyTorch (cloud GPU); Train PyTorch (32 cloud GPUs); Deploy a model on cloud GPUs; Run a model script;  XGBoost; Streamlit demo
    -   :code_files: /levels/basic/hello_components/hello_world.py; /levels/basic/hello_components/hello_world_gpu.py; /levels/basic/hello_components/pl_multinode.py; /levels/basic/hello_components/train_pytorch.py; /levels/basic/hello_components/pt_multinode.py; /levels/basic/hello_components/deploy_model.py; /levels/basic/hello_components/run_ptl_script.py; /levels/basic/hello_components/xgboost.py; /levels/basic/hello_components/streamlit_demo.py
    -   :highlights: 7; 10, 11; 9-11, 16, 17; 4, 8, 12, 18-19, 26; 5, 10, 22, 27, 31, 41, 57-59; 3, 11-12, 25, 29; 7, 10; 15, 21; 9, 15, 24
    -   :works: [{"name":"root.work","spec":{"buildSpec":{"commands":[],"pythonDependencies":{"packageManager":"PACKAGE_MANAGER_PIP","packages":""}},"drives":[],"userRequestedComputeConfig":{"count":1,"diskSize":0,"name":"default","preemptible":false,"shmSize":0},"networkConfig":[{"name":"dzodf","port":61304}]}}];[{"name":"root.work","spec":{"buildSpec":{"commands":[],"pythonDependencies":{"packageManager":"PACKAGE_MANAGER_PIP","packages":""}},"drives":[],"networkConfig":[{"name":"qnlgd","port":61516}],"userRequestedComputeConfig":{"count":1,"diskSize":0,"name":"gpu","preemptible":false,"shmSize":0}}}];[{"name":"root.ws.0","spec":{"buildSpec":{"commands":[],"pythonDependencies":{"packageManager":"PACKAGE_MANAGER_PIP","packages":""}},"drives":[],"networkConfig":[{"name":"ajfrc","port":61553}],"userRequestedComputeConfig":{"count":1,"diskSize":0,"name":"gpu-fast-multi","preemptible":false,"shmSize":0}}},{"name":"root.ws.1","spec":{"buildSpec":{"commands":[],"pythonDependencies":{"packageManager":"PACKAGE_MANAGER_PIP","packages":""}},"drives":[],"networkConfig":[{"name":"ttyqc","port":61554}],"userRequestedComputeConfig":{"count":1,"diskSize":0,"name":"gpu-fast-multi","preemptible":false,"shmSize":0}}},{"name":"root.ws.2","spec":{"buildSpec":{"commands":[],"pythonDependencies":{"packageManager":"PACKAGE_MANAGER_PIP","packages":""}},"drives":[],"networkConfig":[{"name":"svyej","port":61555}],"userRequestedComputeConfig":{"count":1,"diskSize":0,"name":"gpu-fast-multi","preemptible":false,"shmSize":0}}},{"name":"root.ws.3","spec":{"buildSpec":{"commands":[],"pythonDependencies":{"packageManager":"PACKAGE_MANAGER_PIP","packages":""}},"drives":[],"networkConfig":[{"name":"parme","port":61556}],"userRequestedComputeConfig":{"count":1,"diskSize":0,"name":"gpu-fast-multi","preemptible":false,"shmSize":0}}}];[{"name":"root.work","spec":{"buildSpec":{"commands":[],"pythonDependencies":{"packageManager":"PACKAGE_MANAGER_PIP","packages":""}},"drives":[],"networkConfig":[{"name":"cutdu","port":61584}],"userRequestedComputeConfig":{"count":1,"diskSize":0,"name":"gpu","preemptible":false,"shmSize":0}}}];[{"name":"root.ws.0","spec":{"buildSpec":{"commands":[],"pythonDependencies":{"packageManager":"PACKAGE_MANAGER_PIP","packages":""}},"drives":[],"networkConfig":[{"name":"whhby","port":61613}],"userRequestedComputeConfig":{"count":1,"diskSize":0,"name":"gpu-fast-multi","preemptible":false,"shmSize":0}}},{"name":"root.ws.1","spec":{"buildSpec":{"commands":[],"pythonDependencies":{"packageManager":"PACKAGE_MANAGER_PIP","packages":""}},"drives":[],"networkConfig":[{"name":"yhjtf","port":61614}],"userRequestedComputeConfig":{"count":1,"diskSize":0,"name":"gpu-fast-multi","preemptible":false,"shmSize":0}}},{"name":"root.ws.2","spec":{"buildSpec":{"commands":[],"pythonDependencies":{"packageManager":"PACKAGE_MANAGER_PIP","packages":""}},"drives":[],"networkConfig":[{"name":"rqwkt","port":61615}],"userRequestedComputeConfig":{"count":1,"diskSize":0,"name":"gpu-fast-multi","preemptible":false,"shmSize":0}}},{"name":"root.ws.3","spec":{"buildSpec":{"commands":[],"pythonDependencies":{"packageManager":"PACKAGE_MANAGER_PIP","packages":""}},"drives":[],"networkConfig":[{"name":"pjdsj","port":61616}],"userRequestedComputeConfig":{"count":1,"diskSize":0,"name":"gpu-fast-multi","preemptible":false,"shmSize":0}}},{"name":"root.ws.4","spec":{"buildSpec":{"commands":[],"pythonDependencies":{"packageManager":"PACKAGE_MANAGER_PIP","packages":""}},"drives":[],"networkConfig":[{"name":"efdor","port":61617}],"userRequestedComputeConfig":{"count":1,"diskSize":0,"name":"gpu-fast-multi","preemptible":false,"shmSize":0}}},{"name":"root.ws.5","spec":{"buildSpec":{"commands":[],"pythonDependencies":{"packageManager":"PACKAGE_MANAGER_PIP","packages":""}},"drives":[],"networkConfig":[{"name":"pxmso","port":61618}],"userRequestedComputeConfig":{"count":1,"diskSize":0,"name":"gpu-fast-multi","preemptible":false,"shmSize":0}}},{"name":"root.ws.6","spec":{"buildSpec":{"commands":[],"pythonDependencies":{"packageManager":"PACKAGE_MANAGER_PIP","packages":""}},"drives":[],"networkConfig":[{"name":"feevy","port":61619}],"userRequestedComputeConfig":{"count":1,"diskSize":0,"name":"gpu-fast-multi","preemptible":false,"shmSize":0}}},{"name":"root.ws.7","spec":{"buildSpec":{"commands":[],"pythonDependencies":{"packageManager":"PACKAGE_MANAGER_PIP","packages":""}},"drives":[],"networkConfig":[{"name":"tbmse","port":61620}],"userRequestedComputeConfig":{"count":1,"diskSize":0,"name":"gpu-fast-multi","preemptible":false,"shmSize":0}}}];[{"name":"root.work","spec":{"buildSpec":{"commands":[],"pythonDependencies":{"packageManager":"PACKAGE_MANAGER_PIP","packages":""}},"drives":[],"networkConfig":[{"name":"umqqg","port":7777}],"userRequestedComputeConfig":{"count":1,"diskSize":0,"name":"gpu","preemptible":false,"shmSize":0}}}];[];[{"name":"root.work","spec":{"buildSpec":{"commands":[],"pythonDependencies":{"packageManager":"PACKAGE_MANAGER_PIP","packages":""}},"drives":[],"networkConfig":[{"name":"tggba","port":61729}],"userRequestedComputeConfig":{"count":1,"diskSize":0,"name":"default","preemptible":false,"shmSize":0}}}];[{"name":"root.work","spec":{"buildSpec":{"commands":[],"pythonDependencies":{"packageManager":"PACKAGE_MANAGER_PIP","packages":""}},"drives":[],"networkConfig":[{"name":"hpyaz","port":61763}],"userRequestedComputeConfig":{"count":1,"diskSize":0,"name":"default","preemptible":false,"shmSize":0}}}]
    -   :enable_run: true
    -   :tab_rows: 3
    -   :height: 620px
    
  • docs/source-app/levels/basic/index.rst+0 54 removed
    @@ -1,54 +0,0 @@
    -.. _level_basic:
    -
    -.. toctree::
    -   :maxdepth: 1
    -   :hidden:
    -
    -   build_a_lightning_component
    -   real_lightning_component_implementations
    -   save_money_on_cloud_costs
    -
    -############
    -Basic skills
    -############
    -Learn to package your code into Lightning components which can plug into your existing ML workflows.
    -
    -A Lightning component organizes arbitrary code so it can run on the cloud, manages
    -its own infrastructure, cloud costs, networking and more.
    -
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: Level 1: Package code in a Lightning component
    -   :description: Learn to package your code into Lightning components which can plug into your existing ML workflows.
    -   :button_link: build_a_lightning_component.html
    -   :col_css: col-md-6
    -   :height: 170
    -   :tag: 10 minutes
    -
    -.. displayitem::
    -   :header: Level 2: Explore real component implementations
    -   :description: Go deep into real component implementations.
    -   :button_link: real_lightning_component_implementations.html
    -   :col_css: col-md-6
    -   :height: 170
    -   :tag: 10 minutes
    -
    -.. displayitem::
    -   :header: Level 3: Save money on cloud costs
    -   :description: Explore key Lightning features that save you cloud costs and improve performance.
    -   :button_link: save_money_on_cloud_costs.html
    -   :col_css: col-md-6
    -   :height: 150
    -   :tag: 10 minutes
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/levels/basic/key_features/accelerators.py+0 21 removed
    @@ -1,21 +0,0 @@
    -# app.py
    -from lightning.app import LightningWork, LightningApp, CloudCompute
    -
    -
    -class YourComponent(LightningWork):
    -   def run(self):
    -      print('RUN ANY PYTHON CODE HERE')
    -
    -
    -# custom accelerators
    -compute = CloudCompute('gpu')
    -component = YourComponent(cloud_compute=compute)
    -app = LightningApp(component)
    -
    -# OTHER ACCELERATORS:
    -# compute = CloudCompute('default')          # 1 CPU
    -# compute = CloudCompute('cpu-medium')       # 8 CPUs
    -# compute = CloudCompute('gpu')              # 1 T4 GPU
    -# compute = CloudCompute('gpu-fast-multi')   # 4 V100 GPU
    -# compute = CloudCompute('p4d.24xlarge')     # AWS instance name (8 A100 GPU)
    -# compute = ...
    
  • docs/source-app/levels/basic/key_features/auto_timeout.py+0 13 removed
    @@ -1,13 +0,0 @@
    -# app.py
    -from lightning.app import LightningWork, LightningApp, CloudCompute
    -
    -
    -class YourComponent(LightningWork):
    -   def run(self):
    -      print('RUN ANY PYTHON CODE HERE')
    -
    -
    -# if the machine hasn't started after 60 seconds, cancel the work
    -compute = CloudCompute('gpu', wait_timeout=60)
    -component = YourComponent(cloud_compute=compute)
    -app = LightningApp(component)
    
  • docs/source-app/levels/basic/key_features/custom_container.py+0 13 removed
    @@ -1,13 +0,0 @@
    -# app.py
    -from lightning.app import LightningWork, LightningApp
    -
    -
    -class YourComponent(LightningWork):
    -   def run(self):
    -      print('RUN ANY PYTHON CODE HERE')
    -
    -
    -# custom image (from any provider)
    -config= BuildConfig(image="gcr.io/google-samples/hello-app:1.0")
    -component = YourComponent(cloud_build_config=config)
    -app = LightningApp(component)
    
  • docs/source-app/levels/basic/key_features/idle_machine.py+0 13 removed
    @@ -1,13 +0,0 @@
    -# app.py
    -from lightning.app import LightningWork, LightningApp, CloudCompute
    -
    -
    -class YourComponent(LightningWork):
    -   def run(self):
    -      print('RUN ANY PYTHON CODE HERE')
    -
    -
    -# stop the machine when idle for 10 seconds
    -compute = CloudCompute('gpu', idle_timeout=10)
    -component = YourComponent(cloud_compute=compute)
    -app = LightningApp(component)
    
  • docs/source-app/levels/basic/key_features/massive_dataset.py+0 13 removed
    @@ -1,13 +0,0 @@
    -# app.py
    -from lightning.app import LightningWork, LightningApp, CloudCompute
    -
    -
    -class YourComponent(LightningWork):
    -   def run(self):
    -      print('RUN ANY PYTHON CODE HERE')
    -
    -
    -# use 100 GB of space on that machine (max size: 64 TB)
    -compute = CloudCompute('gpu', disk_size=100)
    -component = YourComponent(cloud_compute=compute)
    -app = LightningApp(component)
    
  • docs/source-app/levels/basic/key_features/mount_data.py+0 13 removed
    @@ -1,13 +0,0 @@
    -from lightning.app import LightningWork, LightningApp, CloudCompute
    -import os
    -
    -
    -class YourComponent(LightningWork):
    -   def run(self):
    -      os.listdir('/foo')
    -
    -# mount the files on the s3 bucket under this path
    -mount = Mount(source="s3://lightning-example-public/", mount_path="/foo")
    -compute = CloudCompute(mounts=mount)
    -component = YourComponent(cloud_compute=compute)
    -app = LightningApp(component)
    
  • docs/source-app/levels/basic/key_features/spot.py+0 13 removed
    @@ -1,13 +0,0 @@
    -# app.py
    -from lightning.app import LightningWork, LightningApp, CloudCompute
    -
    -
    -class YourComponent(LightningWork):
    -   def run(self):
    -      print('RUN ANY PYTHON CODE HERE')
    -
    -# spot machines can be turned off without notice, use for non-critical, resumable work
    -# request a spot machine, after 60 seconds of waiting switch to full-price
    -compute = CloudCompute('gpu', wait_timeout=60, spot=True)
    -component = YourComponent(cloud_compute=compute)
    -app = LightningApp(component)
    
  • docs/source-app/levels/basic/real_lightning_component_implementations.rst+0 75 removed
    @@ -1,75 +0,0 @@
    -###############################################
    -Level 2: Explore real component implementations
    -###############################################
    -**Audience:** Users who want to deeply understand what is possible with Lightning components.
    -
    -**Prereqs:** You must have finished :doc:`level 1 <../basic/build_a_lightning_component>`.
    -
    -----
    -
    -***********************
    -Real component examples
    -***********************
    -Use this guide to understand what is happening in each type of component.
    -These are a few prototypical components. Since each component organizes
    -Python, you can build virtually infinite components for any use-case
    -you can think of.
    -
    -----
    -
    -*******************************
    -Ex: PyTorch + Lightning Trainer
    -*******************************
    -This example shows how to train PyTorch with the Lightning trainer on your machine
    -or cloud GPUs without code changes.
    -
    -.. lit_tabs::
    -   :descriptions: import Lightning; We're using a demo LightningModule; Move your training code here (usually your main.py); Pass your component to the multi-node executor (it works on CPU or single GPUs also); Select the number of machines (nodes). Here we choose 4.; Choose from over 15+ machine types. This one has 4 v100 GPUs.; Initialize the App object that executes the component logic.
    -   :code_files: /levels/basic/hello_components/pl_multinode.py; /levels/basic/hello_components/pl_multinode.py; /levels/basic/hello_components/pl_multinode.py; /levels/basic/hello_components/pl_multinode.py;  /levels/basic/hello_components/pl_multinode.py; /levels/basic/hello_components/pl_multinode.py; /levels/basic/hello_components/pl_multinode.py;
    -   :highlights: 2; 4; 9-11; 14-17; 16; 17; 19
    -   :enable_run: true
    -   :tab_rows: 5
    -   :height: 420px
    -
    -----
    -
    -*********************************
    -Ex: Deploy a PyTorch API endpoint
    -*********************************
    -This example shows how to deploy PyTorch and create an API
    -
    -.. lit_tabs::
    -   :descriptions: Shortcut to list dependencies without a requirements.txt file.; Import one of our serving components (high-performance ones are available on the enterprise tiers); Define the setup function to load your favorite pretrained models and do any kind of pre-processing.; Define the predict function which is called when the endpoint is hit.; Initialize the server and define the type of cloud machine to use.
    -   :code_files: /levels/basic/hello_components/deploy_model.py; /levels/basic/hello_components/deploy_model.py; /levels/basic/hello_components/deploy_model.py; /levels/basic/hello_components/deploy_model.py; /levels/basic/hello_components/deploy_model.py;
    -   :highlights: 1; 3; 10-12; 15-25; 28-30
    -   :enable_run: true
    -   :tab_rows: 4
    -   :height: 620px
    -
    -----
    -
    -*************************
    -Next: Save on cloud costs
    -*************************
    -Let's review key lightning features to help you run components more efficiently on the cloud
    -so you can save on cloud costs.
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: Level 3: Save money on cloud costs
    -   :description: Explore key Lightning features that save you cloud costs and improve performance.
    -   :button_link: save_money_on_cloud_costs.html
    -   :col_css: col-md-12
    -   :height: 150
    -   :tag: 10 minutes
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/levels/basic/run_jupyter_notebook_on_the_cloud.rst+0 20 removed
    @@ -1,20 +0,0 @@
    -:orphan:
    -
    -#############################################
    -Example: Develop a Jupyter Notebook component
    -#############################################
    -
    -**Prereqs:** You have an app already running locally.
    -
    -----
    -
    -****************************
    -What is the Lightning Cloud?
    -****************************
    -The Lightning Cloud is the platform that we've created to interface with the cloud providers. Today
    -the Lightning Cloud supports AWS.
    -
    -.. note:: Support for GCP and Azure is coming soon!
    -
    -To use the Lightning Cloud, you buy credits that are used to pay the cloud providers. If you want to run
    -on your own AWS credentials, please contact us (support@lightning.ai) so we can get your clusters set up for you.
    
  • docs/source-app/levels/basic/save_money_on_cloud_costs.rst+0 51 removed
    @@ -1,51 +0,0 @@
    -##################################
    -Level 3: Save money on cloud costs
    -##################################
    -**Audience:** Users who want to use the AWS cloud efficiently.
    -
    -**Prereqs:** You must have finished :doc:`level 1 <../basic/build_a_lightning_component>`.
    -
    -----
    -
    -***********************************
    -Save money with these optimizations
    -***********************************
    -A Lightning component gives you fine-grain control over the cloud lifecycle of that component.
    -
    -Here are a few features that will enable you save a lot on your cloud costs:
    -
    -.. lit_tabs::
    -   :titles: 15+ accelerators; Auto-stop idle machines; Auto-timeout submitted work; Use spot machines (~70% discount); Work with massive datasets; Mount cloud storage; Use a custom container
    -   :code_files: ./key_features/accelerators.py; ./key_features/idle_machine.py; ./key_features/auto_timeout.py; ./key_features/spot.py; ./key_features/massive_dataset.py; ./key_features/mount_data.py; ./key_features/custom_container.py;
    -   :highlights: 11;11;11;11;11;1,7, 10, 11; 11
    -   :enable_run: true
    -   :tab_rows: 3
    -   :height: 430px
    -
    -----
    -
    -******************************
    -Next: Coordinate 2+ components
    -******************************
    -Now that you know how to organize arbitrary code inside a Lightning component,
    -learn to coordinate 2 or more components into workflows which we call Lightning apps.
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: Intermediate skills
    -   :description: Learn to coordinate 2+ components into workflows which we call Lightning apps.
    -   :button_link: ../intermediate/index.html
    -   :col_css: col-md-12
    -   :height: 170
    -   :tag: 15 minutes
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/levels/basic/scripts/toy_app_1_component_pdb.py+0 18 removed
    @@ -1,18 +0,0 @@
    -# app.py
    -from lightning.app import LightningWork, LightningFlow, LightningApp
    -from lightning.app.pdb import set_trace
    -
    -class Component(LightningWork):
    -    def run(self, x):
    -        print(x)
    -        set_trace()
    -
    -class WorkflowOrchestrator(LightningFlow):
    -    def __init__(self) -> None:
    -        super().__init__()
    -        self.component = Component()
    -
    -    def run(self):
    -        self.component.run('i love Lightning')
    -
    -app = LightningApp(WorkflowOrchestrator())
    
  • docs/source-app/levels/basic/scripts/toy_app_1_component.py+0 17 removed
    @@ -1,17 +0,0 @@
    -# app.py
    -from lightning.app import LightningWork, LightningFlow, LightningApp
    -
    -class Component(LightningWork):
    -    def run(self, x):
    -        print(x)
    -
    -
    -class WorkflowOrchestrator(LightningFlow):
    -    def __init__(self) -> None:
    -        super().__init__()
    -        self.component = Component()
    -
    -    def run(self):
    -        self.component.run('i love Lightning')
    -
    -app = LightningApp(WorkflowOrchestrator())
    
  • docs/source-app/levels/basic/train_pytorch_on_the_cloud.rst+0 20 removed
    @@ -1,20 +0,0 @@
    -:orphan:
    -
    -###################################
    -Example: Train PyTorch on the cloud
    -###################################
    -
    -**Prereqs:** You have an app already running locally.
    -
    -----
    -
    -****************************
    -What is the Lightning Cloud?
    -****************************
    -The Lightning Cloud is the platform that we've created to interface with the cloud providers. Today
    -the Lightning Cloud supports AWS.
    -
    -.. note:: Support for GCP and Azure is coming soon!
    -
    -To use the Lightning Cloud, you buy credits that are used to pay the cloud providers. If you want to run
    -on your own AWS credentials, please contact us (support@lightning.ai) so we can get your clusters set up for you.
    
  • docs/source-app/levels/expert/index.rst+0 82 removed
    @@ -1,82 +0,0 @@
    -:orphan:
    -
    -.. _expert_level:
    -
    -.. toctree::
    -   :maxdepth: 1
    -   :hidden:
    -
    -#############
    -Expert skills
    -#############
    -
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: Level : Use custom containers
    -   :description: Learn to use a custom cloud container.
    -   :button_link: build_a_machine_learning_workflow.html
    -   :col_css: col-md-6
    -   :height: 150
    -   :tag: basic
    -
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    -
    -----
    -
    -*********************
    -Intermediate Examples
    -*********************
    -As you work through the intermediate levels, try these examples:
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: Example: Develop a Github Repo Script Runner
    -   :description: Develop a workflow to execute Github Repos
    -   :button_link: ../../examples/github_repo_runner/github_repo_runner.html
    -   :col_css: col-md-6
    -   :height: 150
    -   :tag: basic
    -
    -.. displayitem::
    -   :header: Example: Develop a file server
    -   :description: Create a simple Lightning App (App) that allows users to upload files and list the uploaded files.
    -   :button_link: ../../examples/file_server/file_server.html
    -   :col_css: col-md-6
    -   :height: 150
    -   :tag: basic
    -
    -.. displayitem::
    -   :header: Example: Develop a Jupyter Notebook component
    -   :description: Develop a LightningWork that runs a notebook on the cloud.
    -   :button_link: run_jupyter_notebook_on_the_cloud.html
    -   :col_css: col-md-6
    -   :height: 150
    -   :tag: basic
    -
    -.. displayitem::
    -   :header: Example: Create a model demo
    -   :description: Demo POCs and MVPs which can be shared with a public web user interface.
    -   :button_link: create_a_model_demo.html
    -   :col_css: col-md-6
    -   :height: 150
    -   :tag: basic
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/levels/intermediate/connect_lightning_components.rst+0 116 removed
    @@ -1,116 +0,0 @@
    -####################################################
    -Level 4: Connect components into a full stack AI app
    -####################################################
    -
    -**Audience:** Users who want to build apps with multiple components.
    -
    -**Prereqs:** You know how to :doc:`build a component <../basic/build_a_lightning_component>`.
    -
    -----
    -
    -****************************
    -What is a full stack AI app?
    -****************************
    -In the ML world, workflows coordinate multiple pieces of code working together. In Lightning,
    -when we coordinate 2 or more :doc:`Lightning components <../basic/build_a_lightning_component>` working together,
    -we instead call it a Lightning App. The difference will become more obvious when we introduce reactive
    -workflows in the advanced section.
    -
    -For the time being, we'll go over how to coordinate 2 components together in a traditional workflow setting
    -and explain how it works.
    -
    -.. note:: If you've used workflow tools for Python, this page describes conventional DAGs.
    -        In :doc:`level 6 <run_lightning_work_in_parallel>`, we introduce reactive workflows that generalize beyond DAGs
    -        so you can build complex systems without much effort.
    -
    -----
    -
    -***********
    -The toy app
    -***********
    -
    -In this app, we define two components that run across 2 separate machines. One to train a model on a GPU machine and one to analyze the model
    -on a separate CPU machine. We save money by stopping the GPU machine when the work is done.
    -
    -.. lit_tabs::
    -   :titles: Import Lightning; Define Component 1;  Define Component 2; Orchestrator; Connect component 1; Connect component 2; Implement run; Train; Analyze; Define app placeholder
    -   :descriptions: First, import Lightning; This component trains a model on a GPU machine; This component analyzes a model on a CPU machine; Define the LightningFlow that orchestrates components; Component 1 will run on a CPU machine; Component 2 will run on an accelerated GPU machine; Describe the workflow in the run method; Training runs first and completes; Analyze runs after training completes; This allows the app to be runnable
    -   :code_files: ./level_2_scripts/hello_app.py; ./level_2_scripts/hello_app.py; ./level_2_scripts/hello_app.py; ./level_2_scripts/hello_app.py; ./level_2_scripts/hello_app.py; ./level_2_scripts/hello_app.py; ./level_2_scripts/hello_app.py; ./level_2_scripts/hello_app.py; ./level_2_scripts/hello_app.py; ./level_2_scripts/hello_app.py
    -   :highlights: 2; 5-7; 9-11; 13; 16; 17; 19; 20; 21; 23
    -   :enable_run: true
    -   :tab_rows: 4
    -   :height: 460px
    -
    -|
    -
    -Now run the app:
    -
    -.. lit_tabs::
    -   :titles: Run on Lightning cloud; Your own hardware
    -   :descriptions: Run to see these 2 components execute on separate machines 🤯; Run it locally without code changes 🤯🤯;
    -   :code_files: ./level_2_scripts/code_run_cloud.bash; ./level_2_scripts/code_run_local.bash
    -   :tab_rows: 7
    -   :height: 195px
    -
    -|
    -
    -Now you can develop distributed cloud apps on your laptop 🤯🤯🤯🤯!
    -
    -----
    -
    -*************
    -Now you know:
    -*************
    -
    -Without going out of your way, you're now doing the following: (Hint: Click **visualize** to see an animation describing the code).
    -
    -.. lit_tabs::
    -   :titles: Orchestration; Distributed cloud computing; Multi-machine communication; Multi-machine communication; Multi-cloud;
    -   :descriptions: Define orchestration in Python with full control-flow; The two pieces of independent Python code ran on separate machines 🤯🤯; The text "CPU machine 1" was sent from the flow machine to the machine running the TrainComponent;  The text "GPU machine 2" was sent from the flow machine to the machine running the AnalyzeComponent; The full Lightning app can move across clusters and clouds
    -   :code_files: ./level_2_scripts/hello_app.py; ./level_2_scripts/hello_app.py; ./level_2_scripts/hello_app.py; ./level_2_scripts/hello_app.py;
    -   :tab_rows: 4
    -   :highlights: 19-21; 16-17; 20; 21
    -   :images: <img src="https://pl-bolts-doc-images.s3.us-east-2.amazonaws.com/orchestration.gif" style="max-height: 430px; width: auto"></img> | <img src="https://pl-bolts-doc-images.s3.us-east-2.amazonaws.com/distributed_computing.gif" style="max-height: 430px; width: auto"></img> | <img src="https://pl-bolts-doc-images.s3.us-east-2.amazonaws.com/multi_machine_comms.gif" style="max-height: 430px; width: auto"></img> | <img src="https://pl-bolts-doc-images.s3.us-east-2.amazonaws.com/multi_machine_comms.gif" style="max-height: 430px; width: auto"></img> | <img src="https://pl-bolts-doc-images.s3.us-east-2.amazonaws.com/multi_cloud.gif" style="max-height: 430px; width: auto"></img>
    -   :height: 470px
    -
    -----
    -
    -*********************
    -Maintain full control
    -*********************
    -Although we've abstracted the infrastructure, you still have full control when you need it:
    -
    -.. lit_tabs::
    -   :titles: Scheduler; Crontab syntax; Auto-scaling; Organized Python; Full terraform control;
    -   :descriptions: Although you can use Python timers, we have a scheduler short-hand; You can also use full cron syntax; Code your own auto-scaling syntax (Lightning plays well with Kubernetes); *Remember* components organize ANY Python code which can even call external non-python scripts such as optimized C++ model servers ;Experts have the option to use terraform to configure Lightning clusters
    -   :code_files: ./level_2_scripts/hello_app_scheduler.py; ./level_2_scripts/hello_app_cron.py; ./level_2_scripts/hello_app_auto_scale.py; ./level_2_scripts/organized_app_python.py;
    -   :tab_rows: 4
    -   :highlights: 24; 24; 21, 24, 27, 28; 9, 16, 17
    -   :height: 700px
    -
    -----
    -
    -*************************
    -Next: Review how to debug
    -*************************
    -The next levels does a 2 minute review to make sure you know how to debug a Lightning app.
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: Level 5: Debug a Lightning App
    -   :description: Learn to debug a lightning app.
    -   :button_link: debug_a_lightning_app.html
    -   :col_css: col-md-12
    -   :height: 170
    -   :tag: 10 minutes
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/levels/intermediate/debug_a_lightning_app.rst+0 48 removed
    @@ -1,48 +0,0 @@
    -##############################
    -Level 5: Debug A Lightning app
    -##############################
    -**Audience:** Users who want to debug a distributed app locally.
    -
    -**Prereqs:** You must have finished the :doc:`Basic levels <../basic/index>`.
    -
    -----
    -
    -******************
    -Enable breakpoints
    -******************
    -To enable a breakpoint, use :func:`~lightning.app.pdb.set_trace()` (note direct python pdb support is work in progress and open to contributions).
    -
    -.. lit_tabs::
    -   :descriptions: Toy app; Add a breakpoint. When the program runs, it will stop at this line.
    -   :code_files: ./debug_app_scripts/toy_app_1_component.py; ./debug_app_scripts/toy_app_1_component_pdb.py
    -   :highlights: ; 7
    -   :enable_run: true
    -   :tab_rows: 3
    -   :height: 350px
    -
    -----
    -
    -*********************************
    -Next: Run a component in parallel
    -*********************************
    -Learn to run components in parallel to enable more powerful workflows.
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: Level 6: Run a Lightning component in parallel
    -   :description: Learn when and how to run Components in parallel (asynchronous).
    -   :button_link: run_lightning_work_in_parallel.html
    -   :col_css: col-md-12
    -   :height: 150
    -   :tag: 15 minutes
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/levels/intermediate/debug_app_scripts/debug_app.py+0 25 removed
    @@ -1,25 +0,0 @@
    -# app.py
    -from lightning.app import LightningWork, LightningFlow, LightningApp
    -from lightning.app.runners import MultiProcessRuntime
    -
    -
    -class TrainComponent(LightningWork):
    -    def run(self, x):
    -        print(f'train a model on {x}')
    -
    -class AnalyzeComponent(LightningWork):
    -    def run(self, x):
    -        print(f'analyze model on {x}')
    -
    -class WorkflowOrchestrator(LightningFlow):
    -    def __init__(self) -> None:
    -        super().__init__()
    -        self.train = TrainComponent()
    -        self.analyze = AnalyzeComponent()
    -
    -    def run(self):
    -        self.train.run("GPU machine 1")
    -        self.analyze.run("CPU machine 2")
    -
    -app = LightningApp(WorkflowOrchestrator())
    -MultiProcessRuntime(app).dispatch()
    
  • docs/source-app/levels/intermediate/debug_app_scripts/toy_app_1_component_pdb.py+0 18 removed
    @@ -1,18 +0,0 @@
    -# app.py
    -from lightning.app import LightningWork, LightningFlow, LightningApp
    -from lightning.app.pdb import set_trace
    -
    -class Component(LightningWork):
    -    def run(self, x):
    -        print(x)
    -        set_trace()
    -
    -class WorkflowOrchestrator(LightningFlow):
    -    def __init__(self) -> None:
    -        super().__init__()
    -        self.component = Component()
    -
    -    def run(self):
    -        self.component.run('i love Lightning')
    -
    -app = LightningApp(WorkflowOrchestrator())
    
  • docs/source-app/levels/intermediate/debug_app_scripts/toy_app_1_component.py+0 17 removed
    @@ -1,17 +0,0 @@
    -# app.py
    -from lightning.app import LightningWork, LightningFlow, LightningApp
    -
    -class Component(LightningWork):
    -    def run(self, x):
    -        print(x)
    -
    -
    -class WorkflowOrchestrator(LightningFlow):
    -    def __init__(self) -> None:
    -        super().__init__()
    -        self.component = Component()
    -
    -    def run(self):
    -        self.component.run('i love Lightning')
    -
    -app = LightningApp(WorkflowOrchestrator())
    
  • docs/source-app/levels/intermediate/debug_app_scripts/toy_app.py+0 24 removed
    @@ -1,24 +0,0 @@
    -# app.py
    -from lightning.app import LightningWork, LightningFlow, LightningApp
    -
    -
    -
    -class TrainComponent(LightningWork):
    -    def run(self, x):
    -        print(f'train a model on {x}')
    -
    -class AnalyzeComponent(LightningWork):
    -    def run(self, x):
    -        print(f'analyze model on {x}')
    -
    -class WorkflowOrchestrator(LightningFlow):
    -    def __init__(self) -> None:
    -        super().__init__()
    -        self.train = TrainComponent()
    -        self.analyze = AnalyzeComponent()
    -
    -    def run(self):
    -        self.train.run("CPU machine 1")
    -        self.analyze.run("CPU machine 2")
    -
    -app = LightningApp(WorkflowOrchestrator())
    
  • docs/source-app/levels/intermediate/embed_web_ui_into_lightningwork.rst+0 40 removed
    @@ -1,40 +0,0 @@
    -######################################
    -Level 9: Embed graphical UIs into work
    -######################################
    -**Audience:** Users who need to embed a Graphical UI in their Lightning Apps.
    -
    -**Prereqs:** You have finished :doc:`Level 8 <share_files_between_components>`.
    -
    -----
    -
    -.. include:: ../../workflows/add_web_ui/index_content.rst
    -
    -----
    -
    -*******************************************
    -Next steps: Practice adapting app templates
    -*******************************************
    -One of the most exciting powers of Lightning is the ability
    -to start an app from a template, replace or add components
    -and build a powerful system.
    -
    -----
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: Level 10: Practice adapting app templates
    -   :description: Practice starting apps from templates and evolving them by replacing or adding components.
    -   :button_link: start_from_lightning_app_templates.html
    -   :col_css: col-md-12
    -   :height: 150
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/levels/intermediate/index.rst+0 87 removed
    @@ -1,87 +0,0 @@
    -.. _intermediate_level:
    -
    -.. toctree::
    -   :maxdepth: 1
    -   :hidden:
    -
    -   connect_lightning_components
    -   debug_a_lightning_app
    -   run_lightning_work_in_parallel
    -   share_variables_between_lightning_components
    -   share_files_between_components
    -   embed_web_ui_into_lightningwork
    -   start_from_lightning_app_templates
    -
    -###################
    -Intermediate skills
    -###################
    -Learn to coordinate 2+ components into workflows which we call Lightning apps.
    -
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: Level 4: Coordinate 2+ components in a workflow
    -   :description: Learn to coordinate 2_ components in a workflow which we call a Lightning app.
    -   :button_link: connect_lightning_components.html
    -   :col_css: col-md-6
    -   :height: 170
    -   :tag: 15 minutes
    -
    -.. displayitem::
    -   :header: Level 5: Debug a Lightning App
    -   :description: Learn to debug a lightning app.
    -   :button_link: debug_a_lightning_app.html
    -   :col_css: col-md-6
    -   :height: 170
    -   :tag: 2 minutes
    -
    -.. displayitem::
    -   :header: Level 6: Run a Lightning component in parallel
    -   :description: Learn when and how to run Components in parallel (asynchronous).
    -   :button_link: run_lightning_work_in_parallel.html
    -   :col_css: col-md-6
    -   :height: 150
    -   :tag: 10 minutes
    -
    -.. displayitem::
    -   :header: Level 7: Share variables between components
    -   :description: Share variables between Lightning components.
    -   :button_link: share_variables_between_lightning_components.html
    -   :col_css: col-md-6
    -   :height: 150
    -   :tag: 15 minutes
    -
    -.. displayitem::
    -   :header: Level 8: Share files between components
    -   :description: Learn how Drives share files between components
    -   :button_link: share_files_between_components.html
    -   :col_css: col-md-6
    -   :height: 150
    -   :tag: 20 minutes
    -
    -.. displayitem::
    -   :header: Level 9: Render a web UI with other components
    -   :description: Learn how to embed graphical UIs like react, vue, streamlit and notebook UIs into a lightning workflow.
    -   :button_link: embed_web_ui_into_lightningwork.html
    -   :col_css: col-md-6
    -   :height: 150
    -   :tag: 15 minutes
    -
    -.. displayitem::
    -   :header: Level 10: Practice adapting app templates
    -   :description: Practice starting apps from templates and evolving them by replacing or adding components.
    -   :button_link: start_from_lightning_app_templates.html
    -   :col_css: col-md-6
    -   :height: 150
    -   :tag: intermediate
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/levels/intermediate/level_12.rst+0 12 removed
    @@ -1,12 +0,0 @@
    -:orphan:
    -
    -######################
    -Level 12: Flow vs Work
    -######################
    -**Audience:** Users who need to do non trivial workloads in their apps.
    -
    -**Prereqs:** Level 8+
    -
    -----
    -
    -.. include:: ../../workflows/build_lightning_component/from_scratch_component_content.rst
    
  • docs/source-app/levels/intermediate/level_2_scripts/code_run_cloud.bash+0 1 removed
    @@ -1 +0,0 @@
    -lightning run app app.py --cloud
    
  • docs/source-app/levels/intermediate/level_2_scripts/code_run_local.bash+0 1 removed
    @@ -1 +0,0 @@
    -lightning run app app.py
    
  • docs/source-app/levels/intermediate/level_2_scripts/hello_app_auto_scale.py+0 30 removed
    @@ -1,30 +0,0 @@
    -# app.py
    -from lightning.app import LightningWork, LightningFlow, LightningApp, CloudCompute
    -
    -
    -class TrainComponent(LightningWork):
    -    def run(self, x):
    -        print(f'train a model on {x}')
    -
    -class AnalyzeComponent(LightningWork):
    -    def run(self, x):
    -        print(f'analyze model on {x}')
    -
    -class WorkflowOrchestrator(LightningFlow):
    -    def __init__(self) -> None:
    -        super().__init__()
    -        self.train = TrainComponent(cloud_compute=CloudCompute('cpu'))
    -        self.analyze = AnalyzeComponent(cloud_compute=CloudCompute('gpu'))
    -
    -    def run(self):
    -        # run() starts the machine
    -        self.train.run("GPU machine 1")
    -
    -        # stop() stops the machine
    -        self.train.stop()
    -
    -        # run analysis ONLY when machine 1 stopped
    -        if self.train.status.STOPPED:
    -            self.analyze.run("CPU machine 2")
    -
    -app = LightningApp(WorkflowOrchestrator())
    
  • docs/source-app/levels/intermediate/level_2_scripts/hello_app_cron.py+0 27 removed
    @@ -1,27 +0,0 @@
    -# app.py
    -from lightning.app import LightningWork, LightningFlow, LightningApp, CloudCompute
    -
    -
    -class TrainComponent(LightningWork):
    -    def run(self, x):
    -        print(f'train a model on {x}')
    -
    -class AnalyzeComponent(LightningWork):
    -    def run(self, x):
    -        print(f'analyze model on {x}')
    -
    -class WorkflowOrchestrator(LightningFlow):
    -    def __init__(self) -> None:
    -        super().__init__()
    -        self.train = TrainComponent(cloud_compute=CloudCompute('cpu'))
    -        self.analyze = AnalyzeComponent(cloud_compute=CloudCompute('gpu'))
    -
    -    def run(self):
    -        # run training once
    -        self.train.run("GPU machine 1")
    -
    -        # run analysis once, then every hour again...
    -        if self.schedule("5 4 * * *"):
    -            self.analyze.run("CPU machine 2")
    -
    -app = LightningApp(WorkflowOrchestrator())
    
  • docs/source-app/levels/intermediate/level_2_scripts/hello_app.py+0 23 removed
    @@ -1,23 +0,0 @@
    -# app.py
    -from lightning.app import LightningWork, LightningFlow, LightningApp, CloudCompute
    -
    -
    -class TrainComponent(LightningWork):
    -    def run(self, x):
    -        print(f'train a model on {x}')
    -
    -class AnalyzeComponent(LightningWork):
    -    def run(self, x):
    -        print(f'analyze model on {x}')
    -
    -class WorkflowOrchestrator(LightningFlow):
    -    def __init__(self) -> None:
    -        super().__init__()
    -        self.train = TrainComponent(cloud_compute=CloudCompute('cpu'))
    -        self.analyze = AnalyzeComponent(cloud_compute=CloudCompute('gpu'))
    -
    -    def run(self):
    -        self.train.run("CPU machine 1")
    -        self.analyze.run("GPU machine 2")
    -
    -app = LightningApp(WorkflowOrchestrator())
    
  • docs/source-app/levels/intermediate/level_2_scripts/hello_app_scheduler.py+0 27 removed
    @@ -1,27 +0,0 @@
    -# app.py
    -from lightning.app import LightningWork, LightningFlow, LightningApp, CloudCompute
    -
    -
    -class TrainComponent(LightningWork):
    -    def run(self, x):
    -        print(f'train a model on {x}')
    -
    -class AnalyzeComponent(LightningWork):
    -    def run(self, x):
    -        print(f'analyze model on {x}')
    -
    -class WorkflowOrchestrator(LightningFlow):
    -    def __init__(self) -> None:
    -        super().__init__()
    -        self.train = TrainComponent(cloud_compute=CloudCompute('cpu'))
    -        self.analyze = AnalyzeComponent(cloud_compute=CloudCompute('gpu'))
    -
    -    def run(self):
    -        # run training once
    -        self.train.run("GPU machine 1")
    -
    -        # run analysis once, then every hour again...
    -        if self.schedule("hourly"):
    -            self.analyze.run("CPU machine 2")
    -
    -app = LightningApp(WorkflowOrchestrator())
    
  • docs/source-app/levels/intermediate/level_2_scripts/organized_app_python.py+0 36 removed
    @@ -1,36 +0,0 @@
    -# app.py
    -import subprocess
    -from lightning.app import LightningWork, LightningFlow, LightningApp, CloudCompute
    -
    -
    -class ExternalModelServer(LightningWork):
    -    def run(self, x):
    -        # compile
    -        process = subprocess.Popen('g++ model_server.cpp -o model_server')
    -        process.wait()
    -        process = subprocess.Popen('./model_server')
    -        process.wait()
    -
    -class LocustLoadTester(LightningWork):
    -    def run(self, x):
    -        cmd = f'locust --master-host {self.host} --master-port {self.port}'
    -        process = subprocess.Popen(cmd)
    -        process.wait()
    -
    -class WorkflowOrchestrator(LightningFlow):
    -    def __init__(self) -> None:
    -        super().__init__()
    -        self.serve = ExternalModelServer(
    -            cloud_compute=CloudCompute('cpu'), parallel=True
    -        )
    -        self.load_test = LocustLoadTester(cloud_compute=CloudCompute('cpu'))
    -
    -    def run(self):
    -        # start the server (on a CPU machine 1)
    -        self.serve.run()
    -
    -        # load testing when the server is up (on a separate cpu machine 2)
    -        if self.serve.state.RUNNING:
    -            self.load_test.run()
    -
    -app = LightningApp(WorkflowOrchestrator())
    
  • docs/source-app/levels/intermediate/level_9.rst+0 16 removed
    @@ -1,16 +0,0 @@
    -:orphan:
    -
    -###################
    -Level 9: Event loop
    -###################
    -**Audience:** Users who want to build reactive Lightning Apps and move beyond DAGs.
    -
    -**Prereqs:** Level 8+
    -
    -----
    -
    -Drawing inspiration from modern web frameworks like `React.js <https://reactjs.org/>`_, the Lightning App runs all flows in an **event loop** (forever), which is triggered several times a second after collecting any works' state change.
    -
    -.. figure::  https://pl-public-data.s3.amazonaws.com/assets_lightning/lightning_loop.gif
    -
    -When running a Lightning App in the cloud, the ``LightningWork`` run on different machines. LightningWork communicates any state changes to the **event loop** which re-executes the flow with the newly-collected works' state.
    
  • docs/source-app/levels/intermediate/run_lightning_work_in_parallel.rst+0 38 removed
    @@ -1,38 +0,0 @@
    -##############################################
    -Level 6: Run a Lightning component in parallel
    -##############################################
    -**Audience:** Users who want to run a Lightning Component in parallel (asynchronously).
    -
    -**Prereqs:** You must have finished :doc:`Level 5 <debug_a_lightning_app>`.
    -
    -----
    -
    -.. include:: ../../workflows/run_work_in_parallel_content.rst
    -
    -----
    -
    -**********************************************
    -Next steps: Share variables between components
    -**********************************************
    -Now that you know how to run components in parallel, we'll learn to share variables
    -across components to simplify complex workflows.
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: Level 7: Share variables between components
    -   :description: Learn to connect components
    -   :col_css: col-md-12
    -   :button_link: share_variables_between_lightning_components.html
    -   :height: 150
    -   :tag: 10 minutes
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/levels/intermediate/scripts/a+0 0 removed
  • docs/source-app/levels/intermediate/scripts/comms_1.py+0 18 removed
    @@ -1,18 +0,0 @@
    -# app.py
    -from lightning.app import LightningWork, LightningFlow, LightningApp
    -
    -class Component(LightningWork):
    -    def run(self, x):
    -        print(f'MACHINE 1: this string came from machine 0: "{x}"')
    -        print('MACHINE 1: this string is on machine 1')
    -
    -class WorkflowOrchestrator(LightningFlow):
    -    def __init__(self) -> None:
    -        super().__init__()
    -        self.component = Component()
    -
    -    def run(self):
    -        x = 'hello from machine 0'
    -        self.component.run(x)
    -
    -app = LightningApp(WorkflowOrchestrator())
    
  • docs/source-app/levels/intermediate/scripts/debug_app.py+0 25 removed
    @@ -1,25 +0,0 @@
    -# app.py
    -from lightning.app import LightningWork, LightningFlow, LightningApp
    -from lightning.app.runners import MultiProcessRuntime
    -
    -
    -class TrainComponent(LightningWork):
    -    def run(self, x):
    -        print(f'train a model on {x}')
    -
    -class AnalyzeComponent(LightningWork):
    -    def run(self, x):
    -        print(f'analyze model on {x}')
    -
    -class WorkflowOrchestrator(LightningFlow):
    -    def __init__(self) -> None:
    -        super().__init__()
    -        self.train = TrainComponent()
    -        self.analyze = AnalyzeComponent()
    -
    -    def run(self):
    -        self.train.run("GPU machine 1")
    -        self.analyze.run("CPU machine 2")
    -
    -app = LightningApp(WorkflowOrchestrator())
    -MultiProcessRuntime(app).dispatch()
    
  • docs/source-app/levels/intermediate/scripts/embeddings+0 0 removed
  • docs/source-app/levels/intermediate/scripts/.storage/a+0 0 removed
  • docs/source-app/levels/intermediate/scripts/.storage/embeddings+0 0 removed
  • docs/source-app/levels/intermediate/scripts/toy_app.py+0 24 removed
    @@ -1,24 +0,0 @@
    -# app.py
    -from lightning.app import LightningWork, LightningFlow, LightningApp
    -
    -
    -
    -class TrainComponent(LightningWork):
    -    def run(self, x):
    -        print(f'train a model on {x}')
    -
    -class AnalyzeComponent(LightningWork):
    -    def run(self, x):
    -        print(f'analyze model on {x}')
    -
    -class WorkflowOrchestrator(LightningFlow):
    -    def __init__(self) -> None:
    -        super().__init__()
    -        self.train = TrainComponent()
    -        self.analyze = AnalyzeComponent()
    -
    -    def run(self):
    -        self.train.run("CPU machine 1")
    -        self.analyze.run("CPU machine 2")
    -
    -app = LightningApp(WorkflowOrchestrator())
    
  • docs/source-app/levels/intermediate/scripts/toy_payload.py+0 31 removed
    @@ -1,31 +0,0 @@
    -# app.py
    -from lightning.app import LightningWork, LightningFlow, LightningApp
    -
    -
    -class EmbeddingProcessor(LightningWork):
    -    def __init__(self, *args, **kwargs):
    -        super().__init__(*args, **kwargs)
    -        self.embeddings = None
    -
    -    def run(self):
    -        print('PROCESSOR: Generating embeddings...')
    -        fake_embeddings = [[1, 2, 3], [2, 3, 4]]
    -        self.embeddings = storage.Payload(fake_embeddings)
    -
    -class EmbeddingServer(LightningWork):
    -    def run(self, payload):
    -        print('SERVER: Using embeddings from processor', payload)
    -        embeddings = payload.value
    -        print('serving embeddings sent from EmbeddingProcessor: ', embeddings)
    -
    -class WorkflowOrchestrator(LightningFlow):
    -    def __init__(self) -> None:
    -        super().__init__()
    -        self.processor = EmbeddingProcessor()
    -        self.server = EmbeddingServer()
    -
    -    def run(self):
    -        self.processor.run()
    -        self.server.run(self.processor.embeddings)
    -
    -app = LightningApp(WorkflowOrchestrator())
    
  • docs/source-app/levels/intermediate/scripts/two_comms_non_ml.py+0 36 removed
    @@ -1,36 +0,0 @@
    -# app.py
    -from lightning.app import LightningWork, LightningFlow, LightningApp
    -import time
    -
    -class A(LightningWork):
    -    def __init__(self, *args, **kwargs):
    -        super().__init__(*args, **kwargs)
    -        self.msg_changed = False
    -        self.new_msg = ''
    -
    -    def run(self):
    -        # pretend to train and save a checkpoint every 10 steps
    -        for step in (range(1000)):
    -            time.sleep(1.0)
    -            if step % 10 == 0:
    -                self.msg_changed = True
    -                self.new_msg = f'A is at step: {step}'
    -                print(self.new_msg)
    -
    -class B(LightningWork):
    -    def run(self, msg):
    -        print(f'B: message from A: {msg}')
    -
    -class Example(LightningFlow):
    -    def __init__(self) -> None:
    -        super().__init__()
    -        self.a = A(parallel=True)
    -        self.b = B(parallel=True)
    -
    -    def run(self):
    -        self.a.run()
    -        if self.a.msg_changed:
    -            self.a.msg_changed = False
    -            self.b.run(self.a.new_msg)
    -
    -app = LightningApp(Example())
    
  • docs/source-app/levels/intermediate/scripts/two_work_comms.py+0 35 removed
    @@ -1,35 +0,0 @@
    -# app.py
    -from lightning.app import LightningWork, LightningFlow, LightningApp
    -import time
    -
    -class TrainComponent(LightningWork):
    -    def __init__(self, *args, **kwargs):
    -        super().__init__(*args, **kwargs)
    -        self.last_checkpoint_path = None
    -
    -    def run(self):
    -        # pretend to train and save a checkpoint every 10 steps
    -        for step in (range(1000)):
    -            time.sleep(1.0)
    -            fake_loss = round(1/(step + 0.00001), 4)
    -            print(f'{step=}: {fake_loss=} ')
    -            if step % 10 == 0:
    -                self.last_checkpoint_path = f'/some/path/{step=}_{fake_loss=}'
    -                print(f'TRAIN COMPONENT: saved new checkpoint: {self.last_checkpoint_path}')
    -
    -class ModelDeploymentComponent(LightningWork):
    -    def run(self, new_checkpoint):
    -        print(f'DEPLOY COMPONENT: load new model from checkpoint: {new_checkpoint}')
    -
    -class ContinuousDeployment(LightningFlow):
    -    def __init__(self) -> None:
    -        super().__init__()
    -        self.train = TrainComponent(parallel=True)
    -        self.model_deployment = ModelDeploymentComponent(parallel=True)
    -
    -    def run(self):
    -        self.train.run()
    -        if self.train.last_checkpoint_path:
    -            self.model_deployment.run(self.train.last_checkpoint_path)
    -
    -app = LightningApp(ContinuousDeployment())
    
  • docs/source-app/levels/intermediate/share_files_between_components.rst+0 34 removed
    @@ -1,34 +0,0 @@
    -#######################################
    -Level 8: Share files between components
    -#######################################
    -**Audience:** Users who are moving large files such as artifacts or datasets.
    -
    -**Prereqs:** Level 6+
    -
    -----
    -
    -*************************************************
    -Next steps: Render a web UI with other components
    -*************************************************
    -Now that we know the key ways of sharing files and variables,
    -we'll apply it to embed web UIs alongside components.
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: Level 9: Render a web UI with other components
    -   :description: Learn how to embed graphical UIs like react, vue, streamlit and notebook UIs into a lightning workflow.
    -   :button_link: embed_web_ui_into_lightningwork.html
    -   :col_css: col-md-12
    -   :height: 150
    -   :tag: 15 minutes
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/levels/intermediate/share_variables_between_lightning_components.rst+0 162 removed
    @@ -1,162 +0,0 @@
    -###########################################
    -Level 7: Share variables between components
    -###########################################
    -**Audience:** Users who want to share variables and files across Lightning components.
    -
    -**Prereqs:** You must have finished `intermediate level 5+ <run_lightning_work_in_parallel.rst>`_.
    -
    -----
    -
    -****************************************
    -Send a variable from Flow to a Component
    -****************************************
    -When a variable is defined on the LightningFlow (orchestrator), and
    -then it's passed into functions for the work components, under the hood
    -Lightning sends the variables across the machines for you automatically.
    -
    -.. lit_tabs::
    -   :descriptions: Remember this component may live on its own machine; The flow may be on a separate machine as well; This variable is on the flow machine; When passed to the work component, it is actually sent across the network under the hood.; When it prints here, it prints on the work component machine (not the flow machine); The second string was directly created on machine 1
    -   :code_files: ./scripts/comms_1.py; ./scripts/comms_1.py; ./scripts/comms_1.py; ./scripts/comms_1.py; ./scripts/comms_1.py; ./scripts/comms_1.py
    -   :highlights: 4-7; 9-16; 15; 16; 6; 7;
    -   :enable_run: true
    -   :tab_rows: 3
    -   :height: 380px
    -
    -|
    -
    -.. collapse:: CLI output
    -
    -    .. code-block::
    -
    -        $ lightning run app app.py --open-ui=false
    -
    -        Your Lightning App is starting. This won't take long.
    -        INFO: Your app has started. View it in your browser: http://127.0.0.1:7501/view
    -        MACHINE 1: this string came from machine 0: "hello from machine 0"
    -        MACHINE 1: this string is on machine 1
    -
    -|
    -
    -In this example, we learned that we can send variables to components like in regular Python.
    -On a local machine, it will behave like Python. When the workflow is distributed on the cloud,
    -it makes network calls under the hood, but still functions like Python to you.
    -
    -----
    -
    -**************************************
    -Send a variable between two components
    -**************************************
    -A majority of workflows (especially in ML), require components to respond to a change in a component
    -likely running on a separate machine or even cluster.
    -
    -Example Continuous deployment: Every time a model saves a checkpoint, we redeploy a model:
    -
    -.. lit_tabs::
    -   :descriptions: Define a component that simulates training; Define a component that simulates deployment; Training will happen in parallel over a long period; The deployment server also runs in parallel forever; Start training in parallel (could take months); Whenever the model has a checkpoint deploy; When the checkpoint is updated, model re-deploys
    -   :code_files: ./scripts/two_work_comms.py; ./scripts/two_work_comms.py; ./scripts/two_work_comms.py; ./scripts/two_work_comms.py; ./scripts/two_work_comms.py; ./scripts/two_work_comms.py; ./scripts/two_work_comms.py
    -   :highlights: 5-18; 20-22; 27; 28; 31; 32, 33; 33
    -   :enable_run: true
    -   :tab_rows: 3
    -   :height: 690px
    -
    -|
    -
    -.. collapse:: CLI output:
    -
    -    .. code::
    -
    -        $ lightning run app app.py --open-ui=false
    -
    -        Your Lightning App is starting. This won't take long.
    -        INFO: Your app has started. View it in your browser: http://127.0.0.1:7501/view
    -        step=0: fake_loss=100000.0
    -        TRAIN COMPONENT: saved new checkpoint: /some/path/step=0_fake_loss=100000.0
    -        step=1: fake_loss=1.0
    -        DEPLOY COMPONENT: load new model from checkpoint: /some/path/step=0_fake_loss=100000.0
    -        step=2: fake_loss=0.5
    -        step=3: fake_loss=0.3333
    -        step=4: fake_loss=0.25
    -        step=5: fake_loss=0.2
    -        step=6: fake_loss=0.1667
    -        step=7: fake_loss=0.1429
    -        step=8: fake_loss=0.125
    -        step=9: fake_loss=0.1111
    -        step=10: fake_loss=0.1
    -        TRAIN COMPONENT: saved new checkpoint: /some/path/step=10_fake_loss=0.1
    -        DEPLOY COMPONENT: load new model from checkpoint: /some/path/step=10_fake_loss=0.1
    -        step=11: fake_loss=0.0909
    -        step=12: fake_loss=0.0833
    -        step=13: fake_loss=0.0769
    -        step=14: fake_loss=0.0714
    -        step=15: fake_loss=0.0667
    -        step=16: fake_loss=0.0625
    -        step=17: fake_loss=0.0588
    -        step=18: fake_loss=0.0556
    -        step=19: fake_loss=0.0526
    -        step=20: fake_loss=0.05
    -        TRAIN COMPONENT: saved new checkpoint: /some/path/step=20_fake_loss=0.05
    -        DEPLOY COMPONENT: load new model from checkpoint: /some/path/step=20_fake_loss=0.05
    -        step=21: fake_loss=0.0476
    -
    -----
    -
    -********************************************
    -Send a large variable between two components
    -********************************************
    -For large variables such as arrays, tensors, embeddings and so on, use Payload to enable
    -transferring them across components.
    -
    -.. lit_tabs::
    -   :descriptions: Let's define a component to simulate generating embeddings (from a DB, feature store, etc...); This component simulates a server that will use the embeddings.; Run the component to generate the embeddings; Simulate embeddings as an array. Here you would query a DB, load from a feature store or disk or even use a neural network to extract the embedding.; Allow the embeddings to be transferred efficiently by wrapping them in the Payload object.; Pass the variable to the EmbeddingServer (just the pointer).; The data gets transferred once you use the .value attribute in the other component.
    -   :code_files: ./scripts/toy_payload.py; ./scripts/toy_payload.py; ./scripts/toy_payload.py; ./scripts/toy_payload.py; ./scripts/toy_payload.py; ./scripts/toy_payload.py; ./scripts/toy_payload.py;
    -   :highlights: 5-13; 15-19; 28; 12; 13; 29; 18
    -   :enable_run: true
    -   :tab_rows: 3
    -   :height: 600px
    -
    -|
    -
    -.. collapse:: CLI output
    -
    -    .. code::
    -
    -            $ lightning run app app.py --open-ui=false
    -
    -            Your Lightning App is starting. This won't take long.
    -            INFO: Your app has started. View it in your browser: http://127.0.0.1:7501/view
    -            PROCESSOR: Generating embeddings...
    -            SERVER: Using embeddings from processor <lightning.app.storage.payload.Payload object at 0x123383d60>
    -            serving embeddings sent from EmbeddingProcessor:  [[1, 2, 3], [2, 3, 4]]
    -
    -|
    -
    -The payload object keeps the data on the machine and passes a pointer
    -to the data around the app until the data is needed by a component.
    -
    -----
    -
    -******************************************
    -Next steps: Share files between components
    -******************************************
    -Now that you know how to run components in parallel, we'll learn to share variables
    -across components to simplify complex workflows.
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: Level 8: Share files between components
    -   :description: Learn to share files between components.
    -   :col_css: col-md-12
    -   :button_link: share_files_between_components.html
    -   :height: 150
    -   :tag: 10 minutes
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/levels/intermediate/start_from_lightning_app_templates.rst+0 34 removed
    @@ -1,34 +0,0 @@
    -############################################
    -Level 10: Start from lightning app templates
    -############################################
    -**Audience:** All users who want to move quickly with Lightning
    -
    -**Prereqs:** You have finished :doc:`Level 9 <embed_web_ui_into_lightningwork>`.
    -
    -----
    -
    -****************************************************
    -Next step: Learn to build powerful nested components
    -****************************************************
    -Now that you can build powerful apps, learn to build nested components
    -that can do things like start dynamic works and connect to each other
    -via networking or CLI commands.
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: Advanced skills
    -   :description: Learn to build nested components with advanced functionality.
    -   :button_link: ../advanced/index.html
    -   :col_css: col-md-12
    -   :height: 170
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/make.bat+0 35 removed
    @@ -1,35 +0,0 @@
    -@ECHO OFF
    -
    -pushd %~dp0
    -
    -REM Command file for Sphinx documentation
    -
    -if "%SPHINXBUILD%" == "" (
    -	set SPHINXBUILD=sphinx-build
    -)
    -set SOURCEDIR=.
    -set BUILDDIR=../build
    -
    -if "%1" == "" goto help
    -
    -%SPHINXBUILD% >NUL 2>NUL
    -if errorlevel 9009 (
    -	echo.
    -	echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
    -	echo.installed, then set the SPHINXBUILD environment variable to point
    -	echo.to the full path of the 'sphinx-build' executable. Alternatively you
    -	echo.may add the Sphinx directory to PATH.
    -	echo.
    -	echo.If you don't have Sphinx installed, grab it from
    -	echo.http://sphinx-doc.org/
    -	exit /b 1
    -)
    -
    -%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
    -goto end
    -
    -:help
    -%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
    -
    -:end
    -popd
    
  • docs/source-app/Makefile+0 19 removed
    @@ -1,19 +0,0 @@
    -# Minimal makefile for Sphinx documentation
    -#
    -
    -# You can set these variables from the command line.
    -SPHINXOPTS    = -T -W
    -SPHINXBUILD   = sphinx-build
    -SOURCEDIR     = .
    -BUILDDIR      = ../build
    -
    -# Put it first so that "make" without argument is like "make help".
    -help:
    -	@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
    -
    -.PHONY: help Makefile
    -
    -# Catch-all target: route all unknown targets to Sphinx using the new
    -# "make mode" option.  $(O) is meant as a shortcut for $(SPHINXOPTS).
    -%: Makefile
    -	@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
    
  • docs/source-app/moving_to_the_cloud.rst+0 122 removed
    @@ -1,122 +0,0 @@
    -:orphan:
    -
    -.. _moving_to_the_cloud:
    -
    -####################
    -Moving to the Cloud
    -####################
    -
    -.. warning:: This is in progress and not yet fully supported.
    -
    -In the :ref:`quick_start` guide, you learned how to implement a simple app
    -that trains an image classifier and serve it once trained.
    -
    -In this tutorial, you'll learn how to extend that application so that it works seamlessly
    -both locally and in the cloud.
    -
    -----
    -
    -********************************
    -Step 1: Distributed Application
    -********************************
    -
    -
    -Distributed Storage
    -^^^^^^^^^^^^^^^^^^^
    -
    -When running your application in a fully-distributed setting, the data available on one machine won't necessarily be available on another.
    -
    -To solve this problem, Lightning introduces the :class:`~lightning.app.storage.path.Path` object.
    -This ensures that your code can run both locally and in the cloud.
    -
    -The :class:`~lightning.app.storage.path.Path` object keeps track of the work which creates
    -the path. This enables Lightning to transfer the files correctly in a distributed setting.
    -
    -Instead of passing a string representing a file or directory, Lightning simply wraps
    -them into a :class:`~lightning.app.storage.path.Path` object and makes them an attribute of your LightningWork.
    -
    -Without doing this conscientiously for every single path, your application will fail in the cloud.
    -
    -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
    -    :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
    -    :emphasize-lines: 21, 23-26
    -
    -----
    -
    -Distributed Frontend
    -^^^^^^^^^^^^^^^^^^^^
    -
    -In the above example, the **FastAPI Service** was running on one machine,
    -and the frontend UI in another.
    -
    -In order to assemble them, you need to do two things:
    -
    -* Provide **port** argument to your work's ``__init__`` method to expose a single service.
    -
    -Here's how to expose the port:
    -
    -.. 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
    -    :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
    -    :lines: 23-26
    -
    -
    -Here's a visualization of the application described above:
    -
    -.. figure:: https://pl-public-data.s3.amazonaws.com/assets_lightning/storage_ui.gif
    -    :alt: Storage API Animation
    -    :width: 100 %
    -
    -----
    -
    -*****************************
    -Step 2: Scalable Application
    -*****************************
    -
    -The benefit of defining long-running code inside a
    -:class:`~lightning.app.core.work.LightningWork`
    -component is that you can run it on different hardware
    -by providing :class:`~lightning.app.utilities.packaging.cloud_compute.CloudCompute` to
    -the ``__init__`` method of your :class:`~lightning.app.core.work.LightningWork`.
    -
    -By adapting the :ref:`quick_start` example as follows, you can easily run your component on multiple GPUs:
    -
    -
    -Without doing much, you’re now running a script on its own cluster of machines! 🤯
    -
    -----
    -
    -*****************************
    -Step 3: Resilient Application
    -*****************************
    -
    -We designed Lightning with a strong emphasis on supporting failure cases.
    -The framework shines when the developer embraces our fault-tolerance best practices,
    -enabling them to create ML applications with a high degree of complexity as well as a strong support
    -for unhappy cases.
    -
    -An entire section would be dedicated to this concept.
    -
    -TODO
    
  • docs/source-app/quickstart.rst+0 125 removed
    @@ -1,125 +0,0 @@
    -:orphan:
    -
    -.. _quick_start:
    -
    -############
    -Quick Start
    -############
    -
    -In this guide, we'll run an application that trains
    -an image classification model with the `MNIST Dataset <https://en.wikipedia.org/wiki/MNIST_database>`_,
    -and uses `Gradio <https://gradio.app>`_ to serve it.
    -
    -----
    -
    -**********************
    -Step 1 - Installation
    -**********************
    -
    -First, you'll need to install Lightning. You can find the complete guide here.
    -
    -Then, you'll need to install the `Lightning Quick Start package <https://github.com/Lightning-AI/lightning-quick-start>`_.
    -
    -.. code-block:: bash
    -
    -    lightning install app lightning/quick-start
    -
    -And download the training script used by the App:
    -
    -
    -----
    -
    -**********************
    -Step 2 - Run the app
    -**********************
    -
    -To run your app, copy the following command to your local terminal:
    -
    -.. code-block:: bash
    -
    -    lightning run app app.py
    -
    -And that's it!
    -
    -.. admonition::  You should see the app logs in your terminal.
    -   :class: dropdown
    -
    -    .. code-block:: console
    -
    -        Your Lightning App is starting. This won't take long.
    -        INFO: Your app has started. View it in your browser: http://127.0.0.1:7501/view
    -
    -        Global seed set to 42
    -
    -        GPU available: True (mps), used: False
    -        TPU available: False, using: 0 TPU cores
    -
    -          | Name    | Type     | Params | In sizes       | Out sizes
    -        ------------------------------------------------------------------
    -        0 | model   | Net      | 1.2 M  | [1, 1, 28, 28] | [1, 10]
    -        1 | val_acc | Accuracy | 0      | ?              | ?
    -        ------------------------------------------------------------------
    -        1.2 M     Trainable params
    -        0         Non-trainable params
    -        1.2 M     Total params
    -        Epoch 4: 100%|█████████████████████████| 16/16 [00:00<00:00, 32.31it/s, loss=0.0826, v_num=0]
    -        `Trainer.fit` stopped: `max_epochs=5` reached.
    -
    -        Running on local URL:  http://127.0.0.1:62782/
    -        ...
    -
    -
    -The app will open your browser and show an interactive demo:
    -
    -.. figure:: https://pl-public-data.s3.amazonaws.com/assets_lightning/qiuck-start-tensorboard-tab.png
    -    :alt: Quick Start UI - Model Training Tab
    -    :width: 100 %
    -
    -.. figure:: https://pl-public-data.s3.amazonaws.com/assets_lightning/quick-start-gradio-tab.png
    -    :alt: Quick Start UI - Interactive Demo Tab
    -    :width: 100 %
    -
    -----
    -
    -This app behind the scenes
    -^^^^^^^^^^^^^^^^^^^^^^^^^^^
    -
    -This application has one flow component which coordinates two works executing their own python script.
    -Once the training is finished, the trained model weights are passed to the serve component.
    -
    -
    -Here is how the components of a Lightning app are structured:
    -
    -.. figure:: https://pl-public-data.s3.amazonaws.com/assets_lightning/quick_start_components.gif
    -    :alt: Quick Start Application
    -    :width: 100 %
    -
    -Here is the application timeline:
    -
    -.. figure:: https://pl-public-data.s3.amazonaws.com/assets_lightning/timeline.gif
    -    :alt: Quick Start Timeline Application
    -    :width: 100 %
    -
    -----
    -
    -**************************************
    -Steps 3 - Build your app in the cloud
    -**************************************
    -
    -Simply add ``--cloud`` to run this application in the cloud 🤯
    -
    -.. code-block:: bash
    -
    -    lightning run app app.py --cloud
    -
    -Congratulations! You've now run your first application with Lightning.
    -
    -----
    -
    -***********
    -Next Steps
    -***********
    -
    -To learn how to build and modify apps, go to the :ref:`basics`.
    -
    -To learn how to create UIs for your apps, read :ref:`ui_and_frontends`.
    
  • docs/source-app/_static/copybutton.js+0 78 removed
    @@ -1,78 +0,0 @@
    -/* Copied from the official Python docs: https://docs.python.org/3/_static/copybutton.js */
    -$(document).ready(function () {
    -  /* Add a [>>>] button on the top-right corner of code samples to hide
    -   * the >>> and ... prompts and the output and thus make the code
    -   * copyable. */
    -  var div = $(
    -    ".highlight-python .highlight," +
    -      ".highlight-python3 .highlight," +
    -      ".highlight-pycon .highlight," +
    -      ".highlight-default .highlight",
    -  );
    -  var pre = div.find("pre");
    -
    -  // get the styles from the current theme
    -  pre.parent().parent().css("position", "relative");
    -  var hide_text = "Hide the prompts and output";
    -  var show_text = "Show the prompts and output";
    -  var border_width = pre.css("border-top-width");
    -  var border_style = pre.css("border-top-style");
    -  var border_color = pre.css("border-top-color");
    -  var button_styles = {
    -    cursor: "pointer",
    -    position: "absolute",
    -    top: "0",
    -    right: "0",
    -    "border-color": border_color,
    -    "border-style": border_style,
    -    "border-width": border_width,
    -    color: border_color,
    -    "text-size": "75%",
    -    "font-family": "monospace",
    -    "padding-left": "0.2em",
    -    "padding-right": "0.2em",
    -    "border-radius": "0 3px 0 0",
    -  };
    -
    -  // create and add the button to all the code blocks that contain >>>
    -  div.each(function (index) {
    -    var jthis = $(this);
    -    if (jthis.find(".gp").length > 0) {
    -      var button = $('<span class="copybutton">&gt;&gt;&gt;</span>');
    -      button.css(button_styles);
    -      button.attr("title", hide_text);
    -      button.data("hidden", "false");
    -      jthis.prepend(button);
    -    }
    -    // tracebacks (.gt) contain bare text elements that need to be
    -    // wrapped in a span to work with .nextUntil() (see later)
    -    jthis
    -      .find("pre:has(.gt)")
    -      .contents()
    -      .filter(function () {
    -        return this.nodeType == 3 && this.data.trim().length > 0;
    -      })
    -      .wrap("<span>");
    -  });
    -
    -  // define the behavior of the button when it's clicked
    -  $(".copybutton").click(function (e) {
    -    e.preventDefault();
    -    var button = $(this);
    -    if (button.data("hidden") === "false") {
    -      // hide the code output
    -      button.parent().find(".go, .gp, .gt").hide();
    -      button.next("pre").find(".gt").nextUntil(".gp, .go").css("visibility", "hidden");
    -      button.css("text-decoration", "line-through");
    -      button.attr("title", show_text);
    -      button.data("hidden", "true");
    -    } else {
    -      // show the code output
    -      button.parent().find(".go, .gp, .gt").show();
    -      button.next("pre").find(".gt").nextUntil(".gp, .go").css("visibility", "visible");
    -      button.css("text-decoration", "none");
    -      button.attr("title", hide_text);
    -      button.data("hidden", "false");
    -    }
    -  });
    -});
    
  • docs/source-app/_static/images/icon.svg+0 9 removed
    @@ -1,9 +0,0 @@
    -<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
    -<path d="M7.6932 0.0821815L1.30579 3.77571C1.21278 3.82957 1.13557 3.90694 1.08189 4.00006C1.02822 4.09317 0.999984 4.19875 1 4.30622V11.6943C1.00003 11.8017 1.0283 11.9073 1.08196 12.0004C1.13563 12.0935 1.21281 12.1709 1.30579 12.2248L7.6932 15.9178C7.78648 15.9716 7.89229 16 8 16C8.10771 16 8.21351 15.9716 8.30679 15.9178L14.6942 12.2248C14.7872 12.1709 14.8644 12.0935 14.918 12.0004C14.9717 11.9073 15 11.8017 15 11.6943V4.30622C15 4.19875 14.9718 4.09317 14.9181 4.00006C14.8644 3.90694 14.7872 3.82957 14.6942 3.77571L8.30679 0.0821815C8.21351 0.0283364 8.10771 0 8 0C7.89229 0 7.78648 0.0283364 7.6932 0.0821815ZM6.65211 12.3978L7.41055 9.16688C7.41599 9.14352 7.41528 9.11917 7.40849 9.09617C7.4017 9.07317 7.38907 9.05231 7.37182 9.03564L5.53355 7.24295C5.51998 7.22994 5.50918 7.21431 5.5018 7.19703C5.49442 7.17975 5.49063 7.16117 5.49063 7.14237C5.49063 7.12358 5.49442 7.10498 5.5018 7.08769C5.50918 7.07041 5.51998 7.0548 5.53355 7.0418L9.12811 3.46996C9.14946 3.44852 9.17724 3.43466 9.20721 3.43046C9.23718 3.42626 9.2677 3.43196 9.29413 3.44671C9.32056 3.46146 9.34144 3.48444 9.3536 3.51215C9.36575 3.53986 9.36852 3.57079 9.36147 3.60022L8.60203 6.83864C8.59634 6.86203 8.59687 6.88649 8.60358 6.9096C8.61028 6.93272 8.62293 6.95367 8.64025 6.97037L10.4679 8.75303C10.4811 8.76603 10.4915 8.7815 10.4986 8.79855C10.5057 8.8156 10.5094 8.83388 10.5094 8.85235C10.5094 8.87082 10.5057 8.8891 10.4986 8.90615C10.4915 8.92319 10.4811 8.93867 10.4679 8.95167L6.88597 12.5265C6.86459 12.5475 6.83701 12.5611 6.8073 12.5652C6.77759 12.5693 6.74736 12.5637 6.72109 12.5492C6.69482 12.5348 6.67392 12.5122 6.66149 12.4849C6.64906 12.4576 6.64577 12.4271 6.65211 12.3978Z" fill="url(#paint0_linear_1878_170374)"/>
    -<defs>
    -<linearGradient id="paint0_linear_1878_170374" x1="11.5573" y1="2.06173" x2="-1.81768" y2="25.1199" gradientUnits="userSpaceOnUse">
    -<stop stop-color="#792EE5"/>
    -<stop offset="1" stop-color="#3EABB3"/>
    -</linearGradient>
    -</defs>
    -</svg>
    
  • docs/source-app/_static/images/logo-large.svg+0 9 removed
    @@ -1,9 +0,0 @@
    -<svg width="224" height="224" viewBox="0 0 224 224" fill="none" xmlns="http://www.w3.org/2000/svg">
    -<path d="M107.705 1.15054L18.281 52.8599C16.9789 53.614 15.8979 54.6972 15.1465 56.0008C14.3951 57.3044 13.9998 58.7825 14 60.287V163.72C14.0005 165.224 14.3961 166.702 15.1475 168.005C15.8988 169.309 16.9794 170.392 18.281 171.147L107.705 222.849C109.011 223.603 110.492 224 112 224C113.508 224 114.989 223.603 116.295 222.849L205.719 171.147C207.021 170.392 208.101 169.309 208.853 168.005C209.604 166.702 210 165.224 210 163.72V60.287C210 58.7825 209.605 57.3044 208.853 56.0008C208.102 54.6972 207.021 53.614 205.719 52.8599L116.295 1.15054C114.989 0.39671 113.508 0 112 0C110.492 0 109.011 0.39671 107.705 1.15054ZM93.1295 173.569L103.748 128.336C103.824 128.009 103.814 127.668 103.719 127.346C103.624 127.024 103.447 126.732 103.206 126.499L77.4698 101.401C77.2798 101.219 77.1285 101 77.0252 100.758C76.9219 100.516 76.8688 100.256 76.8688 99.9932C76.8688 99.7301 76.9219 99.4697 77.0252 99.2277C77.1285 98.9857 77.2798 98.7672 77.4698 98.5852L127.794 48.5795C128.092 48.2793 128.481 48.0852 128.901 48.0264C129.321 47.9676 129.748 48.0475 130.118 48.254C130.488 48.4604 130.78 48.7821 130.95 49.1701C131.121 49.558 131.159 49.9911 131.061 50.4031L120.428 95.741C120.349 96.0684 120.356 96.4108 120.45 96.7345C120.544 97.0581 120.721 97.3513 120.964 97.5852L146.551 122.542C146.735 122.724 146.881 122.941 146.981 123.18C147.08 123.418 147.131 123.674 147.131 123.933C147.131 124.191 147.08 124.447 146.981 124.686C146.881 124.925 146.735 125.141 146.551 125.323L96.4036 175.371C96.1043 175.665 95.7181 175.855 95.3022 175.913C94.8863 175.97 94.463 175.891 94.0952 175.689C93.7275 175.487 93.4348 175.171 93.2608 174.789C93.0868 174.407 93.0408 173.979 93.1295 173.569Z" fill="url(#paint0_linear_1878_170388)"/>
    -<defs>
    -<linearGradient id="paint0_linear_1878_170388" x1="161.803" y1="28.8643" x2="-25.4475" y2="351.678" gradientUnits="userSpaceOnUse">
    -<stop stop-color="#792EE5"/>
    -<stop offset="1" stop-color="#3EABB3"/>
    -</linearGradient>
    -</defs>
    -</svg>
    
  • docs/source-app/_static/images/logo.png+0 0 removed
  • docs/source-app/_static/images/logo-small.svg+0 9 removed
    @@ -1,9 +0,0 @@
    -<svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
    -<path d="M23.0796 0.246544L3.91737 11.3271C3.63833 11.4887 3.4067 11.7208 3.24568 12.0002C3.08467 12.2795 2.99995 12.5962 3 12.9186V35.0828C3.0001 35.4052 3.08489 35.7218 3.24589 36.0012C3.40688 36.2805 3.63844 36.5126 3.91737 36.6744L23.0796 47.7534C23.3594 47.9149 23.6769 48 24 48C24.3231 48 24.6405 47.9149 24.9204 47.7534L44.0826 36.6744C44.3615 36.5126 44.5931 36.2805 44.7541 36.0012C44.9151 35.7218 44.9999 35.4052 45 35.0828V12.9186C45 12.5962 44.9153 12.2795 44.7543 12.0002C44.5933 11.7208 44.3617 11.4887 44.0826 11.3271L24.9204 0.246544C24.6405 0.0850093 24.3231 0 24 0C23.6769 0 23.3594 0.0850093 23.0796 0.246544ZM19.9563 37.1933L22.2317 27.5006C22.248 27.4306 22.2458 27.3575 22.2255 27.2885C22.2051 27.2195 22.1672 27.1569 22.1155 27.1069L16.6007 21.7288C16.56 21.6898 16.5275 21.6429 16.5054 21.5911C16.4833 21.5392 16.4719 21.4835 16.4719 21.4271C16.4719 21.3707 16.4833 21.3149 16.5054 21.2631C16.5275 21.2112 16.56 21.1644 16.6007 21.1254L27.3843 10.4099C27.4484 10.3456 27.5317 10.304 27.6216 10.2914C27.7115 10.2788 27.8031 10.2959 27.8824 10.3401C27.9617 10.3844 28.0243 10.4533 28.0608 10.5364C28.0973 10.6196 28.1055 10.7124 28.0844 10.8007L25.8061 20.5159C25.789 20.5861 25.7906 20.6595 25.8107 20.7288C25.8308 20.7982 25.8688 20.861 25.9208 20.9111L31.4039 26.2591C31.4432 26.2981 31.4745 26.3445 31.4958 26.3956C31.5172 26.4468 31.5281 26.5016 31.5281 26.557C31.5281 26.6124 31.5172 26.6673 31.4958 26.7184C31.4745 26.7696 31.4432 26.816 31.4039 26.855L20.6579 37.5795C20.5938 37.6426 20.511 37.6833 20.4219 37.6956C20.3328 37.7079 20.2421 37.691 20.1633 37.6476C20.0845 37.6043 20.0217 37.5367 19.9845 37.4548C19.9472 37.3729 19.9373 37.2812 19.9563 37.1933Z" fill="url(#paint0_linear_1878_170386)"/>
    -<defs>
    -<linearGradient id="paint0_linear_1878_170386" x1="34.672" y1="6.1852" x2="-5.45303" y2="75.3597" gradientUnits="userSpaceOnUse">
    -<stop stop-color="#792EE5"/>
    -<stop offset="1" stop-color="#3EABB3"/>
    -</linearGradient>
    -</defs>
    -</svg>
    
  • docs/source-app/_static/images/logo.svg+0 22 removed
    @@ -1,22 +0,0 @@
    -<svg width="385" height="101" viewBox="0 0 385 101" fill="none" xmlns="http://www.w3.org/2000/svg">
    -<g clip-path="url(#clip0_402_129)">
    -<path d="M41.5765 1.57696L1.78056 24.6539C1.191 24.9497 0.896211 25.5415 0.306642 26.1332C0.0665573 26.6922 -0.0346068 27.3014 0.0118562 27.9083V74.0622C0.0729164 74.6908 0.27444 75.2976 0.601428 75.8373C0.935017 76.4667 1.44824 76.9818 2.07535 77.3166L41.5765 100.394C42.0867 100.778 42.7074 100.985 43.3452 100.985C43.983 100.985 44.6036 100.778 45.1139 100.394L84.615 77.3166C85.2421 76.9818 85.7554 76.4667 86.0889 75.8373C86.4159 75.2976 86.6175 74.6908 86.6785 74.0622V27.9379C86.6175 27.3092 86.4159 26.7025 86.0889 26.1628C85.7554 25.5334 85.2421 25.0183 84.615 24.6835L45.1139 1.60655C44.5761 1.27837 43.9716 1.07611 43.3452 1.01483C42.7211 1.06707 42.1167 1.25917 41.5765 1.57696Z" fill="url(#paint0_linear_402_129)"/>
    -<g clip-path="url(#clip1_402_129)">
    -<path d="M67.6675 50.6829C67.5909 49.5408 67.0834 48.4704 66.2478 47.6882C65.4121 46.906 64.3106 46.4703 63.166 46.4692H63.1524C62.1912 46.4719 61.2559 46.7808 60.4822 47.3511C59.7085 47.9214 59.1366 48.7234 58.8496 49.6407H52.6205V46.38C52.6213 46.0294 52.5305 45.6847 52.3573 45.3799C52.1841 45.0752 51.9343 44.8209 51.6327 44.6422L51.6098 44.6286L55.2688 40.9704C56.2251 41.472 57.3294 41.6143 58.3816 41.3715C59.4338 41.1287 60.3642 40.5169 61.0041 39.6471C61.644 38.7772 61.951 37.7068 61.8694 36.63C61.7879 35.5533 61.3232 34.5413 60.5596 33.7777C59.796 33.0142 58.7841 32.5495 57.7074 32.4679C56.6306 32.3864 55.5602 32.6934 54.6904 33.3332C53.8205 33.9731 53.2087 34.9035 52.966 35.9558C52.7232 37.008 52.8655 38.1124 53.3671 39.0687L49.2053 43.2306L44.6936 40.5975V35.4759C45.7242 35.1544 46.6056 34.4742 47.1778 33.5587C47.75 32.6431 47.9753 31.5529 47.8127 30.4855C47.6501 29.4182 47.1104 28.4444 46.2915 27.7408C45.4726 27.0372 44.4287 26.6503 43.349 26.6503C42.2694 26.6503 41.2255 27.0372 40.4066 27.7408C39.5877 28.4444 39.048 29.4182 38.8854 30.4855C38.7228 31.5529 38.948 32.6431 39.5203 33.5587C40.0925 34.4742 40.9739 35.1544 42.0045 35.4759V40.5975L37.4936 43.2238L33.3319 39.0619C33.8334 38.1056 33.9757 37.0012 33.7329 35.949C33.4902 34.8967 32.8784 33.9663 32.0085 33.3265C31.1387 32.6866 30.0683 32.3796 28.9916 32.4611C27.9148 32.5427 26.9029 33.0074 26.1393 33.7709C25.3757 34.5345 24.911 35.5465 24.8295 36.6232C24.748 37.7 25.055 38.7704 25.6948 39.6403C26.3347 40.5101 27.2651 41.1219 28.3173 41.3647C29.3695 41.6075 30.4739 41.4652 31.4302 40.9636L35.0891 44.6218L35.0671 44.6354C34.7646 44.8137 34.5141 45.0679 34.3402 45.3729C34.1663 45.6779 34.0752 46.023 34.0759 46.374V49.6373H27.8417C27.5202 48.6064 26.8399 47.7248 25.9242 47.1524C25.0085 46.58 23.918 46.3547 22.8505 46.5173C21.7829 46.6799 20.809 47.2197 20.1052 48.0387C19.4015 48.8578 19.0145 49.9019 19.0145 50.9818C19.0145 52.0617 19.4015 53.1059 20.1052 53.9249C20.809 54.744 21.7829 55.2838 22.8505 55.4464C23.918 55.609 25.0085 55.3837 25.9242 54.8113C26.8399 54.2389 27.5202 53.3573 27.8417 52.3264H34.0759V55.5879C34.0759 55.9387 34.1675 56.2834 34.3414 56.588C34.5154 56.8926 34.7658 57.1466 35.0679 57.3249L35.0908 57.3384L31.4319 60.9966C30.4756 60.4951 29.3712 60.3528 28.319 60.5955C27.2668 60.8383 26.3364 61.4501 25.6965 62.32C25.0567 63.1899 24.7497 64.2602 24.8312 65.337C24.9127 66.4138 25.3774 67.4257 26.141 68.1893C26.9046 68.9529 27.9165 69.4176 28.9933 69.4991C30.07 69.5807 31.1404 69.2737 32.0102 68.6338C32.8801 67.9939 33.4919 67.0635 33.7346 66.0113C33.9774 64.9591 33.8351 63.8547 33.3336 62.8984L37.4953 58.7365L42.0037 61.3704V66.492C40.9728 66.8135 40.0912 67.4938 39.5188 68.4095C38.9464 69.3252 38.7211 70.4157 38.8837 71.4833C39.0463 72.5509 39.5861 73.5248 40.4051 74.2286C41.2242 74.9324 42.2683 75.3193 43.3482 75.3193C44.428 75.3193 45.4722 74.9324 46.2912 74.2286C47.1103 73.5248 47.6501 72.5509 47.8127 71.4833C47.9753 70.4157 47.7499 69.3252 47.1776 68.4095C46.6052 67.4938 45.7236 66.8135 44.6927 66.492V61.3704L49.2044 58.7441L53.3662 62.906C52.8643 63.8624 52.7218 64.9671 52.9645 66.0196C53.2073 67.0721 53.8192 68.0028 54.6894 68.6427C55.5595 69.2827 56.6302 69.5895 57.7072 69.5077C58.7842 69.4258 59.7962 68.9606 60.5597 68.1965C61.3231 67.4324 61.7874 66.42 61.8683 65.3428C61.9491 64.2657 61.6413 63.1953 61.0006 62.3257C60.3599 61.4561 59.4287 60.845 58.376 60.6032C57.3233 60.3614 56.2188 60.5049 55.2628 61.0077L51.6013 57.3452L51.6234 57.3316C51.9268 57.1541 52.1785 56.9001 52.3535 56.5951C52.5284 56.2901 52.6205 55.9446 52.6205 55.593V52.3298H58.8547C59.1832 53.3862 59.8882 54.2853 60.8358 54.8564C61.7834 55.4274 62.9077 55.6306 63.9953 55.4275C65.0828 55.2243 66.0579 54.6289 66.7355 53.7543C67.4131 52.8797 67.7459 51.7867 67.6709 50.6829H67.6675ZM63.166 49.1591C63.6501 49.1602 64.1143 49.3521 64.4578 49.6933C64.8 50.036 64.9922 50.5005 64.9922 50.9848C64.9922 51.4691 64.8 51.9336 64.4578 52.2763C64.1144 52.6177 63.6502 52.81 63.166 52.8114C62.6817 52.8114 62.2172 52.619 61.8747 52.2765C61.5323 51.934 61.3399 51.4695 61.3399 50.9852C61.3399 50.5009 61.5323 50.0364 61.8747 49.694C62.2172 49.3515 62.6817 49.1591 63.166 49.1591ZM57.3497 63.1438C57.592 63.1469 57.8315 63.1977 58.0542 63.2935C58.2769 63.3893 58.4785 63.528 58.6474 63.7019L58.6542 63.7086C58.995 64.0509 59.1863 64.5142 59.1863 64.9971C59.1863 65.4801 58.995 65.9434 58.6542 66.2856C58.3044 66.6183 57.8401 66.8038 57.3573 66.8038C56.8745 66.8038 56.4102 66.6183 56.0603 66.2856C55.7969 66.0319 55.6158 65.7049 55.5403 65.347C55.4648 64.9892 55.4984 64.6169 55.6368 64.2784C55.7753 63.9398 56.0121 63.6506 56.3167 63.4482C56.6213 63.2458 56.9797 63.1395 57.3454 63.143L57.3497 63.1438ZM31.1567 36.9708C31.1572 37.2095 31.1106 37.446 31.0195 37.6667C30.9284 37.8874 30.7946 38.0879 30.6258 38.2567C30.2759 38.5883 29.8122 38.773 29.3302 38.773C28.8481 38.773 28.3844 38.5883 28.0345 38.2567C27.8231 38.0437 27.6675 37.782 27.5814 37.4946C27.4952 37.2072 27.4812 36.903 27.5406 36.6089C27.6 36.3148 27.7309 36.0398 27.9218 35.8084C28.1127 35.5769 28.3577 35.3961 28.6352 35.2818C28.9126 35.1675 29.2139 35.1234 29.5124 35.1533C29.811 35.1831 30.0975 35.2861 30.3468 35.4531C30.5961 35.6201 30.8004 35.8459 30.9416 36.1106C31.0829 36.3753 31.1568 36.6707 31.1567 36.9708ZM42.0538 32.4573C41.8837 32.2881 41.7488 32.087 41.6569 31.8653C41.5651 31.6437 41.5181 31.4061 41.5187 31.1662C41.5202 30.682 41.7124 30.2178 42.0538 29.8744C42.3965 29.5322 42.861 29.34 43.3452 29.34C43.8295 29.34 44.2939 29.5322 44.6366 29.8744C44.9778 30.2179 45.1697 30.6821 45.1709 31.1662C45.1708 31.5273 45.0636 31.8803 44.863 32.1805C44.6623 32.4808 44.3772 32.7147 44.0435 32.8529C43.7099 32.9911 43.3428 33.0273 42.9887 32.9568C42.6345 32.8864 42.3092 32.7126 42.0538 32.4573ZM49.9272 48.5747V55.2065L44.6893 58.2566V51.7437L49.9272 48.5747ZM42.0037 51.7437V58.2566L36.7657 55.2057V48.5705L42.0037 51.7437ZM43.349 49.4131L37.8945 46.1048L43.3482 42.9316L48.8078 46.1116L43.349 49.4131ZM44.6366 69.5123C44.8066 69.6815 44.9414 69.8827 45.0331 70.1043C45.1248 70.3259 45.1716 70.5635 45.1709 70.8034C45.1698 71.2875 44.9778 71.7517 44.6366 72.0952C44.2939 72.4374 43.8295 72.6296 43.3452 72.6296C42.861 72.6296 42.3965 72.4374 42.0538 72.0952C41.7123 71.7518 41.5201 71.2876 41.5187 70.8034C41.5186 70.4421 41.6257 70.0889 41.8264 69.7885C42.0271 69.4881 42.3124 69.254 42.6462 69.1158C42.98 68.9776 43.3473 68.9415 43.7016 69.0121C44.0559 69.0826 44.3813 69.2567 44.6366 69.5123ZM57.8321 35.2067C58.1411 35.2897 58.4228 35.4524 58.6492 35.6785C58.8755 35.9047 59.0385 36.1863 59.1218 36.4952C59.2052 36.8041 59.2059 37.1295 59.124 37.4387C59.0421 37.748 58.8804 38.0304 58.6551 38.2576C58.3052 38.5891 57.8415 38.7739 57.3594 38.7739C56.8774 38.7739 56.4137 38.5891 56.0637 38.2576C55.7235 37.9148 55.5329 37.451 55.5339 36.968C55.5348 36.485 55.7272 36.022 56.0688 35.6806L56.0909 35.6568C56.3179 35.4383 56.5974 35.2821 56.9024 35.2033C57.2074 35.1244 57.5276 35.1256 57.8321 35.2067ZM31.1575 64.9997C31.1582 65.2386 31.1117 65.4752 31.0206 65.6961C30.9295 65.9169 30.7956 66.1175 30.6267 66.2865C30.2769 66.618 29.8133 66.8027 29.3314 66.8027C28.8495 66.8027 28.386 66.618 28.0362 66.2865C27.8246 66.0736 27.6688 65.8119 27.5825 65.5245C27.4962 65.2371 27.482 64.9328 27.5413 64.6387C27.6005 64.3445 27.7314 64.0694 27.9222 63.8379C28.113 63.6063 28.358 63.4253 28.6355 63.3109C28.9129 63.1966 29.2142 63.1523 29.5128 63.1821C29.8114 63.2119 30.0981 63.3149 30.3474 63.4818C30.5968 63.6488 30.8011 63.8746 30.9424 64.1394C31.0837 64.4041 31.1576 64.6996 31.1575 64.9997ZM25.3565 50.9852C25.3566 51.2251 25.3094 51.4626 25.2177 51.6842C25.126 51.9058 24.9915 52.1071 24.8219 52.2767C24.6523 52.4463 24.4509 52.5808 24.2293 52.6726C24.0077 52.7643 23.7702 52.8115 23.5304 52.8114C23.0465 52.8102 22.5826 52.6182 22.2394 52.2771C22.0698 52.1075 21.9352 51.9062 21.8434 51.6846C21.7516 51.463 21.7044 51.2255 21.7044 50.9857C21.7044 50.7458 21.7516 50.5083 21.8434 50.2867C21.9352 50.0651 22.0698 49.8638 22.2394 49.6942C22.5825 49.3529 23.0464 49.1606 23.5304 49.1591C24.0146 49.1593 24.479 49.3518 24.8214 49.6942C25.1638 50.0366 25.3563 50.501 25.3565 50.9852Z" fill="white"/>
    -</g>
    -</g>
    -<path d="M107.857 47.9852V18.8943H113.127V43.5676H125.94V47.9852H107.857ZM129.286 47.9852V26.167H134.428V47.9852H129.286ZM131.872 23.0705C131.057 23.0705 130.356 22.8006 129.769 22.2608C129.182 21.7116 128.889 21.0534 128.889 20.2864C128.889 19.5098 129.182 18.8517 129.769 18.3119C130.356 17.7627 131.057 17.4881 131.872 17.4881C132.695 17.4881 133.396 17.7627 133.974 18.3119C134.561 18.8517 134.855 19.5098 134.855 20.2864C134.855 21.0534 134.561 21.7116 133.974 22.2608C133.396 22.8006 132.695 23.0705 131.872 23.0705ZM148.205 56.6216C146.358 56.6216 144.772 56.3706 143.446 55.8688C142.12 55.3763 141.055 54.7134 140.25 53.8801C139.445 53.0468 138.886 52.1235 138.574 51.1102L143.205 49.9881C143.413 50.4142 143.716 50.8356 144.114 51.2523C144.511 51.6784 145.047 52.0288 145.719 52.3034C146.401 52.5875 147.258 52.7295 148.29 52.7295C149.748 52.7295 150.956 52.3744 151.912 51.6642C152.868 50.9634 153.347 49.8081 153.347 48.1983V44.0648H153.091C152.826 44.5951 152.438 45.1396 151.926 45.6983C151.424 46.257 150.757 46.7258 149.923 47.1045C149.1 47.4833 148.063 47.6727 146.813 47.6727C145.136 47.6727 143.617 47.2797 142.253 46.4938C140.899 45.6983 139.819 44.5146 139.014 42.9426C138.219 41.3612 137.821 39.382 137.821 37.0051C137.821 34.6093 138.219 32.5875 139.014 30.9398C139.819 29.2826 140.904 28.0278 142.267 27.1756C143.631 26.3138 145.151 25.883 146.827 25.883C148.105 25.883 149.156 26.1008 149.98 26.5364C150.814 26.9625 151.476 27.4786 151.969 28.0847C152.461 28.6813 152.835 29.2447 153.091 29.775H153.375V26.167H158.446V48.3403C158.446 50.2059 158.001 51.7494 157.111 52.971C156.221 54.1926 155.004 55.1064 153.46 55.7125C151.917 56.3186 150.165 56.6216 148.205 56.6216ZM148.247 43.6386C149.336 43.6386 150.264 43.3735 151.031 42.8432C151.798 42.3129 152.381 41.5506 152.779 40.5563C153.176 39.5619 153.375 38.3688 153.375 36.9767C153.375 35.6036 153.176 34.4009 152.779 33.3688C152.39 32.3366 151.813 31.5364 151.046 30.9682C150.288 30.3905 149.355 30.1017 148.247 30.1017C147.101 30.1017 146.145 30.4 145.378 30.9966C144.611 31.5932 144.033 32.4123 143.645 33.454C143.257 34.4862 143.063 35.6604 143.063 36.9767C143.063 38.3119 143.257 39.4814 143.645 40.4852C144.043 41.4795 144.625 42.2561 145.392 42.8148C146.169 43.364 147.12 43.6386 148.247 43.6386ZM167.858 35.2011V47.9852H162.716V18.8943H167.744V29.8744H168C168.511 28.6434 169.302 27.6727 170.372 26.9625C171.452 26.2428 172.825 25.883 174.492 25.883C176.007 25.883 177.328 26.2002 178.455 26.8347C179.582 27.4691 180.453 28.3972 181.068 29.6188C181.693 30.8403 182.006 32.3318 182.006 34.0932V47.9852H176.864V34.8886C176.864 33.4208 176.485 32.2797 175.727 31.4653C174.979 30.6415 173.928 30.2295 172.574 30.2295C171.665 30.2295 170.85 30.4284 170.131 30.8261C169.421 31.2144 168.862 31.7778 168.455 32.5165C168.057 33.2551 167.858 34.15 167.858 35.2011ZM197.142 26.167V30.1443H184.6V26.167H197.142ZM187.696 20.9398H192.838V41.4227C192.838 42.114 192.942 42.6443 193.151 43.0136C193.368 43.3735 193.653 43.6197 194.003 43.7523C194.353 43.8849 194.742 43.9511 195.168 43.9511C195.49 43.9511 195.783 43.9275 196.048 43.8801C196.323 43.8328 196.531 43.7902 196.673 43.7523L197.54 47.7722C197.265 47.8669 196.872 47.971 196.361 48.0847C195.859 48.1983 195.243 48.2646 194.514 48.2835C193.226 48.3214 192.066 48.1273 191.034 47.7011C190.002 47.2655 189.183 46.5932 188.577 45.6841C187.98 44.775 187.687 43.6386 187.696 42.275V20.9398ZM205.585 35.2011V47.9852H200.443V26.167H205.357V29.8744H205.613C206.115 28.6528 206.915 27.6822 208.014 26.9625C209.122 26.2428 210.49 25.883 212.119 25.883C213.624 25.883 214.936 26.2049 216.053 26.8489C217.18 27.4928 218.051 28.4256 218.667 29.6472C219.292 30.8688 219.6 32.3508 219.59 34.0932V47.9852H214.448V34.8886C214.448 33.4303 214.069 32.2892 213.312 31.4653C212.564 30.6415 211.527 30.2295 210.201 30.2295C209.301 30.2295 208.501 30.4284 207.801 30.8261C207.109 31.2144 206.565 31.7778 206.167 32.5165C205.779 33.2551 205.585 34.15 205.585 35.2011ZM223.818 47.9852V26.167H228.96V47.9852H223.818ZM226.403 23.0705C225.588 23.0705 224.888 22.8006 224.301 22.2608C223.713 21.7116 223.42 21.0534 223.42 20.2864C223.42 19.5098 223.713 18.8517 224.301 18.3119C224.888 17.7627 225.588 17.4881 226.403 17.4881C227.227 17.4881 227.927 17.7627 228.505 18.3119C229.092 18.8517 229.386 19.5098 229.386 20.2864C229.386 21.0534 229.092 21.7116 228.505 22.2608C227.927 22.8006 227.227 23.0705 226.403 23.0705ZM238.389 35.2011V47.9852H233.247V26.167H238.162V29.8744H238.418C238.92 28.6528 239.72 27.6822 240.818 26.9625C241.926 26.2428 243.295 25.883 244.923 25.883C246.429 25.883 247.741 26.2049 248.858 26.8489C249.985 27.4928 250.856 28.4256 251.472 29.6472C252.097 30.8688 252.404 32.3508 252.395 34.0932V47.9852H247.253V34.8886C247.253 33.4303 246.874 32.2892 246.117 31.4653C245.368 30.6415 244.332 30.2295 243.006 30.2295C242.106 30.2295 241.306 30.4284 240.605 30.8261C239.914 31.2144 239.369 31.7778 238.972 32.5165C238.583 33.2551 238.389 34.15 238.389 35.2011ZM266.111 56.6216C264.264 56.6216 262.678 56.3706 261.352 55.8688C260.027 55.3763 258.961 54.7134 258.156 53.8801C257.351 53.0468 256.793 52.1235 256.48 51.1102L261.111 49.9881C261.319 50.4142 261.622 50.8356 262.02 51.2523C262.418 51.6784 262.953 52.0288 263.625 52.3034C264.307 52.5875 265.164 52.7295 266.196 52.7295C267.654 52.7295 268.862 52.3744 269.818 51.6642C270.775 50.9634 271.253 49.8081 271.253 48.1983V44.0648H270.997C270.732 44.5951 270.344 45.1396 269.832 45.6983C269.331 46.257 268.663 46.7258 267.83 47.1045C267.006 47.4833 265.969 47.6727 264.719 47.6727C263.043 47.6727 261.523 47.2797 260.159 46.4938C258.805 45.6983 257.725 44.5146 256.921 42.9426C256.125 41.3612 255.727 39.382 255.727 37.0051C255.727 34.6093 256.125 32.5875 256.921 30.9398C257.725 29.2826 258.81 28.0278 260.173 27.1756C261.537 26.3138 263.057 25.883 264.733 25.883C266.011 25.883 267.063 26.1008 267.886 26.5364C268.72 26.9625 269.383 27.4786 269.875 28.0847C270.368 28.6813 270.742 29.2447 270.997 29.775H271.281V26.167H276.352V48.3403C276.352 50.2059 275.907 51.7494 275.017 52.971C274.127 54.1926 272.91 55.1064 271.367 55.7125C269.823 56.3186 268.071 56.6216 266.111 56.6216ZM266.154 43.6386C267.243 43.6386 268.171 43.3735 268.938 42.8432C269.705 42.3129 270.287 41.5506 270.685 40.5563C271.082 39.5619 271.281 38.3688 271.281 36.9767C271.281 35.6036 271.082 34.4009 270.685 33.3688C270.297 32.3366 269.719 31.5364 268.952 30.9682C268.194 30.3905 267.261 30.1017 266.154 30.1017C265.008 30.1017 264.051 30.4 263.284 30.9966C262.517 31.5932 261.94 32.4123 261.551 33.454C261.163 34.4862 260.969 35.6604 260.969 36.9767C260.969 38.3119 261.163 39.4814 261.551 40.4852C261.949 41.4795 262.531 42.2561 263.298 42.8148C264.075 43.364 265.027 43.6386 266.154 43.6386ZM293.507 47.9852H287.882L298.124 18.8943H304.629L314.885 47.9852H309.26L301.49 24.8602H301.263L293.507 47.9852ZM293.692 36.579H309.033V40.8119H293.692V36.579ZM317.489 56.167V26.167H322.546V29.775H322.845C323.11 29.2447 323.484 28.6813 323.967 28.0847C324.45 27.4786 325.103 26.9625 325.927 26.5364C326.751 26.1008 327.802 25.883 329.08 25.883C330.766 25.883 332.286 26.3138 333.64 27.1756C335.004 28.0278 336.083 29.292 336.879 30.9682C337.684 32.6348 338.086 34.6803 338.086 37.1045C338.086 39.5004 337.693 41.5364 336.907 43.2125C336.121 44.8886 335.051 46.167 333.697 47.0477C332.343 47.9284 330.809 48.3688 329.095 48.3688C327.845 48.3688 326.808 48.1604 325.984 47.7438C325.16 47.3271 324.497 46.8252 323.995 46.2381C323.503 45.6415 323.119 45.078 322.845 44.5477H322.632V56.167H317.489ZM322.532 37.0761C322.532 38.4871 322.731 39.7229 323.129 40.7835C323.536 41.8441 324.118 42.6727 324.876 43.2693C325.643 43.8564 326.571 44.15 327.66 44.15C328.796 44.15 329.748 43.847 330.515 43.2409C331.282 42.6254 331.86 41.7873 332.248 40.7267C332.646 39.6566 332.845 38.4398 332.845 37.0761C332.845 35.722 332.65 34.5193 332.262 33.4682C331.874 32.417 331.296 31.5932 330.529 30.9966C329.762 30.4 328.806 30.1017 327.66 30.1017C326.561 30.1017 325.629 30.3905 324.862 30.9682C324.095 31.5458 323.512 32.3555 323.114 33.3972C322.726 34.4388 322.532 35.6652 322.532 37.0761ZM341.489 56.167V26.167H346.546V29.775H346.845C347.11 29.2447 347.484 28.6813 347.967 28.0847C348.45 27.4786 349.103 26.9625 349.927 26.5364C350.751 26.1008 351.802 25.883 353.08 25.883C354.766 25.883 356.286 26.3138 357.64 27.1756C359.004 28.0278 360.083 29.292 360.879 30.9682C361.684 32.6348 362.086 34.6803 362.086 37.1045C362.086 39.5004 361.693 41.5364 360.907 43.2125C360.121 44.8886 359.051 46.167 357.697 47.0477C356.343 47.9284 354.809 48.3688 353.095 48.3688C351.845 48.3688 350.808 48.1604 349.984 47.7438C349.16 47.3271 348.497 46.8252 347.995 46.2381C347.503 45.6415 347.119 45.078 346.845 44.5477H346.632V56.167H341.489ZM346.532 37.0761C346.532 38.4871 346.731 39.7229 347.129 40.7835C347.536 41.8441 348.118 42.6727 348.876 43.2693C349.643 43.8564 350.571 44.15 351.66 44.15C352.796 44.15 353.748 43.847 354.515 43.2409C355.282 42.6254 355.86 41.7873 356.248 40.7267C356.646 39.6566 356.845 38.4398 356.845 37.0761C356.845 35.722 356.65 34.5193 356.262 33.4682C355.874 32.417 355.296 31.5932 354.529 30.9966C353.762 30.4 352.806 30.1017 351.66 30.1017C350.561 30.1017 349.629 30.3905 348.862 30.9682C348.095 31.5458 347.512 32.3555 347.114 33.3972C346.726 34.4388 346.532 35.6652 346.532 37.0761ZM382.734 31.9341L378.046 32.4455C377.914 31.972 377.682 31.5269 377.35 31.1102C377.028 30.6936 376.593 30.3574 376.043 30.1017C375.494 29.846 374.822 29.7182 374.026 29.7182C372.956 29.7182 372.057 29.9502 371.328 30.4142C370.608 30.8782 370.253 31.4795 370.262 32.2182C370.253 32.8527 370.485 33.3688 370.958 33.7665C371.441 34.1642 372.237 34.4909 373.345 34.7466L377.066 35.542C379.131 35.9871 380.665 36.6926 381.668 37.6585C382.682 38.6244 383.193 39.8886 383.203 41.4511C383.193 42.8242 382.791 44.0364 381.995 45.0875C381.209 46.1292 380.115 46.9436 378.714 47.5307C377.312 48.1178 375.703 48.4114 373.884 48.4114C371.214 48.4114 369.064 47.8527 367.435 46.7352C365.807 45.6083 364.836 44.0411 364.524 42.0335L369.538 41.5506C369.765 42.5354 370.248 43.2788 370.987 43.7807C371.725 44.2826 372.686 44.5335 373.87 44.5335C375.092 44.5335 376.072 44.2826 376.81 43.7807C377.559 43.2788 377.933 42.6585 377.933 41.9199C377.933 41.2949 377.691 40.7788 377.208 40.3716C376.735 39.9644 375.996 39.6519 374.992 39.4341L371.271 38.6528C369.178 38.2172 367.63 37.4833 366.626 36.4511C365.622 35.4095 365.125 34.0932 365.134 32.5023C365.125 31.1576 365.489 29.9928 366.228 29.008C366.976 28.0136 368.013 27.2466 369.339 26.7068C370.674 26.1576 372.213 25.883 373.955 25.883C376.512 25.883 378.524 26.4275 379.992 27.5165C381.47 28.6055 382.383 30.078 382.734 31.9341Z" fill="#1C1C1C"/>
    -<path d="M123.159 75.3333H121.045C120.92 74.7254 120.702 74.1913 120.389 73.731C120.082 73.2708 119.707 72.8844 119.264 72.5719C118.827 72.2538 118.341 72.0151 117.807 71.856C117.273 71.6969 116.716 71.6174 116.136 71.6174C115.08 71.6174 114.122 71.8844 113.264 72.4185C112.412 72.9526 111.733 73.7396 111.227 74.7793C110.727 75.8191 110.477 77.0947 110.477 78.606C110.477 80.1174 110.727 81.393 111.227 82.4327C111.733 83.4725 112.412 84.2594 113.264 84.7935C114.122 85.3276 115.08 85.5947 116.136 85.5947C116.716 85.5947 117.273 85.5151 117.807 85.356C118.341 85.1969 118.827 84.9612 119.264 84.6487C119.707 84.3305 120.082 83.9413 120.389 83.481C120.702 83.0151 120.92 82.481 121.045 81.8788H123.159C123 82.7708 122.71 83.5691 122.29 84.2737C121.869 84.9782 121.347 85.5776 120.722 86.0719C120.097 86.5606 119.395 86.9327 118.616 87.1884C117.844 87.4441 117.017 87.5719 116.136 87.5719C114.648 87.5719 113.324 87.2083 112.165 86.481C111.006 85.7538 110.094 84.7197 109.429 83.3788C108.764 82.0379 108.432 80.4469 108.432 78.606C108.432 76.7651 108.764 75.1742 109.429 73.8333C110.094 72.4924 111.006 71.4583 112.165 70.731C113.324 70.0038 114.648 69.6401 116.136 69.6401C117.017 69.6401 117.844 69.768 118.616 70.0237C119.395 70.2793 120.097 70.6543 120.722 71.1487C121.347 71.6373 121.869 72.2339 122.29 72.9384C122.71 73.6373 123 74.4356 123.159 75.3333ZM126.302 87.3333V74.2424H128.245V76.2197H128.381C128.62 75.5719 129.052 75.0464 129.677 74.643C130.302 74.2396 131.006 74.0379 131.79 74.0379C131.938 74.0379 132.123 74.0407 132.344 74.0464C132.566 74.0521 132.734 74.0606 132.847 74.0719V76.1174C132.779 76.1004 132.623 76.0748 132.379 76.0407C132.14 76.0009 131.887 75.981 131.62 75.981C130.984 75.981 130.415 76.1146 129.915 76.3816C129.421 76.643 129.029 77.0066 128.739 77.4725C128.455 77.9327 128.313 78.4583 128.313 79.0492V87.3333H126.302ZM140.322 87.606C139.06 87.606 137.972 87.3276 137.058 86.7708C136.148 86.2083 135.447 85.4242 134.952 84.4185C134.464 83.4072 134.219 82.231 134.219 80.8901C134.219 79.5492 134.464 78.3674 134.952 77.3447C135.447 76.3163 136.134 75.5151 137.015 74.9413C137.901 74.3617 138.935 74.0719 140.117 74.0719C140.799 74.0719 141.472 74.1856 142.137 74.4129C142.802 74.6401 143.407 75.0094 143.952 75.5208C144.498 76.0265 144.933 76.6969 145.256 77.5322C145.58 78.3674 145.742 79.3958 145.742 80.6174V81.4697H135.651V79.731H143.697C143.697 78.9924 143.549 78.3333 143.254 77.7538C142.964 77.1742 142.549 76.7168 142.009 76.3816C141.475 76.0464 140.844 75.8788 140.117 75.8788C139.316 75.8788 138.623 76.0776 138.038 76.4754C137.458 76.8674 137.012 77.3788 136.7 78.0094C136.387 78.6401 136.231 79.3163 136.231 80.0379V81.1969C136.231 82.1856 136.401 83.0237 136.742 83.7112C137.089 84.393 137.569 84.9129 138.183 85.2708C138.796 85.6231 139.509 85.7992 140.322 85.7992C140.85 85.7992 141.327 85.7254 141.754 85.5776C142.185 85.4242 142.558 85.1969 142.87 84.8958C143.183 84.589 143.424 84.2083 143.594 83.7538L145.538 84.2992C145.333 84.9583 144.989 85.5379 144.506 86.0379C144.023 86.5322 143.427 86.9185 142.717 87.1969C142.006 87.4697 141.208 87.606 140.322 87.606ZM152.654 87.6401C151.825 87.6401 151.072 87.4839 150.396 87.1714C149.719 86.8532 149.183 86.3958 148.785 85.7992C148.387 85.1969 148.188 84.4697 148.188 83.6174C148.188 82.8674 148.336 82.2594 148.631 81.7935C148.927 81.3219 149.322 80.9526 149.816 80.6856C150.31 80.4185 150.856 80.2197 151.452 80.089C152.055 79.9526 152.66 79.8447 153.268 79.7651C154.063 79.6629 154.708 79.5862 155.202 79.535C155.702 79.4782 156.066 79.3844 156.293 79.2538C156.526 79.1231 156.643 78.8958 156.643 78.5719V78.5038C156.643 77.6629 156.413 77.0094 155.952 76.5435C155.498 76.0776 154.808 75.8447 153.881 75.8447C152.921 75.8447 152.168 76.0549 151.623 76.4754C151.077 76.8958 150.694 77.3447 150.472 77.8219L148.563 77.1401C148.904 76.3447 149.359 75.7254 149.927 75.2822C150.501 74.8333 151.126 74.5208 151.802 74.3447C152.484 74.1629 153.154 74.0719 153.813 74.0719C154.234 74.0719 154.717 74.1231 155.262 74.2254C155.813 74.3219 156.344 74.5237 156.856 74.8305C157.373 75.1373 157.802 75.6004 158.143 76.2197C158.484 76.839 158.654 77.6685 158.654 78.7083V87.3333H156.643V85.5606H156.54C156.404 85.8447 156.177 86.1487 155.859 86.4725C155.54 86.7964 155.117 87.0719 154.589 87.2992C154.06 87.5265 153.415 87.6401 152.654 87.6401ZM152.961 85.8333C153.756 85.8333 154.427 85.6771 154.972 85.3646C155.523 85.0521 155.938 84.6487 156.217 84.1543C156.501 83.66 156.643 83.1401 156.643 82.5947V80.7538C156.558 80.856 156.37 80.9498 156.08 81.035C155.796 81.1146 155.467 81.1856 155.092 81.2481C154.722 81.3049 154.362 81.356 154.009 81.4015C153.663 81.4413 153.381 81.4754 153.165 81.5038C152.643 81.5719 152.154 81.6827 151.7 81.8362C151.251 81.9839 150.887 82.2083 150.609 82.5094C150.336 82.8049 150.2 83.2083 150.2 83.7197C150.2 84.4185 150.458 84.9469 150.975 85.3049C151.498 85.6572 152.16 85.8333 152.961 85.8333ZM168.018 74.2424V75.9469H161.234V74.2424H168.018ZM163.212 71.106H165.223V83.5833C165.223 84.1515 165.305 84.5776 165.47 84.8617C165.641 85.1401 165.857 85.3276 166.118 85.4242C166.385 85.5151 166.666 85.5606 166.962 85.5606C167.183 85.5606 167.365 85.5492 167.507 85.5265C167.649 85.4981 167.763 85.4754 167.848 85.4583L168.257 87.2651C168.121 87.3163 167.93 87.3674 167.686 87.4185C167.442 87.4754 167.132 87.5038 166.757 87.5038C166.189 87.5038 165.632 87.3816 165.087 87.1373C164.547 86.893 164.098 86.5208 163.74 86.0208C163.388 85.5208 163.212 84.8901 163.212 84.1288V71.106ZM176.392 87.606C175.131 87.606 174.043 87.3276 173.128 86.7708C172.219 86.2083 171.517 85.4242 171.023 84.4185C170.534 83.4072 170.29 82.231 170.29 80.8901C170.29 79.5492 170.534 78.3674 171.023 77.3447C171.517 76.3163 172.205 75.5151 173.085 74.9413C173.972 74.3617 175.006 74.0719 176.188 74.0719C176.869 74.0719 177.543 74.1856 178.207 74.4129C178.872 74.6401 179.477 75.0094 180.023 75.5208C180.568 76.0265 181.003 76.6969 181.327 77.5322C181.651 78.3674 181.812 79.3958 181.812 80.6174V81.4697H171.722V79.731H179.767C179.767 78.9924 179.619 78.3333 179.324 77.7538C179.034 77.1742 178.619 76.7168 178.08 76.3816C177.545 76.0464 176.915 75.8788 176.188 75.8788C175.386 75.8788 174.693 76.0776 174.108 76.4754C173.528 76.8674 173.082 77.3788 172.77 78.0094C172.457 78.6401 172.301 79.3163 172.301 80.0379V81.1969C172.301 82.1856 172.472 83.0237 172.812 83.7112C173.159 84.393 173.639 84.9129 174.253 85.2708C174.866 85.6231 175.58 85.7992 176.392 85.7992C176.92 85.7992 177.398 85.7254 177.824 85.5776C178.256 85.4242 178.628 85.1969 178.94 84.8958C179.253 84.589 179.494 84.2083 179.665 83.7538L181.608 84.2992C181.403 84.9583 181.06 85.5379 180.577 86.0379C180.094 86.5322 179.497 86.9185 178.787 87.1969C178.077 87.4697 177.278 87.606 176.392 87.606ZM189.815 87.606C188.724 87.606 187.761 87.3305 186.926 86.7793C186.091 86.2225 185.438 85.4384 184.966 84.4271C184.494 83.41 184.259 82.2083 184.259 80.8219C184.259 79.4469 184.494 78.2538 184.966 77.2424C185.438 76.231 186.094 75.4498 186.935 74.8987C187.776 74.3475 188.747 74.0719 189.849 74.0719C190.702 74.0719 191.375 74.214 191.869 74.4981C192.369 74.7765 192.75 75.0947 193.011 75.4526C193.278 75.8049 193.486 76.0947 193.634 76.3219H193.804V69.8788H195.815V87.3333H193.872V85.3219H193.634C193.486 85.5606 193.276 85.8617 193.003 86.2254C192.73 86.5833 192.341 86.9043 191.835 87.1884C191.33 87.4668 190.656 87.606 189.815 87.606ZM190.088 85.7992C190.895 85.7992 191.577 85.589 192.134 85.1685C192.69 84.7424 193.114 84.1543 193.403 83.4043C193.693 82.6487 193.838 81.7765 193.838 80.7879C193.838 79.8106 193.696 78.9555 193.412 78.2225C193.128 77.4839 192.707 76.91 192.151 76.5009C191.594 76.0862 190.906 75.8788 190.088 75.8788C189.236 75.8788 188.526 76.0975 187.957 76.535C187.395 76.9668 186.972 77.5549 186.688 78.2992C186.409 79.0379 186.27 79.8674 186.27 80.7879C186.27 81.7197 186.412 82.5663 186.696 83.3276C186.986 84.0833 187.412 84.6856 187.974 85.1344C188.543 85.5776 189.247 85.7992 190.088 85.7992ZM206.801 87.3333V69.8788H208.812V76.3219H208.983C209.131 76.0947 209.335 75.8049 209.597 75.4526C209.864 75.0947 210.244 74.7765 210.739 74.4981C211.239 74.214 211.915 74.0719 212.767 74.0719C213.869 74.0719 214.841 74.3475 215.682 74.8987C216.523 75.4498 217.179 76.231 217.651 77.2424C218.122 78.2538 218.358 79.4469 218.358 80.8219C218.358 82.2083 218.122 83.41 217.651 84.4271C217.179 85.4384 216.526 86.2225 215.69 86.7793C214.855 87.3305 213.892 87.606 212.801 87.606C211.96 87.606 211.287 87.4668 210.781 87.1884C210.276 86.9043 209.886 86.5833 209.614 86.2254C209.341 85.8617 209.131 85.5606 208.983 85.3219H208.744V87.3333H206.801ZM208.778 80.7879C208.778 81.7765 208.923 82.6487 209.213 83.4043C209.503 84.1543 209.926 84.7424 210.483 85.1685C211.04 85.589 211.722 85.7992 212.528 85.7992C213.369 85.7992 214.071 85.5776 214.634 85.1344C215.202 84.6856 215.628 84.0833 215.912 83.3276C216.202 82.5663 216.347 81.7197 216.347 80.7879C216.347 79.8674 216.205 79.0379 215.92 78.2992C215.642 77.5549 215.219 76.9668 214.651 76.535C214.088 76.0975 213.381 75.8788 212.528 75.8788C211.71 75.8788 211.023 76.0862 210.466 76.5009C209.909 76.91 209.489 77.4839 209.205 78.2225C208.92 78.9555 208.778 79.8106 208.778 80.7879ZM222.261 92.2424C221.92 92.2424 221.616 92.214 221.349 92.1572C221.082 92.106 220.898 92.0549 220.795 92.0038L221.307 90.231C221.795 90.356 222.227 90.4015 222.602 90.3674C222.977 90.3333 223.31 90.1657 223.599 89.8646C223.895 89.5691 224.165 89.089 224.409 88.4242L224.784 87.4015L219.943 74.2424H222.125L225.739 84.6742H225.875L229.489 74.2424H231.67L226.114 89.2424C225.864 89.9185 225.554 90.4782 225.185 90.9214C224.815 91.3702 224.386 91.7026 223.898 91.9185C223.415 92.1344 222.869 92.2424 222.261 92.2424ZM241.348 87.3333V69.8788H243.462V85.4583H251.575V87.3333H241.348ZM254.575 87.3333V74.2424H256.587V87.3333H254.575ZM255.598 72.0606C255.206 72.0606 254.868 71.9271 254.584 71.66C254.305 71.393 254.166 71.0719 254.166 70.6969C254.166 70.3219 254.305 70.0009 254.584 69.7339C254.868 69.4668 255.206 69.3333 255.598 69.3333C255.99 69.3333 256.325 69.4668 256.604 69.7339C256.888 70.0009 257.03 70.3219 257.03 70.6969C257.03 71.0719 256.888 71.393 256.604 71.66C256.325 71.9271 255.99 72.0606 255.598 72.0606ZM265.555 92.5151C264.583 92.5151 263.748 92.3901 263.049 92.1401C262.35 91.8958 261.768 91.5719 261.302 91.1685C260.842 90.7708 260.475 90.3447 260.202 89.8901L261.805 88.7651C261.987 89.0038 262.217 89.2765 262.495 89.5833C262.773 89.8958 263.154 90.1657 263.637 90.393C264.126 90.6259 264.765 90.7424 265.555 90.7424C266.612 90.7424 267.484 90.4867 268.171 89.9754C268.859 89.464 269.202 88.6629 269.202 87.5719V84.9129H269.032C268.884 85.1515 268.674 85.4469 268.401 85.7992C268.134 86.1458 267.748 86.4555 267.242 86.7282C266.742 86.9952 266.066 87.1288 265.214 87.1288C264.157 87.1288 263.208 86.8788 262.367 86.3788C261.532 85.8788 260.87 85.1515 260.381 84.1969C259.898 83.2424 259.657 82.0833 259.657 80.7197C259.657 79.3788 259.893 78.2112 260.364 77.2168C260.836 76.2168 261.492 75.4441 262.333 74.8987C263.174 74.3475 264.146 74.0719 265.248 74.0719C266.1 74.0719 266.776 74.214 267.276 74.4981C267.782 74.7765 268.168 75.0947 268.435 75.4526C268.708 75.8049 268.918 76.0947 269.066 76.3219H269.271V74.2424H271.214V87.7083C271.214 88.8333 270.958 89.7481 270.447 90.4526C269.941 91.1629 269.259 91.6827 268.401 92.0123C267.549 92.3475 266.6 92.5151 265.555 92.5151ZM265.487 85.3219C266.293 85.3219 266.975 85.1373 267.532 84.768C268.089 84.3987 268.512 83.8674 268.802 83.1742C269.092 82.481 269.237 81.6515 269.237 80.6856C269.237 79.7424 269.094 78.91 268.81 78.1884C268.526 77.4668 268.106 76.9015 267.549 76.4924C266.992 76.0833 266.305 75.8788 265.487 75.8788C264.634 75.8788 263.924 76.0947 263.356 76.5265C262.793 76.9583 262.37 77.5379 262.086 78.2651C261.808 78.9924 261.668 79.7992 261.668 80.6856C261.668 81.5947 261.81 82.3987 262.094 83.0975C262.384 83.7907 262.81 84.3362 263.373 84.7339C263.941 85.1259 264.646 85.3219 265.487 85.3219ZM276.907 79.4583V87.3333H274.896V69.8788H276.907V76.2879H277.077C277.384 75.6117 277.844 75.0748 278.458 74.6771C279.077 74.2737 279.901 74.0719 280.93 74.0719C281.822 74.0719 282.603 74.2509 283.273 74.6089C283.944 74.9612 284.464 75.5038 284.833 76.2367C285.208 76.964 285.396 77.8901 285.396 79.0151V87.3333H283.384V79.1515C283.384 78.1117 283.114 77.3077 282.575 76.7396C282.04 76.1657 281.299 75.8788 280.35 75.8788C279.691 75.8788 279.1 76.018 278.577 76.2964C278.06 76.5748 277.651 76.981 277.35 77.5151C277.055 78.0492 276.907 78.6969 276.907 79.4583ZM294.768 74.2424V75.9469H287.984V74.2424H294.768ZM289.962 71.106H291.973V83.5833C291.973 84.1515 292.055 84.5776 292.22 84.8617C292.391 85.1401 292.607 85.3276 292.868 85.4242C293.135 85.5151 293.416 85.5606 293.712 85.5606C293.933 85.5606 294.115 85.5492 294.257 85.5265C294.399 85.4981 294.513 85.4754 294.598 85.4583L295.007 87.2651C294.871 87.3163 294.68 87.3674 294.436 87.4185C294.192 87.4754 293.882 87.5038 293.507 87.5038C292.939 87.5038 292.382 87.3816 291.837 87.1373C291.297 86.893 290.848 86.5208 290.49 86.0208C290.138 85.5208 289.962 84.8901 289.962 84.1288V71.106ZM299.805 79.4583V87.3333H297.794V74.2424H299.737V76.2879H299.908C300.214 75.6231 300.68 75.089 301.305 74.6856C301.93 74.2765 302.737 74.0719 303.726 74.0719C304.612 74.0719 305.388 74.2538 306.053 74.6174C306.717 74.9754 307.234 75.5208 307.604 76.2538C307.973 76.981 308.158 77.9015 308.158 79.0151V87.3333H306.146V79.1515C306.146 78.1231 305.879 77.3219 305.345 76.7481C304.811 76.1685 304.078 75.8788 303.146 75.8788C302.504 75.8788 301.93 76.018 301.425 76.2964C300.925 76.5748 300.53 76.981 300.24 77.5151C299.95 78.0492 299.805 78.6969 299.805 79.4583ZM311.833 87.3333V74.2424H313.844V87.3333H311.833ZM312.856 72.0606C312.464 72.0606 312.126 71.9271 311.842 71.66C311.563 71.393 311.424 71.0719 311.424 70.6969C311.424 70.3219 311.563 70.0009 311.842 69.7339C312.126 69.4668 312.464 69.3333 312.856 69.3333C313.248 69.3333 313.583 69.4668 313.862 69.7339C314.146 70.0009 314.288 70.3219 314.288 70.6969C314.288 71.0719 314.146 71.393 313.862 71.66C313.583 71.9271 313.248 72.0606 312.856 72.0606ZM319.54 79.4583V87.3333H317.528V74.2424H319.472V76.2879H319.642C319.949 75.6231 320.415 75.089 321.04 74.6856C321.665 74.2765 322.472 74.0719 323.46 74.0719C324.347 74.0719 325.122 74.2538 325.787 74.6174C326.452 74.9754 326.969 75.5208 327.338 76.2538C327.707 76.981 327.892 77.9015 327.892 79.0151V87.3333H325.881V79.1515C325.881 78.1231 325.614 77.3219 325.08 76.7481C324.545 76.1685 323.813 75.8788 322.881 75.8788C322.239 75.8788 321.665 76.018 321.159 76.2964C320.659 76.5748 320.264 76.981 319.974 77.5151C319.685 78.0492 319.54 78.6969 319.54 79.4583ZM336.852 92.5151C335.88 92.5151 335.045 92.3901 334.346 92.1401C333.647 91.8958 333.065 91.5719 332.599 91.1685C332.138 90.7708 331.772 90.3447 331.499 89.8901L333.102 88.7651C333.283 89.0038 333.513 89.2765 333.792 89.5833C334.07 89.8958 334.451 90.1657 334.934 90.393C335.423 90.6259 336.062 90.7424 336.852 90.7424C337.908 90.7424 338.781 90.4867 339.468 89.9754C340.156 89.464 340.499 88.6629 340.499 87.5719V84.9129H340.329C340.181 85.1515 339.971 85.4469 339.698 85.7992C339.431 86.1458 339.045 86.4555 338.539 86.7282C338.039 86.9952 337.363 87.1288 336.511 87.1288C335.454 87.1288 334.505 86.8788 333.664 86.3788C332.829 85.8788 332.167 85.1515 331.678 84.1969C331.195 83.2424 330.954 82.0833 330.954 80.7197C330.954 79.3788 331.19 78.2112 331.661 77.2168C332.133 76.2168 332.789 75.4441 333.63 74.8987C334.471 74.3475 335.442 74.0719 336.545 74.0719C337.397 74.0719 338.073 74.214 338.573 74.4981C339.079 74.7765 339.465 75.0947 339.732 75.4526C340.005 75.8049 340.215 76.0947 340.363 76.3219H340.567V74.2424H342.511V87.7083C342.511 88.8333 342.255 89.7481 341.744 90.4526C341.238 91.1629 340.556 91.6827 339.698 92.0123C338.846 92.3475 337.897 92.5151 336.852 92.5151ZM336.783 85.3219C337.59 85.3219 338.272 85.1373 338.829 84.768C339.386 84.3987 339.809 83.8674 340.099 83.1742C340.388 82.481 340.533 81.6515 340.533 80.6856C340.533 79.7424 340.391 78.91 340.107 78.1884C339.823 77.4668 339.403 76.9015 338.846 76.4924C338.289 76.0833 337.602 75.8788 336.783 75.8788C335.931 75.8788 335.221 76.0947 334.653 76.5265C334.09 76.9583 333.667 77.5379 333.383 78.2651C333.104 78.9924 332.965 79.7992 332.965 80.6856C332.965 81.5947 333.107 82.3987 333.391 83.0975C333.681 83.7907 334.107 84.3362 334.67 84.7339C335.238 85.1259 335.942 85.3219 336.783 85.3219ZM353.931 87.3333H351.715L358.124 69.8788H360.306L366.715 87.3333H364.499L359.283 72.6401H359.147L353.931 87.3333ZM354.749 80.5151H363.681V82.3901H354.749V80.5151ZM371.548 69.8788V87.3333H369.434V69.8788H371.548Z" fill="#4F4F4F"/>
    -<defs>
    -<linearGradient id="paint0_linear_402_129" x1="62.0319" y1="31.7357" x2="-41.4197" y2="127.346" gradientUnits="userSpaceOnUse">
    -<stop stop-color="#792EE5"/>
    -<stop offset="1" stop-color="#428FF4"/>
    -</linearGradient>
    -<clipPath id="clip0_402_129">
    -<rect width="86.6667" height="100" fill="white" transform="translate(0.0118408 0.985229)"/>
    -</clipPath>
    -<clipPath id="clip1_402_129">
    -<rect width="48.6667" height="48.6667" fill="white" transform="translate(19.0118 26.6519)"/>
    -</clipPath>
    -</defs>
    -</svg>
    
  • docs/source-app/_static/main.css+0 3 removed
    @@ -1,3 +0,0 @@
    -col {
    -  width: 50% !important;
    -}
    
  • docs/source-app/_templates/classtemplate_no_index.rst+0 12 removed
    @@ -1,12 +0,0 @@
    -:orphan:
    -
    -.. role:: hidden
    -    :class: hidden-section
    -.. currentmodule:: {{ module }}
    -
    -
    -{{ name | underline }}
    -
    -.. autoclass:: {{ name }}
    -    :members:
    -    :noindex:
    
  • docs/source-app/_templates/classtemplate.rst+0 9 removed
    @@ -1,9 +0,0 @@
    -.. role:: hidden
    -    :class: hidden-section
    -.. currentmodule:: {{ module }}
    -
    -
    -{{ name | underline }}
    -
    -.. autoclass:: {{ name }}
    -    :members:
    
  • docs/source-app/_templates/layout.html+0 16 removed
    @@ -1,16 +0,0 @@
    -{% extends "!layout.html" %}
    -<link rel="canonical" href="{{ theme_canonical_url }}{{ pagename }}.html" />
    -
    -{% block footer %} {{ super() }}
    -<script script type="text/javascript">
    -  var collapsedSections = [
    -    "App Building Skills",
    -    "Practical Examples",
    -    "Common Workflows",
    -    "Core API Reference",
    -    "Addons API Reference",
    -    "Glossary",
    -  ];
    -</script>
    -
    -{% endblock %}
    
  • docs/source-app/_templates/theme_variables.jinja+0 18 removed
    @@ -1,18 +0,0 @@
    -{%- set external_urls = {
    -  'github': 'https://github.com/Lightning-AI/lightning',
    -  'github_issues': 'https://github.com/Lightning-AI/lightning/issues',
    -  'contributing': 'https://github.com/Lightning-AI/lightning/blob/master/.github/CONTRIBUTING.md',
    -  'governance': 'https://github.com/Lightning-AI/lightning/blob/master/docs/source-pytorch/governance.rst',
    -  'docs': 'https://lightning.rtfd.io/en/latest',
    -  'twitter': 'https://twitter.com/PyTorchLightnin',
    -  'discuss': 'https://discord.gg/VptPCZkGNa',
    -  'tutorials': 'https://pt-lightning.readthedocs.io/en/latest/#tutorials',
    -  'previous_pytorch_versions': 'https://pt-lightning.rtfd.io/en/latest/',
    -  'home': 'https://lightning.ai/',
    -  'get_started': 'https://pt-lightning.readthedocs.io/en/latest/introduction_guide.html',
    -  'features': 'https://pt-lightning.rtfd.io/en/latest/',
    -  'blog': 'https://www.pytorchlightning.ai/blog',
    -  'resources': 'https://pt-lightning.readthedocs.io/en/latest/#community-examples',
    -  'support': 'https://pt-lightning.rtfd.io/en/latest/',
    -}
    --%}
    
  • docs/source-app/testing.rst+0 155 removed
    @@ -1,155 +0,0 @@
    -:orphan:
    -
    -.. _testing:
    -
    -#######################
    -Productionize your Apps
    -#######################
    -
    -.. TODO: Cleanup
    -
    -At the core of our system is an integration testing framework that will allow for a first-class experience creating integration tests for Lightning Apps. This document will explain how we can create a lightning app test, how we can execute it, and where to find more information.
    -
    -----
    -
    -***********
    -Philosophy
    -***********
    -
    -Testing a Lightning app is unique. It is a superset of an application that converges machine learning, API development, and UI development. With that in mind, there are several philosophies (or "best practices") that you should adhere to:
    -
    -
    -#. **Control your app state** - With integration and end to end tests, you have the capabilities of controlling your app's state through dependency injection. Use it!
    -#. **Integration focuses on the work, End to End focuses on the app** - When writing tests, think of the depth and breath of what you are writing. Write many integration tests since they are relatively cheap, while keeping the end to end tests for holistic app testing.
    -#. **Don't overthink it** - What needs to be tested? What is the order of risk? These are the questions you should build with before writing your first line of code. Writing tests for the sake of writing tests is an exercise in futility. Write meaningful, impactful tests.
    -#. **Test Isolation** - Write your tests in an isolated manner. No two tests should ever depend on each other.
    -#. **Use your framework** - Testing apps should be framework agnostic.
    -#. **Have fun!** - At the heart of testing is experimentation. Like any experiment, tests begin with a hypothesis of workability, but you can extend that to be more inclusive. Ask the question, write the test to answer your question, and make sure you have fun while doing it.
    -
    -----
    -
    -****************************************
    -Anatomy of a Lightning integration test
    -****************************************
    -
    -The following is a PyTest example of an integration test using the ``lightning.app.testing`` module.
    -
    -.. code-block:: python
    -
    -   import os
    -
    -   from lightning.app import _PROJECT_ROOT
    -   from lightning.app.testing import application_testing, LightningTestApp
    -   from lightning.app.utilities.enum import AppStage
    -
    -
    -   class TestLightningAppInt(TestLightningApp):
    -       def run_once(self) -> bool:
    -           if self.root.counter > 1:
    -               print("V0 App End")
    -               self.stage = AppStage.STOPPING
    -               return True
    -           return super().run_once()
    -
    -
    -   def test_v0_app_example():
    -       command_line = [
    -           os.path.join(_PROJECT_ROOT, "examples/app_v0/app.py"),
    -           "--blocking",
    -           "False",
    -           "--multiprocess",
    -           "--open-ui",
    -           "False",
    -       ]
    -       result = application_testing(TestLightningAppInt, command_line)
    -       assert "V0 App End" in str(result.stdout_bytes)
    -       assert result.exit_code == 0
    -
    -----
    -
    -Setting up the app
    -^^^^^^^^^^^^^^^^^^
    -
    -Lightning apps are unique in that they represent a full stack model for your machine learning application. To be clear, the integration tests are *NOT* going to touch the UI flow. Instead we inject your application with helper methods that, when executed, can assist in validating your application.
    -
    -To get started, you simply need to import the following:
    -
    -.. code-block:: python
    -
    -    from lightning.app.testing import application_testing, LightningTestApp
    -
    -We will discuss ``application_testing`` in a bit, but first let's review the structure of ``LightningTestApp``.
    -
    -----
    -
    -LightningTestApp
    -^^^^^^^^^^^^^^^^^
    -
    -The :class:`lightning.app.testing.testing.LightningTestApp` class is available to use for provisioning and setting up your testing needs. Note that you do not need this class to move forward with testing. Any application that inherits ``LightningApp`` should suffice as long as you override the correct methods. Reviewing the TestLightnigApp we see some overrides that are already there. Please revuew the class for more information.
    -
    -.. code-block:: python
    -
    -   class TestLightningAppInt(LightningTestApp):
    -       def run_once(self) -> bool:
    -           if self.root.counter > 1:
    -               print("V0 App End")
    -               self.stage = AppStage.STOPPING
    -               return True
    -           return super().run_once()
    -
    -We create a test class overriding the ``run_once`` function. This function helps control the flow of your application and is ran first. In this example we are calling ``self.root.counter`` and checking if the job has executed once. If so, we want to print out ``V0 App End`` and set the ``self.stage`` to ``AppStage.STOPPING``. This is how we control the flow through state. Your situation might be different, so experiment and see what you can do!
    -
    -Besides ``run_once`` there are a few other overrides available:
    -
    -
    -* ``on_before_run_once`` - This runs before your ``run_once`` function kicks off. You can set up your application pre-conditions here.
    -* ``on_after_run_once`` - Similar to ``on_before_run_once`` but after the ``run_once`` method is called.
    -
    -These methods will skew your tests, so use them when needed.
    -
    -----
    -
    -The Test
    -^^^^^^^^
    -
    -We provide ``application_testing`` as a helper function to get your application up and running for testing. It uses ``click``\ 's invocation tooling underneath.
    -
    -.. code-block::
    -
    -   command_line = [
    -       os.path.join(_PROJECT_ROOT, "examples/app_v0/app.py"),
    -       "--blocking",
    -       "False",
    -       "--open-ui",
    -       "False",
    -   ]
    -
    -First in the list for ``command_line`` is the location of your script. It is an external file. In this example we have ``_PROJECT_ROOT`` but this is *not* a helper constant for you to utilize. You will need to provide the location yourself.
    -
    -Next there are a couple of options you can leverage:
    -
    -* ``blocking`` - Blocking is an app status that says "Do not run until I click run in the UI". For our integration test, since we are not using the UI, we are setting this to "False".
    -* ``open-ui`` - We set this to false since this is the routine that opens a browser for your local execution.
    -
    -Once you have your commandline ready, you will then be able to kick off the test and gather results:
    -
    -.. code-block:: python
    -
    -   result = application_testing(TestLightningAppInt, command_line)
    -
    -As mentioned earlier, ``application_testing`` is a helper method that allows you to inject your TestLightningApp class (with overrides) and the commandline flags. Once the process is done it returns the results back for parsing.
    -
    -.. code-block:: python
    -
    -   assert "V0 App End" in str(result.stdout_bytes)
    -   assert result.exit_code == 0
    -
    -Since we injected "V0 App End" to the end of our test flow. The state was changed to ``AppStatus.STOPPING`` which means the process is done. Finally, we check the result's exit code to make sure that we did not throw an error during execution.
    -
    -----
    -
    -************
    -End to End
    -************
    -
    -TODO
    
  • docs/source-app/ui_and_frontends.rst+0 23 removed
    @@ -1,23 +0,0 @@
    -:orphan:
    -
    -.. _ui_and_frontends:
    -
    -################
    -UI and Frontends
    -################
    -
    -
    -The Lightning framework allows you to create customized, interactive UIs with the framework of your choice.
    -
    -You can easily embed other tools and services (like a GitHub repo, a `FastAPI Service <https://fastapi.tiangolo.com/>`_, an `arXiv <https://arxiv.org/>`_ paper or a `Dask Cluster <https://docs.dask.org/en/stable/>`_ Admin page), or create a complete UI from scratch.
    -
    -
    -To get started, you can use built-in templates for the following frameworks:
    -
    -* `React.js <https://github.com/Lightning-AI/lightning-template-react>`_
    -* `StreamLit <https://github.com/Lightning-Universe/StreamLit_demo>`_
    -
    -
    -
    -To keep learning about Lightning, check out :ref:`moving_to_the_cloud`.
    -This section covers best practices to seamlessly make your Lightning code work both locally and in the cloud.
    
  • docs/source-app/workflows/access_app_state.rst+0 59 removed
    @@ -1,59 +0,0 @@
    -.. _access_app_state:
    -
    -################
    -Access App State
    -################
    -
    -**Audience:** Users who want to know how the App State can be accessed.
    -
    -**Level:** Basic
    -
    -**********************
    -What is the App State?
    -**********************
    -
    -In Lightning, each component is stateful and their state is composed of all attributes defined within their **__init__** method.
    -
    -The **App State** is the collection of all the components' states forming the App.
    -
    -************************************
    -What is special about the App State?
    -************************************
    -
    -The **App State** is always up-to-date, even running an App in the cloud on multiple machines.
    -This means that every time an attribute is modified in a Work, that information is automatically
    -broadcasted to the Flow. With this mechanism, any Component can **react** to any other
    -Component's **state changes** through the Flow and complex systems can be easily implemented.
    -Lightning requires a state based driven mindset when implementing the Flow.
    -
    -***************************************
    -When do I need to access the App State?
    -***************************************
    -
    -As a user, you are interacting with your component attributes, so most likely,
    -you won't need to access the Component's state directly, but it can be helpful to
    -understand how the state works under the hood.
    -
    -For example, here we define a **Flow** component and **Work** component, where the Work increments a counter indefinitely and the Flow prints its state which contains the Work.
    -
    -You can easily check the state of your entire App as follows:
    -
    -.. literalinclude:: ../code_samples/quickstart/app_01.py
    -
    -Run the App with:
    -
    -.. code-block:: bash
    -
    -    lightning run app docs/quickstart/app_01.py
    -
    -And here's the output you get when running the App using **Lightning CLI**:
    -
    -.. code-block:: console
    -
    -    INFO: Your app has started. View it in your browser: http://127.0.0.1:7501/view
    -    State: {'works': {'w': {'vars': {'counter': 1}}}}
    -    State: {'works': {'w': {'vars': {'counter': 2}}}}
    -    State: {'works': {'w': {'vars': {'counter': 3}}}}
    -    State: {'works': {'w': {'vars': {'counter': 3}}}}
    -    State: {'works': {'w': {'vars': {'counter': 4}}}}
    -    ...
    
  • docs/source-app/workflows/add_components.rst+0 31 removed
    @@ -1,31 +0,0 @@
    -:orphan:
    -
    -###########################
    -Add a component to your app
    -###########################
    -**Audience:** Users looking to expand the functionality of their Lightning apps.
    -
    -----
    -
    -*******************
    -Install a component
    -*******************
    -
    -Any Lightning component can be installed with:
    -
    -.. code:: python
    -
    -   lightning install component org/the-component-name
    -
    -`Browse all community-built components here <https://lightning.ai/components>`_.
    -
    -.. note:: Components are being populated daily
    -
    -----
    -
    -**********************
    -Contribute a component
    -**********************
    -One of the first principles of the Lightning community is to code something *once* for the benefit or everyone!
    -
    -To contribute a component, :doc:`follow this guide <build_lightning_component/index>`.
    
  • docs/source-app/workflows/add_server/any_server.rst+0 187 removed
    @@ -1,187 +0,0 @@
    -#########################
    -Enable any server (basic)
    -#########################
    -**Audience:** Users who want to enable an arbitrary server/UI.
    -
    -**Prereqs:** Basic python knowledge.
    -
    -----
    -
    -*****************
    -What is a server?
    -*****************
    -A server is a program that enables other programs or users to connect to it. As long as your server can listen on a port,
    -you can enable it with a Lightning App.
    -
    -----
    -
    -***************************
    -Add a server to a component
    -***************************
    -Any server that listens on a port, can be enabled via a work. For example, here's a plain python server:
    -
    -.. code:: python
    -    :emphasize-lines: 11-12
    -
    -    import socketserver
    -    from http import HTTPStatus, server
    -
    -
    -    class PlainServer(server.SimpleHTTPRequestHandler):
    -        def do_GET(self):
    -            self.send_response(HTTPStatus.OK)
    -            self.end_headers()
    -            # Data must be passed as bytes to the `self.wfile.write` call
    -            html = b"<h1 style='color: blue'> Hello lit world </div>"
    -            self.wfile.write(html)
    -
    -
    -    httpd = socketserver.TCPServer(("localhost", "3000"), PlainServer)
    -    httpd.serve_forever()
    -
    -To enable the server inside the component, start the server in the run method and use the ``self.host`` and ``self.port`` properties:
    -
    -.. code:: python
    -    :emphasize-lines: 14-15
    -
    -    import lightning as L
    -    import socketserver
    -    from http import HTTPStatus, server
    -
    -
    -    class PlainServer(server.SimpleHTTPRequestHandler):
    -        def do_GET(self):
    -            self.send_response(HTTPStatus.OK)
    -            self.end_headers()
    -            # Data must be passed as bytes to the `self.wfile.write` call
    -            html = b"<h1 style='color: blue'> Hello lit world </div>"
    -            self.wfile.write(html)
    -
    -
    -    class LitServer(L.LightningWork):
    -        def run(self):
    -            httpd = socketserver.TCPServer((self.host, self.port), PlainServer)
    -            httpd.serve_forever()
    -
    -----
    -
    -**************************************
    -Route the server in the root component
    -**************************************
    -The final step, is to tell the Root component in which tab to render this component's output:
    -In this case, we render the ``LitServer`` output in the ``home`` tab of the application.
    -
    -.. code:: python
    -    :emphasize-lines: 20, 23, 28
    -
    -    import lightning as L
    -    import socketserver
    -    from http import HTTPStatus, server
    -
    -
    -    class PlainServer(server.SimpleHTTPRequestHandler):
    -        def do_GET(self):
    -            self.send_response(HTTPStatus.OK)
    -            self.end_headers()
    -            # Data must be passed as bytes to the `self.wfile.write` call
    -            html = b"<h1 style='color: blue'> Hello lit world </div>"
    -            self.wfile.write(html)
    -
    -
    -    class LitServer(L.LightningWork):
    -        def run(self):
    -            httpd = socketserver.TCPServer((self.host, self.port), PlainServer)
    -            httpd.serve_forever()
    -
    -
    -    class Root(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.lit_server = LitServer(parallel=True)
    -
    -        def run(self):
    -            self.lit_server.run()
    -
    -        def configure_layout(self):
    -            tab1 = {"name": "home", "content": self.lit_server}
    -            return tab1
    -
    -
    -    app = L.LightningApp(Root())
    -
    -We use the ``parallel=True`` argument of ``LightningWork`` to run the server in parallel
    -while the rest of the Lightning App runs everything else.
    -
    -----
    -
    -***********
    -Run the app
    -***********
    -Start the app to see your new UI!
    -
    -.. code:: bash
    -
    -    lightning_app run app app.py
    -
    -To run the app on the cloud, use the ``--cloud`` argument.
    -
    -.. code:: bash
    -
    -    lightning_app run app app.py --cloud
    -
    -----
    -
    -*****************************************
    -Interact with a component from the server
    -*****************************************
    -
    -.. TODO:: how do we do this?
    -
    -
    -----
    -
    -*****************************************
    -Interact with the server from a component
    -*****************************************
    -
    -.. TODO:: how do we do this?
    -
    -----
    -
    -********
    -Examples
    -********
    -Here are a few example apps that expose a server via a component:
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: Example: Tensorboard
    -   :description: TODO
    -   :col_css: col-md-4
    -   :button_link: example_app.html
    -   :height: 150
    -
    -.. displayitem::
    -   :header: Example: Streamlit
    -   :description: TODO
    -   :col_css: col-md-4
    -   :button_link: example_app.html
    -   :height: 150
    -
    -.. displayitem::
    -   :header: Example: React
    -   :description: TODO
    -   :col_css: col-md-4
    -   :button_link: example_app.html
    -   :height: 150
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/workflows/add_server/flask_basic.rst+0 155 removed
    @@ -1,155 +0,0 @@
    -###############################
    -Add a web UI with Flask (basic)
    -###############################
    -**Audience:** Users who want to enable a flask app within a component.
    -
    -**Prereqs:** Basic python knowledge.
    -
    -----
    -
    -**************
    -What is Flask?
    -**************
    -Flask is a web framework, that lets you develop web applications in Python easily.
    -
    -----
    -
    -************************
    -Add Flask to a component
    -************************
    -First, define your flask app as you normally would without Lightning:
    -
    -.. code:: python
    -    :emphasize-lines: 9
    -
    -    from flask import Flask
    -
    -    flask_app = Flask(__name__)
    -
    -
    -    @flask_app.route("/")
    -    def hello():
    -        return "Hello, World!"
    -
    -
    -    flask_app.run(host="0.0.0.0", port=80)
    -
    -To enable the server inside the component, start the Flask server in the run method and use the ``self.host`` and ``self.port`` properties:
    -
    -.. code:: python
    -    :emphasize-lines: 12
    -
    -    import lightning as L
    -    from flask import Flask
    -
    -
    -    class LitFlask(L.LightningWork):
    -        def run(self):
    -            flask_app = Flask(__name__)
    -
    -            @flask_app.route("/")
    -            def hello():
    -                return "Hello, World!"
    -
    -            flask_app.run(host=self.host, port=self.port)
    -
    -----
    -
    -**************************************
    -Route the server in the root component
    -**************************************
    -The final step, is to tell the Root component in which tab to render this component's output:
    -In this case, we render the ``LitFlask`` output in the ``home`` tab of the application.
    -
    -.. code:: python
    -    :emphasize-lines: 17, 23
    -
    -    import lightning as L
    -    from flask import Flask
    -
    -
    -    class LitFlask(L.LightningWork):
    -        def run(self):
    -            flask_app = Flask(__name__)
    -
    -            @flask_app.route("/")
    -            def hello():
    -                return "Hello, World!"
    -
    -            flask_app.run(host=self.host, port=self.port)
    -
    -
    -    class Root(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.lit_flask = LitFlask(parallel=True)
    -
    -        def run(self):
    -            self.lit_flask.run()
    -
    -        def configure_layout(self):
    -            tab1 = {"name": "home", "content": self.lit_flask}
    -            return tab1
    -
    -
    -    app = L.LightningApp(Root())
    -
    -We use the ``parallel=True`` argument of ``LightningWork`` to run the server in the background
    -while the rest of the Lightning App runs everything else.
    -
    -----
    -
    -***********
    -Run the app
    -***********
    -Start the app to see your new UI!
    -
    -.. code:: bash
    -
    -    lightning run app app.py
    -
    -To run the app on the cloud, use the ``--cloud`` argument.
    -
    -.. code:: bash
    -
    -    lightning run app app.py --cloud
    -
    -----
    -
    -********
    -Examples
    -********
    -Here are a few example apps that expose a Flask server via a component:
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: Example 1
    -   :description: TODO
    -   :col_css: col-md-4
    -   :button_link: example_app.html
    -   :height: 150
    -
    -.. displayitem::
    -   :header: Example 2
    -   :description: TODO
    -   :col_css: col-md-4
    -   :button_link: example_app.html
    -   :height: 150
    -
    -.. displayitem::
    -   :header: Example 3
    -   :description: TODO
    -   :col_css: col-md-4
    -   :button_link: example_app.html
    -   :height: 150
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/workflows/add_server/index_content.rst+0 35 removed
    @@ -1,35 +0,0 @@
    -.. toctree::
    -   :maxdepth: 1
    -   :hidden:
    -
    -   any_server
    -   flask_basic
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: Any server
    -   :description: Learn how to enable any server inside a Lightning App.
    -   :col_css: col-md-6
    -   :button_link: any_server.html
    -   :height: 150
    -   :tag: basic
    -
    -.. displayitem::
    -   :header: Flask
    -   :description: Learn how to add a Flask server inside a Lightning App.
    -   :col_css: col-md-6
    -   :button_link: flask_basic.html
    -   :height: 150
    -   :tag: basic
    -
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/workflows/add_server/index.rst+0 8 removed
    @@ -1,8 +0,0 @@
    -###################################
    -Run a server within a Lightning App
    -###################################
    -Any type of server can run inside a Lightning App.
    -
    -----
    -
    -.. include:: index_content.rst
    
  • docs/source-app/workflows/add_web_link.rst+0 54 removed
    @@ -1,54 +0,0 @@
    -##############
    -Add a web link
    -##############
    -**Audience:** Users who want to link to other pages from their app.
    -
    -----
    -
    -**************
    -Add a url link
    -**************
    -In this example we'll replicate |urls_link|.
    -
    -To add a url link to an app, simply specify it in the ``configure_layout`` method
    -and connect the UIs. Create a file named **app.py** with this code:
    -
    -.. |urls_link| raw:: html
    -
    -   <a href="https://01g3ppzb6t3pp5cf1zhg8shpym.litng-ai-03.litng.ai/view/TB%20logs" target="_blank">the app running here</a>
    -
    -.. code:: python
    -    :emphasize-lines: 7,11
    -
    -    import lightning as L
    -
    -    class LitApp(L.LightningFlow):
    -        def configure_layout(self):
    -            tab_1 = {
    -                "name": "Logger",
    -                "content": "https://bit.ly/tb-aasae"
    -            }
    -            tab_2 = {
    -                "name": "Paper",
    -                "content": "https://arxiv.org/pdf/2107.12329.pdf"
    -            }
    -            return tab_1, tab_2
    -
    -    app = L.LightningApp(LitApp())
    -
    -----
    -
    -***********
    -Run the app
    -***********
    -Run the app locally to see it!
    -
    -.. code:: python
    -
    -    lightning run app app.py
    -
    -Now run it on the cloud as well:
    -
    -.. code:: python
    -
    -    lightning run app app.py --cloud
    
  • docs/source-app/workflows/add_web_ui/angular_js_intermediate.rst+0 6 removed
    @@ -1,6 +0,0 @@
    -:orphan:
    -
    -###########################################
    -Add a web UI with Angular.js (intermediate)
    -###########################################
    -coming...
    
  • docs/source-app/workflows/add_web_ui/dash/basic.rst+0 221 removed
    @@ -1,221 +0,0 @@
    -##############################
    -Add a web UI with Dash (basic)
    -##############################
    -**Audience:** Users who want to add a web UI with Dash by Plotly.
    -
    -**Prereqs:** Basic python knowledge.
    -
    -----
    -
    -*************
    -What is Dash?
    -*************
    -`Dash <https://plotly.com/dash/>`_ is the original low-code framework for rapidly building data apps in Python, R, Julia, and F# (experimental).
    -
    -Install Dash with:
    -
    -.. code:: bash
    -
    -    pip install dash
    -
    -----
    -
    -************************
    -Create the dash demo app
    -************************
    -
    -To explain how to use Dash with Lightning, let's build a simple app with Dash.
    -
    -
    -..
    -    To explain how to use Dash with Lightning, let's replicate the |dash_link|.
    -
    -    .. |dash_link| raw:: html
    -
    -       <a href="https://01g3p4bf3m61xsm2yzn0966q59.litng-ai-03.litng.ai/view/home" target="_blank">example running here</a>
    -
    -In the next few sections we'll build an app step-by-step.
    -First **create a file named app.py** with the app content:
    -
    -.. code:: bash
    -
    -        import lightning as L
    -        import dash
    -        import plotly.express as px
    -
    -        class LitDash(L.LightningWork):
    -            def run(self):
    -                dash_app = dash.Dash(__name__)
    -                X = [1, 2, 3, 4, 5, 6]
    -                Y = [2, 4, 8, 16, 32, 64]
    -                fig = px.line(x=X, y=Y)
    -
    -                dash_app.layout = dash.html.Div(children=[
    -                    dash.html.H1(children='⚡ Hello Dash + Lightning⚡'),
    -                    dash.html.Div(children='The Dash framework running inside a ⚡ Lightning App'),
    -                    dash.dcc.Graph(id='example-graph', figure=fig)
    -                ])
    -
    -                dash_app.run_server(host=self.host, port=self.port)
    -
    -        class LitApp(L.LightningFlow):
    -            def __init__(self):
    -                super().__init__()
    -                self.lit_dash = LitDash(parallel=True)
    -
    -            def run(self):
    -                self.lit_dash.run()
    -
    -            def configure_layout(self):
    -                tab1 = {"name": "home", "content": self.lit_dash}
    -                return tab1
    -
    -        app = L.LightningApp(LitApp())
    -
    -
    -add 'dash' to a requirements.txt file:
    -
    -.. code:: bash
    -
    -    echo "dash" >> requirements.txt
    -
    -this is a best practice to make apps reproducible.
    -
    -----
    -
    -***********
    -Run the app
    -***********
    -Run the app locally to see it!
    -
    -.. code:: python
    -
    -    lightning run app app.py
    -
    -Now run it on the cloud as well:
    -
    -.. code:: python
    -
    -    lightning run app app.py --cloud
    -
    -----
    -
    -************************
    -Step-by-step walkthrough
    -************************
    -In this section, we explain each part of this code in detail.
    -
    -----
    -
    -0. Define a Dash app
    -^^^^^^^^^^^^^^^^^^^^
    -First, find the dash app you want to integrate. In this example, that app looks like:
    -
    -.. code:: python
    -
    -        import dash
    -        import plotly.express as px
    -
    -        dash_app = dash.Dash(__name__)
    -        X = [1, 2, 3, 4, 5, 6]
    -        Y = [2, 4, 8, 16, 32, 64]
    -        fig = px.line(x=X, y=Y)
    -
    -        dash_app.layout = dash.html.Div(children=[
    -            dash.html.H1(children='⚡ Hello Dash + Lightning⚡'),
    -            dash.html.Div(children='The Dash framework running inside a ⚡ Lightning App'),
    -            dash.dcc.Graph(id='example-graph', figure=fig)
    -        ])
    -
    -        dash_app.run_server(host='0.0.0.0', port=80)
    -
    -This dash app plots a simple line curve along with some HTMlapp.
    -`Visit the Dash documentation for the full API <https://plotly.com/dash/>`_.
    -
    -----
    -
    -1. Add Dash to a component
    -^^^^^^^^^^^^^^^^^^^^^^^^^^
    -Add the dash app to the run method of a ``LightningWork`` component and run the server on that component's **host** and **port**:
    -
    -.. code:: python
    -    :emphasize-lines: 6, 18
    -
    -        import lightning as L
    -        import dash
    -        import plotly.express as px
    -
    -        class LitDash(L.LightningWork):
    -            def run(self):
    -                dash_app = dash.Dash(__name__)
    -                X = [1, 2, 3, 4, 5, 6]
    -                Y = [2, 4, 8, 16, 32, 64]
    -                fig = px.line(x=X, y=Y)
    -
    -                dash_app.layout = dash.html.Div(children=[
    -                    dash.html.H1(children='⚡ Hello Dash + Lightning⚡'),
    -                    dash.html.Div(children='The Dash framework running inside a ⚡ Lightning App'),
    -                    dash.dcc.Graph(id='example-graph', figure=fig)
    -                ])
    -
    -                dash_app.run_server(host=self.host, port=self.port)
    -
    -        class LitApp(L.LightningFlow):
    -            def __init__(self):
    -                super().__init__()
    -                self.lit_dash = LitDash(parallel=True)
    -
    -            def run(self):
    -                self.lit_dash.run()
    -
    -            def configure_layout(self):
    -                tab1 = {"name": "home", "content": self.lit_dash}
    -                return tab1
    -
    -        app = L.LightningApp(LitApp())
    -
    -----
    -
    -2. Route the UI in the root component
    -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    -The final step, is to tell the Root component in which tab to render this component's UI.
    -In this case, we render the ``LitDash`` UI in the ``home`` tab of the application.
    -
    -.. code:: python
    -    :emphasize-lines: 23, 29
    -
    -        import lightning as L
    -        import dash
    -        import plotly.express as px
    -
    -        class LitDash(L.LightningWork):
    -            def run(self):
    -                dash_app = dash.Dash(__name__)
    -                X = [1, 2, 3, 4, 5, 6]
    -                Y = [2, 4, 8, 16, 32, 64]
    -                fig = px.line(x=X, y=Y)
    -
    -                dash_app.layout = dash.html.Div(children=[
    -                    dash.html.H1(children='⚡ Hello Dash + Lightning⚡'),
    -                    dash.html.Div(children='The Dash framework running inside a ⚡ Lightning App'),
    -                    dash.dcc.Graph(id='example-graph', figure=fig)
    -                ])
    -
    -                dash_app.run_server(host=self.host, port=self.port)
    -
    -        class LitApp(L.LightningFlow):
    -            def __init__(self):
    -                super().__init__()
    -                self.lit_dash = LitDash(parallel=True)
    -
    -            def run(self):
    -                self.lit_dash.run()
    -
    -            def configure_layout(self):
    -                tab1 = {"name": "home", "content": self.lit_dash}
    -                return tab1
    -
    -        app = L.LightningApp(LitApp())
    -
    -We use the ``parallel=True`` argument of ``LightningWork`` to run the server in the background
    -while the rest of the Lightning App runs everything else.
    
  • docs/source-app/workflows/add_web_ui/dash/index.rst+0 84 removed
    @@ -1,84 +0,0 @@
    -:orphan:
    -
    -.. toctree::
    -   :maxdepth: 1
    -   :hidden:
    -
    -   basic
    -   intermediate
    -
    -######################
    -Add a web UI with Dash
    -######################
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: 1: Connect Dash
    -   :description: Learn how to connect a Dash app.
    -   :col_css: col-md-6
    -   :button_link: basic.html
    -   :height: 150
    -   :tag: basic
    -
    -.. displayitem::
    -   :header: 2: Enable two-way communication
    -   :description: Enable two-way communication between the dash app and a Lightning App.
    -   :col_css: col-md-6
    -   :button_link: intermediate.html
    -   :height: 150
    -   :tag: [docs coming soon]
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    -
    -----
    -
    -********
    -Examples
    -********
    -Here are a few example apps that use a Dash web UI.
    -
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -    :header: Example 1
    -    :description: Show off your work! Contribute an example.
    -    :col_css: col-md-4
    -    :button_link: ../../../contribute_app.html
    -    :height: 150
    -    :tag: Waiting for contributed example
    -
    -.. displayitem::
    -    :header: Example 2
    -    :description: Show off your work! Contribute an example.
    -    :col_css: col-md-4
    -    :button_link: ../../../contribute_app.html
    -    :height: 150
    -    :tag: Waiting for contributed example
    -
    -.. displayitem::
    -    :header: Example 3
    -    :description: Show off your work! Contribute an example.
    -    :col_css: col-md-4
    -    :button_link: ../../../contribute_app.html
    -    :height: 150
    -    :tag: Waiting for contributed example
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/workflows/add_web_ui/dash/intermediate_plot.py+0 86 removed
    @@ -1,86 +0,0 @@
    -from typing import Optional
    -
    -import pandas as pd
    -import plotly.express as px
    -from dash import Dash, dcc, html, Input, Output
    -
    -from lightning.app import LightningWork, LightningFlow, LightningApp
    -from lightning.app.storage import Payload
    -
    -
    -class LitDash(LightningWork):
    -    def __init__(self):
    -        super().__init__(parallel=True)
    -        self.df = None
    -        self.selected_year = None
    -
    -    def run(self):
    -        df = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/gapminderDataFiveYear.csv")
    -        self.df = Payload(df)
    -
    -        dash_app = Dash(__name__)
    -
    -        dash_app.layout = html.Div(
    -            [
    -                dcc.Graph(id="graph-with-slider"),
    -                dcc.Slider(
    -                    df["year"].min(),
    -                    df["year"].max(),
    -                    step=None,
    -                    value=df["year"].min(),
    -                    marks={str(year): str(year) for year in df["year"].unique()},
    -                    id="year-slider",
    -                ),
    -            ]
    -        )
    -
    -        @dash_app.callback(Output("graph-with-slider", "figure"), Input("year-slider", "value"))
    -        def update_figure(selected_year):
    -            self.selected_year = selected_year
    -            filtered_df = df[df.year == selected_year]
    -
    -            fig = px.scatter(
    -                filtered_df,
    -                x="gdpPercap",
    -                y="lifeExp",
    -                size="pop",
    -                color="continent",
    -                hover_name="country",
    -                log_x=True,
    -                size_max=55,
    -            )
    -
    -            fig.update_layout(transition_duration=500)
    -
    -            return fig
    -
    -        dash_app.run_server(host=self.host, port=self.port)
    -
    -
    -class Processor(LightningWork):
    -    def run(self, df: Payload, selected_year: Optional[str]):
    -        if selected_year:
    -            df = df.value
    -            filtered_df = df[df.year == selected_year]
    -            print(f"[PROCESSOR|selected_year={selected_year}]")
    -            print(filtered_df)
    -
    -
    -class LitApp(LightningFlow):
    -    def __init__(self):
    -        super().__init__()
    -        self.lit_dash = LitDash()
    -        self.processor = Processor(parallel=True)
    -
    -    def run(self):
    -        self.lit_dash.run()
    -
    -        # Launch some processing based on the Dash Dashboard.
    -        self.processor.run(self.lit_dash.df, self.lit_dash.selected_year)
    -
    -    def configure_layout(self):
    -        tab1 = {"name": "home", "content": self.lit_dash}
    -        return tab1
    -
    -
    -app = LightningApp(LitApp())
    
  • docs/source-app/workflows/add_web_ui/dash/intermediate.rst+0 42 removed
    @@ -1,42 +0,0 @@
    -#####################################
    -Add a web UI with Dash (intermediate)
    -#####################################
    -**Audience:** Users who want to communicate between the Lightning App and Dash.
    -
    -**Prereqs:** Must have read the :doc:`dash basic <basic>` guide.
    -
    -----
    -
    -*******************************
    -Interact with the App from Dash
    -*******************************
    -
    -In the example below, every time you change the select year on the dashboard, this is directly communicated to the flow
    -and another work process the associated data frame with the provided year.
    -
    -.. literalinclude:: intermediate_plot.py
    -
    -Here is how the app looks like once running:
    -
    -.. figure::  https://pl-public-data.s3.amazonaws.com/assets_lightning/dash_plot.gif
    -
    -----
    -
    -***********************************
    -Interact with Dash from a component
    -***********************************
    -
    -In the example below, when you click the toggle, the state of the work appears.
    -
    -Install the following libraries if you want to run the app.
    -
    -```bash
    -pip install dash_daq dash_renderjson
    -```
    -
    -.. literalinclude:: intermediate_state.py
    -
    -
    -Here is how the app looks like once running:
    -
    -.. figure::  https://pl-public-data.s3.amazonaws.com/assets_lightning/dash_state.gif
    
  • docs/source-app/workflows/add_web_ui/dash/intermediate_state.py+0 39 removed
    @@ -1,39 +0,0 @@
    -import dash
    -import dash_daq as daq
    -import dash_renderjson
    -from dash import html, Input, Output
    -
    -from lightning.app import LightningWork, LightningFlow, LightningApp
    -from lightning.app.utilities.state import AppState
    -
    -
    -class LitDash(LightningWork):
    -    def run(self):
    -        dash_app = dash.Dash(__name__)
    -
    -        dash_app.layout = html.Div([daq.ToggleSwitch(id="my-toggle-switch", value=False), html.Div(id="output")])
    -
    -        @dash_app.callback(Output("output", "children"), [Input("my-toggle-switch", "value")])
    -        def display_output(value):
    -            if value:
    -                state = AppState()
    -                state._request_state()
    -                return dash_renderjson.DashRenderjson(id="input", data=state._state, max_depth=-1, invert_theme=True)
    -
    -        dash_app.run_server(host=self.host, port=self.port)
    -
    -
    -class LitApp(LightningFlow):
    -    def __init__(self):
    -        super().__init__()
    -        self.lit_dash = LitDash(parallel=True)
    -
    -    def run(self):
    -        self.lit_dash.run()
    -
    -    def configure_layout(self):
    -        tab1 = {"name": "home", "content": self.lit_dash}
    -        return tab1
    -
    -
    -app = LightningApp(LitApp())
    
  • docs/source-app/workflows/add_web_ui/example_app.rst+0 7 removed
    @@ -1,7 +0,0 @@
    -:orphan:
    -
    -###########
    -Example App
    -###########
    -
    -This is an example app that needs to be built for this part of the docs.
    
  • docs/source-app/workflows/add_web_ui/glossary_front_end.rst+0 9 removed
    @@ -1,9 +0,0 @@
    -########
    -Frontend
    -########
    -Web pages visible to users are also known as **front-ends**. Lightning Apps can have multiple
    -types of Frontends.
    -
    -----
    -
    -.. include:: index_content.rst
    
  • docs/source-app/workflows/add_web_ui/glossary_ui.rst+0 9 removed
    @@ -1,9 +0,0 @@
    -###################
    -UI (User Interface)
    -###################
    -We use (UI) as short for a **web page** with interactions. Lightning Apps can have multiple
    -types of UIs.
    -
    -----
    -
    -.. include:: index_content.rst
    
  • docs/source-app/workflows/add_web_ui/gradio/basic.rst+0 217 removed
    @@ -1,217 +0,0 @@
    -################################
    -Add a web UI with Gradio (basic)
    -################################
    -**Audience:** Users who want to add a web UI written with Python.
    -
    -**Prereqs:** Basic python knowledge.
    -
    -----
    -
    -***************
    -What is Gradio?
    -***************
    -Gradio is a Python library that automatically generates a web interface to demo a machine learning model.
    -
    -----
    -
    -*****************
    -Install gradio
    -*****************
    -First, install gradio.
    -
    -.. code:: bash
    -
    -    pip install gradio
    -
    -----
    -
    -**************************
    -Create the gradio demo app
    -**************************
    -To explain how to use Gradio with Lightning, let's replicate the |gradio_link|.
    -
    -.. |gradio_link| raw:: html
    -
    -   <a href="https://01g3p7np2v3far1jg6ccbvppah.litng-ai-03.litng.ai/view/home" target="_blank">example running here</a>
    -
    -In the next few sections we'll build an app step-by-step.
    -First **create a file named app.py** with the app content:
    -
    -.. code:: python
    -
    -    import lightning as L
    -    from lightning.app.components import ServeGradio
    -    import gradio as gr
    -
    -    class LitGradio(ServeGradio):
    -
    -        inputs = gr.inputs.Textbox(default='lightning', label='name input')
    -        outputs = gr.outputs.Textbox(label='output')
    -        examples = [["hello lightning"]]
    -
    -        def predict(self, input_text):
    -            return self.model(input_text)
    -
    -        def build_model(self):
    -            fake_model = lambda x: f"hello {x}"
    -            return fake_model
    -
    -    class RootFlow(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.lit_gradio = LitGradio()
    -
    -        def run(self):
    -            self.lit_gradio.run()
    -
    -        def configure_layout(self):
    -            return [{"name": "home", "content": self.lit_gradio}]
    -
    -    app = L.LightningApp(RootFlow())
    -
    -add "gradio" to a requirements.txt file:
    -
    -.. code:: bash
    -
    -    echo 'gradio' >> requirements.txt
    -
    -this is a best practice to make apps reproducible.
    -
    -----
    -
    -***********
    -Run the app
    -***********
    -Run the app locally to see it!
    -
    -.. code:: python
    -
    -    lightning run app app.py
    -
    -Now run it on the cloud as well:
    -
    -.. code:: python
    -
    -    lightning run app app.py --cloud
    -
    -----
    -
    -************************
    -Step-by-step walkthrough
    -************************
    -In this section, we explain each part of this code in detail.
    -
    -----
    -
    -Create a Gradio component
    -^^^^^^^^^^^^^^^^^^^^^^^^^
    -To create a Gradio component, simply take any Gradio app and subclass it from ``ServeGradio``.
    -If you haven't created a Gradio demo, you have to implement the following elements:
    -
    -1. Input which is text.
    -2. Output which is text.
    -3. A build_model function.
    -4. A predict function.
    -
    -|
    -
    -Here's an example:
    -
    -.. code:: python
    -    :emphasize-lines: 4
    -
    -    from lightning.app.components import ServeGradio
    -    import gradio as gr
    -
    -    class LitGradio(ServeGradio):
    -
    -        inputs = gr.inputs.Textbox(default='lightning', label='name input')
    -        outputs = gr.outputs.Textbox(label='output')
    -
    -        def predict(self, input_text):
    -            return self.model(input_text)
    -
    -        def build_model(self):
    -            fake_model = lambda x: f"hello {x}"
    -            return fake_model
    -
    -This fake model simply concatenates 2 strings.
    -
    -----
    -
    -Route the UI in the root component
    -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    -Now, tell the Root component in which tab to render this component's UI.
    -In this case, we render the ``LitGradio`` UI in the ``home`` tab of the application.
    -
    -.. code:: python
    -    :emphasize-lines: 21, 27
    -
    -    import lightning as L
    -    from lightning.app.components import ServeGradio
    -    import gradio as gr
    -
    -    class LitGradio(ServeGradio):
    -
    -        inputs = gr.inputs.Textbox(default='lightning', label='name input')
    -        outputs = gr.outputs.Textbox(label='output')
    -        examples = [["hello lightning"]]
    -
    -        def predict(self, input_text):
    -            return self.model(input_text)
    -
    -        def build_model(self):
    -            fake_model = lambda x: f"hello {x}"
    -            return fake_model
    -
    -    class RootFlow(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.lit_gradio = LitGradio()
    -
    -        def run(self):
    -            self.lit_gradio.run()
    -
    -        def configure_layout(self):
    -            return [{"name": "home", "content": self.lit_gradio}]
    -
    -    app = L.LightningApp(RootFlow())
    -
    -----
    -
    -Call run
    -^^^^^^^^
    -Finally, don't forget to call run inside the Root Flow to serve the Gradio app.
    -
    -.. code:: python
    -    :emphasize-lines: 24
    -
    -    import lightning as L
    -    from lightning.app.components import ServeGradio
    -    import gradio as gr
    -
    -    class LitGradio(ServeGradio):
    -
    -        inputs = gr.inputs.Textbox(default='lightning', label='name input')
    -        outputs = gr.outputs.Textbox(label='output')
    -        examples = [["hello lightning"]]
    -
    -        def predict(self, input_text):
    -            return self.model(input_text)
    -
    -        def build_model(self):
    -            fake_model = lambda x: f"hello {x}"
    -            return fake_model
    -
    -    class RootFlow(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.lit_gradio = LitGradio()
    -
    -        def run(self):
    -            self.lit_gradio.run()
    -
    -        def configure_layout(self):
    -            return [{"name": "home", "content": self.lit_gradio}]
    -
    -    app = L.LightningApp(RootFlow())
    
  • docs/source-app/workflows/add_web_ui/gradio/index.rst+0 84 removed
    @@ -1,84 +0,0 @@
    -:orphan:
    -
    -.. toctree::
    -   :maxdepth: 1
    -   :hidden:
    -
    -   basic
    -   intermediate
    -
    -########################
    -Add a web UI with Gradio
    -########################
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: 1: Connect Gradio
    -   :description: Learn how to connect Gradio to a Lightning Component.
    -   :col_css: col-md-6
    -   :button_link: basic.html
    -   :height: 150
    -   :tag: basic
    -
    -.. displayitem::
    -   :header: 2: Enable two-way communication
    -   :description: Enable two-way communication between Gradio and a Lightning App.
    -   :col_css: col-md-6
    -   :button_link: intermediate.html
    -   :height: 150
    -   :tag: [documentation coming soon]
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    -
    -----
    -
    -********
    -Examples
    -********
    -Here are a few example apps that use a Gradio web UI.
    -
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -    :header: Example 1
    -    :description: Show off your work! Contribute an example.
    -    :col_css: col-md-4
    -    :button_link: ../../../contribute_app.html
    -    :height: 150
    -    :tag: Waiting for contributed example
    -
    -.. displayitem::
    -    :header: Example 2
    -    :description: Show off your work! Contribute an example.
    -    :col_css: col-md-4
    -    :button_link: ../../../contribute_app.html
    -    :height: 150
    -    :tag: Waiting for contributed example
    -
    -.. displayitem::
    -    :header: Example 3
    -    :description: Show off your work! Contribute an example.
    -    :col_css: col-md-4
    -    :button_link: ../../../contribute_app.html
    -    :height: 150
    -    :tag: Waiting for contributed example
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/workflows/add_web_ui/gradio/intermediate.rst+0 21 removed
    @@ -1,21 +0,0 @@
    -#######################################
    -Add a web UI with Gradio (intermediate)
    -#######################################
    -
    -.. note:: documentation coming soon.
    -
    -
    -*************************************
    -Interact with a component from the UI
    -*************************************
    -
    -.. warning:: is there such a thing for this with gradio?
    -
    -
    -----
    -
    -*************************************
    -Interact with the UI from a component
    -*************************************
    -
    -.. warning:: is there such a thing for this with gradio?
    
  • docs/source-app/workflows/add_web_ui/html/basic.rst+0 166 removed
    @@ -1,166 +0,0 @@
    -##############################
    -Add a web UI with HTML (basic)
    -##############################
    -**Audience:** Users who want to add a web UI written in HTMlapp.
    -
    -**Prereqs:** Basic html knowledge.
    -
    -----
    -
    -*************
    -What is HTML?
    -*************
    -HyperText Markup Language (HTML) is the Language used to create web pages. Use HTML for simple
    -web user interfaces that tend to be more static.
    -
    -For reactive web applications, we recommend using: React.js, Angular.js or Vue.js
    -
    -----
    -
    -*******************
    -Create an HTML page
    -*******************
    -The first step is to create an HTML file named **index.html**:
    -
    -.. code:: html
    -
    -    <!--index.html-->
    -    <html>
    -    <head>
    -    </head>
    -    <body>
    -        <h1>Hello World<h1>
    -    </body>
    -    </html>
    -
    -----
    -
    -************************
    -Create the HTML demo app
    -************************
    -
    -..
    -    To explain how to use html with Lightning, let's replicate the |html_app_link|.
    -
    -    .. |html_app_link| raw:: html
    -
    -       <a href="https://01g3pdayfptbhqfre565j8gwjr.litng-ai-03.litng.ai/view/home" target="_blank">example running here</a>
    -
    -In the next few sections we'll build an app step-by-step.
    -First **create a file named app.py** with the app content (in the same folder as index.html):
    -
    -.. code:: bash
    -
    -    # app.py
    -    import lightning as L
    -    import lightning.app.frontend as frontend
    -
    -
    -    class HelloComponent(L.LightningFlow):
    -        def configure_layout(self):
    -            return frontend.StaticWebFrontend(serve_dir='.')
    -
    -
    -    class LitApp(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.hello_component = HelloComponent()
    -
    -        def run(self):
    -            self.hello_component.run()
    -
    -        def configure_layout(self):
    -            tab1 = {"name": "home", "content": self.hello_component}
    -            return tab1
    -
    -
    -    app = L.LightningApp(LitApp())
    -
    -----
    -
    -***********
    -Run the app
    -***********
    -Run the app locally to see it!
    -
    -.. code:: python
    -
    -    lightning run app app.py
    -
    -Now run it on the cloud as well:
    -
    -.. code:: python
    -
    -    lightning run app app.py --cloud
    -
    -----
    -
    -************************
    -Step-by-step walkthrough
    -************************
    -In this section, we explain each part of this code in detail.
    -
    -----
    -
    -Enable an HTML UI for the component
    -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    -Give the component an HTML UI, by returning a ``StaticWebFrontend`` object from the ``configure_layout`` method:
    -
    -.. code:: bash
    -    :emphasize-lines: 6,7
    -
    -    # app.py
    -    import lightning as L
    -    import lightning.app.frontend as frontend
    -
    -    class HelloComponent(L.LightningFlow):
    -        def configure_layout(self):
    -            return frontend.StaticWebFrontend(serve_dir='.')
    -
    -    class LitApp(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.hello_component = HelloComponent()
    -
    -        def run(self):
    -            self.hello_component.run()
    -
    -        def configure_layout(self):
    -            tab1 = {"name": "home", "content": self.hello_component}
    -            return tab1
    -
    -    app = L.LightningApp(LitApp())
    -
    -The folder path given in ``StaticWebFrontend(serve_dir=)`` must point to a folder with an ``index.html`` page.
    -
    -----
    -
    -Route the UI in the root component
    -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    -The final step, is to tell the Root component in which tab to render this component's UI.
    -In this case, we render the ``HelloComponent`` UI in the ``home`` tab of the application.
    -
    -.. code:: python
    -    :emphasize-lines: 18, 19
    -
    -    # app.py
    -    import lightning as L
    -    import lightning.app.frontend as frontend
    -
    -    class HelloComponent(L.LightningFlow):
    -        def configure_layout(self):
    -            return frontend.StaticWebFrontend(serve_dir='.')
    -
    -    class LitApp(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.hello_component = HelloComponent()
    -
    -        def run(self):
    -            self.hello_component.run()
    -
    -        def configure_layout(self):
    -            tab1 = {"name": "home", "content": self.hello_component}
    -            return tab1
    -
    -    app = L.LightningApp(LitApp())
    
  • docs/source-app/workflows/add_web_ui/html/index.rst+0 87 removed
    @@ -1,87 +0,0 @@
    -:orphan:
    -
    -.. toctree::
    -   :maxdepth: 1
    -   :hidden:
    -
    -   basic
    -   intermediate
    -
    -######################
    -Add a web UI with HTML
    -######################
    -**Audience:** Users who want to add a web UI using plain html.
    -
    -**Prereqs:** Basic html knowledge.
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: 1: Connect HTML
    -   :description: Learn how to connect an HTML app.
    -   :col_css: col-md-6
    -   :button_link: basic.html
    -   :height: 150
    -   :tag: basic
    -
    -.. displayitem::
    -   :header: 2: Enable two-way communication
    -   :description: Enable two-way communication between HTML and a Lightning App.
    -   :col_css: col-md-6
    -   :button_link: intermediate.html
    -   :height: 150
    -   :tag: [docs coming soon]
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    -
    -----
    -
    -********
    -Examples
    -********
    -Here are a few example apps that use an HTML web UI.
    -
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -    :header: Example 1
    -    :description: Show off your work! Contribute an example.
    -    :col_css: col-md-4
    -    :button_link: ../../../contribute_app.html
    -    :height: 150
    -    :tag: Waiting for contributed example
    -
    -.. displayitem::
    -    :header: Example 2
    -    :description: Show off your work! Contribute an example.
    -    :col_css: col-md-4
    -    :button_link: ../../../contribute_app.html
    -    :height: 150
    -    :tag: Waiting for contributed example
    -
    -.. displayitem::
    -    :header: Example 3
    -    :description: Show off your work! Contribute an example.
    -    :col_css: col-md-4
    -    :button_link: ../../../contribute_app.html
    -    :height: 150
    -    :tag: Waiting for contributed example
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/workflows/add_web_ui/html/intermediate.rst+0 20 removed
    @@ -1,20 +0,0 @@
    -#####################################
    -Add a web UI with HTML (intermediate)
    -#####################################
    -**Audience:** Users who want to add a web UI using plain html.
    -
    -**Prereqs:** Must have read the :doc:`html basic <basic>` guide.
    -
    -----
    -
    -*******************************
    -Interact with the App from HTML
    -*******************************
    -.. note:: documentation in progress
    -
    -----
    -
    -***********************************
    -Interact with HTML from a component
    -***********************************
    -.. note:: documentation in progress
    
  • docs/source-app/workflows/add_web_ui/index_content.rst+0 121 removed
    @@ -1,121 +0,0 @@
    -*************************************
    -Web UIs for non Javascript Developers
    -*************************************
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: Dash
    -   :description: Learn how to add a web UI built in Python with Dash.
    -   :col_css: col-md-4
    -   :button_link: ../../workflows/add_web_ui/dash/index.html
    -   :height: 150
    -   :tag: basic
    -
    -.. displayitem::
    -   :header: Gradio
    -   :description: Learn how to add a web UI built in Python with Gradio.
    -   :col_css: col-md-4
    -   :button_link: ../../workflows/add_web_ui/gradio/index.html
    -   :height: 150
    -   :tag: basic
    -
    -.. displayitem::
    -   :header: Panel
    -   :description: Learn how to add a web UI built in Python with Panel.
    -   :col_css: col-md-4
    -   :button_link: ../../workflows/add_web_ui/panel/index.html
    -   :height: 150
    -   :tag: basic
    -
    -.. displayitem::
    -   :header: Jupyter Notebook
    -   :description: Learn how to enable a web UI that is a Jupyter Notebook.
    -   :col_css: col-md-4
    -   :button_link: ../../workflows/add_web_ui/jupyter_basic.html
    -   :height: 150
    -   :tag: [docs coming soon]
    -
    -.. displayitem::
    -   :header: Streamlit
    -   :description: Learn how to add a web UI built in Python with Streamlit.
    -   :col_css: col-md-4
    -   :button_link: ../../workflows/add_web_ui/streamlit/index.html
    -   :height: 150
    -   :tag: basic
    -
    -.. displayitem::
    -   :header: JustPy
    -   :description: Learn how to add a web UI built in Python with JustPy.
    -   :col_css: col-md-4
    -   :button_link: ../../workflows/add_web_ui/justpy/index.html
    -   :height: 150
    -   :tag: basic
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    -
    -----
    -
    -*********************************
    -Web UIs for Javascript Developers
    -*********************************
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: Any javascript framework
    -   :description: Learn how to link up any javascript framework to a Lightning app.
    -   :col_css: col-md-4
    -   :button_link: ../../workflows/add_web_ui/integrate_any_javascript_framework.html
    -   :height: 150
    -   :tag: advanced
    -
    -.. displayitem::
    -   :header: Angular.js
    -   :description: Learn how to add a web UI built in Javascript with Angular.js
    -   :col_css: col-md-4
    -   :button_link: ../../workflows/add_web_ui/angular_js_intermediate.html
    -   :height: 150
    -   :tag: [Docs coming soon]
    -
    -.. displayitem::
    -   :header: HTML
    -   :description: Learn how to add a web UI built with html.
    -   :col_css: col-md-4
    -   :button_link: ../../workflows/add_web_ui/html/index.html
    -   :height: 150
    -   :tag: basic
    -
    -.. displayitem::
    -   :header: React.js
    -   :description: Learn how to add a web UI built in Javascript with React.js
    -   :col_css: col-md-4
    -   :button_link: ../../workflows/add_web_ui/react/index.html
    -   :height: 150
    -   :tag: intermediate
    -
    -.. displayitem::
    -   :header: Vue.js
    -   :description: Learn how to add a web UI built in Javascript with Vue.js
    -   :col_css: col-md-4
    -   :button_link: ../../workflows/add_web_ui/vue_js_intermediate.html
    -   :height: 150
    -   :tag: [Docs coming soon]
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/workflows/add_web_ui/index.rst+0 10 removed
    @@ -1,10 +0,0 @@
    -
    -#############################
    -Add a web user interface (UI)
    -#############################
    -
    -**Audience:** Users who want to add a UI to their Lightning Apps
    -
    -----
    -
    -.. include:: index_content.rst
    
  • docs/source-app/workflows/add_web_ui/integrate_any_javascript_framework.rst+0 164 removed
    @@ -1,164 +0,0 @@
    -:orphan:
    -
    -##################################
    -Integrate any javascript framework
    -##################################
    -**Audience:** Advanced web developers with complex apps that may not have been covered by the other tutorials
    -
    -**Pre-requisites:** Intermediate knowledge of html and javascript
    -
    -----
    -
    -************************
    -Import LightningState.js
    -************************
    -To connect any javascript framework, import the `LightningState.js <https://storage.googleapis.com/grid-packages/lightning-ui/v0.0.0/LightningState.js>`_ library.
    -LightningState.js enables two-way communication between a javascript framework and a Lightning app.
    -
    -To import this library, add this to your html:
    -
    -.. code:: html
    -
    -    <script src="https://storage.googleapis.com/grid-packages/lightning-ui/v0.0.0/LightningState.js"></script>
    -
    -Once it's imported, use it inside your app, this example uses it inside a React App:
    -
    -.. code-block::
    -    :emphasize-lines: 1, 5
    -
    -        import { useLightningState } from "./hooks/useLightningState";
    -        import cloneDeep from "lodash/cloneDeep";
    -
    -        function App() {
    -            const { lightningState, updateLightningState } = useLightningState();
    -
    -            const modify_and_send_back_the_state = async (event: ChangeEvent<HTMLInputElement>) => {
    -                if (lightningState) {
    -                const newLightningState = cloneDeep(lightningState);
    -                // Update the state and send it back.
    -                newLightningState.flows.counter += 1
    -
    -                updateLightningState(newLightningState);
    -                }
    -        };
    -
    -        return (
    -            <div className="App">
    -            </div>
    -        );
    -    }
    -
    -    export default App;
    -
    -----
    -
    -************************
    -Update the Lightning app
    -************************
    -Use `updateLightningState` to update the lightning app. Here we update a variable called counter.
    -
    -.. code-block::
    -    :emphasize-lines: 11
    -
    -    import { useLightningState } from "./hooks/useLightningState";
    -    import cloneDeep from "lodash/cloneDeep";
    -
    -    function App() {
    -            const { lightningState, updateLightningState } = useLightningState();
    -
    -            const modify_and_send_back_the_state = async (event: ChangeEvent<HTMLInputElement>) => {
    -                if (lightningState) {
    -                const newLightningState = cloneDeep(lightningState);
    -                // Update the state and send it back.
    -                newLightningState.flows.counter += 1
    -
    -                updateLightningState(newLightningState);
    -                }
    -        };
    -
    -        return (
    -            <div className="App">
    -            </div>
    -        );
    -    }
    -
    -    export default App;
    -
    -----
    -
    -**************************************
    -Receive updates from the Lightning app
    -**************************************
    -Whenever a variable in the Lightning app changes, the javascript app will receive those values via `lightningState`.
    -
    -Extract any variable from the state and update the javascript app:
    -
    -.. code-block::
    -    :emphasize-lines: 5
    -
    -    import { useLightningState } from "./hooks/useLightningState";
    -    import cloneDeep from "lodash/cloneDeep";
    -
    -    function App() {
    -            const { lightningState, updateLightningState } = useLightningState();
    -
    -            const modify_and_send_back_the_state = async (event: ChangeEvent<HTMLInputElement>) => {
    -                if (lightningState) {
    -                const newLightningState = cloneDeep(lightningState);
    -                // Update the state and send it back.
    -                newLightningState.flows.counter += 1
    -
    -                updateLightningState(newLightningState);
    -            }
    -        };
    -
    -        return (
    -            <div className="App">
    -            </div>
    -        );
    -    }
    -
    -    export default App;
    -
    -----
    -
    -********
    -Examples
    -********
    -
    -See this in action in these examples:
    -
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -    :header: React.js
    -    :description: Explore how React.js uses lightningState.js
    -    :col_css: col-md-4
    -    :button_link: react/communicate_between_react_and_lightning.html
    -    :height: 150
    -    :tag: intermediate
    -
    -.. displayitem::
    -    :header: Example 2
    -    :description: Show off your work! Contribute an example.
    -    :col_css: col-md-4
    -    :height: 150
    -    :tag: Waiting for contributed example
    -
    -.. displayitem::
    -    :header: Example 3
    -    :description: Show off your work! Contribute an example.
    -    :col_css: col-md-4
    -    :height: 150
    -    :tag: Waiting for contributed example
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/workflows/add_web_ui/jupyter_basic.rst+0 70 removed
    @@ -1,70 +0,0 @@
    -:orphan:
    -
    -#####################################
    -Add a Jupyter Notebook web UI (basic)
    -#####################################
    -**Audience:** Users who want to enable a Jupyter notebook UI.
    -
    -**Prereqs:** Basic python knowledge.
    -
    -TODO
    -
    -----
    -
    -***************************
    -What is a Jupyter Notebook?
    -***************************
    -
    -TODO
    -
    -----
    -
    -*******************
    -Install Jupyter Lab
    -*******************
    -
    -First, install Jupyter Lab.
    -
    -.. code:: bash
    -
    -    pip install jupyterlab
    -
    -----
    -
    -********
    -Examples
    -********
    -Here are a few example apps that use Jupyter Lab.
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: Example 1
    -   :description: TODO
    -   :col_css: col-md-4
    -   :button_link: angular_js_intermediate.html
    -   :height: 150
    -
    -.. displayitem::
    -   :header: Example 2
    -   :description: TODO
    -   :col_css: col-md-4
    -   :button_link: angular_js_intermediate.html
    -   :height: 150
    -
    -.. displayitem::
    -   :header: Example 3
    -   :description: TODO
    -   :col_css: col-md-4
    -   :button_link: angular_js_intermediate.html
    -   :height: 150
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/workflows/add_web_ui/justpy/index.rst+0 92 removed
    @@ -1,92 +0,0 @@
    -:orphan:
    -
    -########################
    -Add a web UI with JustPy
    -########################
    -
    -
    -******
    -JustPy
    -******
    -
    -The `JustPy <https://github.com/justpy-org/justpy>`_  framework is an object oriented high-level Python Web Framework that requires no JavaScript programming, while at the same time providing the full flexibility of a frontend framework.
    -
    -Additionally, it provides a higher level API called `Quasar <https://justpy.io/quasar_tutorial/introduction/>`_ with stylized components.
    -
    -
    -You can install ``justpy`` from PyPi.
    -
    -.. code-block::
    -
    -    pip install justpy
    -
    -*******
    -Example
    -*******
    -
    -
    -In the following example, we are creating a simple UI with 2 buttons.
    -When clicking the first button, the flow state ``counter`` is incremented and re-rendered on the UI.
    -
    -
    -First of all, you would need to import the ``JustPyFrontend`` and return it from the ``configure_layout`` hook of the flow.
    -
    -.. code-block::
    -
    -    from typing import Callable
    -
    -    from lightning import LightningApp, LightningFlow
    -    from lightning.app.frontend import JustPyFrontend
    -
    -
    -    class Flow(LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.counter = 0
    -
    -        def run(self):
    -            print(self.counter)
    -
    -        def configure_layout(self):
    -            return JustPyFrontend(render_fn=render_fn)
    -
    -Secondly, you would need to implement a ``render_fn`` that takes as input a ``get_state`` function and return a function.
    -
    -
    -.. code-block::
    -
    -    def render_fn(get_state: Callable) -> Callable:
    -        import justpy as jp
    -
    -        def webpage():
    -            wp = jp.QuasarPage(dark=True)
    -            # the `a=wp` argument adds the div to the web page
    -            d = jp.Div(classes="q-pa-md q-gutter-sm", a=wp)
    -            container = jp.QBtn(color="primary", text="Counter: 0")
    -
    -            async def click(*_):
    -                state = get_state()
    -                state.counter += 1
    -                container.text = f"Counter: {state.counter}"
    -
    -            button = jp.QBtn(color="primary", text="Click Me!", click=click)
    -
    -            d.add(button)
    -            d.add(container)
    -
    -            return wp
    -
    -        return webpage
    -
    -
    -Finally, you can wrap your flow in a LightningAp.
    -
    -.. code-block::
    -
    -    app = LightningApp(Flow())
    -
    -Now, you can run the Lightning App with:
    -
    -.. code-block::
    -
    -    lightning_app run app app.py
    
  • docs/source-app/workflows/add_web_ui/panel/basic.rst+0 369 removed
    @@ -1,369 +0,0 @@
    -:orphan:
    -
    -###############################
    -Add a web UI with Panel (basic)
    -###############################
    -
    -**Audience:** Users who want to add a web UI written with Python and Panel.
    -
    -**Prereqs:** Basic Python knowledge.
    -
    -----
    -
    -**************
    -What is Panel?
    -**************
    -
    -`Panel`_ and the `HoloViz`_ ecosystem provide unique and powerful
    -features such as big data visualization using `DataShader`_, easy cross filtering
    -using `HoloViews`_, streaming and much more.
    -
    -* Panel is highly flexible and ties into the PyData and Jupyter ecosystems as you can develop in notebooks and use ipywidgets. You can also develop in .py files.
    -
    -* Panel is one of the most popular data app frameworks in Python with `more than 400.000 downloads a month <https://pyviz.org/tools.html#dashboarding>`_. It's especially popular in the scientific community.
    -
    -* Panel is used, for example, by Rapids to power `CuxFilter`_, a CuDF based big data visualization framework.
    -
    -* Panel can be deployed on your favorite server or cloud including `Lightning`_.
    -
    -.. figure:: https://pl-public-data.s3.amazonaws.com/assets_lightning/panel-intro.gif
    -   :alt: Example Panel App
    -
    -   Example Panel App
    -
    -Panel is **particularly well suited for Lightning Apps** that need to display live progress. This is because the Panel server can react
    -to state changes and asynchronously push messages from the server to the client using web socket communication.
    -
    -.. figure:: https://pl-public-data.s3.amazonaws.com/assets_lightning/panel-streaming-intro.gif
    -   :alt: Example Panel Streaming App
    -
    -   Example Panel Streaming App
    -
    -Install Panel with:
    -
    -.. code:: bash
    -
    -    pip install panel
    -
    -----
    -
    -*********************
    -Run a basic Panel App
    -*********************
    -
    -In the next few sections, we'll build an App step-by-step.
    -
    -First, create a file named ``app_panel.py`` with the App content:
    -
    -.. code:: python
    -
    -    # app_panel.py
    -
    -    import panel as pn
    -
    -    pn.panel("Hello **Panel ⚡** World").servable()
    -
    -Then, create a file named ``app.py`` with the following App content:
    -
    -.. code:: python
    -
    -    # app.py
    -
    -    import lightning as L
    -    from lightning.app.frontend import PanelFrontend
    -
    -
    -    class LitPanel(L.LightningFlow):
    -
    -        def configure_layout(self):
    -            return PanelFrontend("app_panel.py")
    -
    -
    -    class LitApp(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.lit_panel = LitPanel()
    -
    -        def run(self):
    -            self.lit_panel.run()
    -
    -        def configure_layout(self):
    -            return {"name": "home", "content": self.lit_panel}
    -
    -
    -    app = L.LightningApp(LitApp())
    -
    -Finally, add ``panel`` to your ``requirements.txt`` file:
    -
    -.. code:: bash
    -
    -    echo 'panel' >> requirements.txt
    -
    -.. note:: This is a best practice to make Apps reproducible.
    -
    -----
    -
    -***********
    -Run the App
    -***********
    -
    -Run the App locally:
    -
    -.. code:: bash
    -
    -    lightning_app run app app.py
    -
    -The App should look like this:
    -
    -.. figure:: https://pl-public-data.s3.amazonaws.com/assets_lightning/panel-lightning-basic.png
    -   :alt: Basic Panel Lightning App
    -
    -   Basic Panel Lightning App
    -
    -Now, run it on the cloud:
    -
    -.. code:: bash
    -
    -    lightning_app run app app.py --cloud
    -
    -----
    -
    -*************************
    -Step-by-step walk-through
    -*************************
    -
    -In this section, we explain each part of the code in detail.
    -
    -----
    -
    -0. Define a Panel app
    -^^^^^^^^^^^^^^^^^^^^^
    -
    -First, find the Panel app you want to integrate. In this example, that app looks like:
    -
    -.. code:: python
    -
    -    import panel as pn
    -
    -    pn.panel("Hello **Panel ⚡** World").servable()
    -
    -Refer to the `Panel documentation <https://panel.holoviz.org/>`_ and `awesome-panel <https://github.com/awesome-panel/awesome-panel>`_ for more complex examples.
    -
    -----
    -
    -1. Add Panel to a Component
    -^^^^^^^^^^^^^^^^^^^^^^^^^^^
    -
    -Link this app to the Lightning App by using the ``PanelFrontend`` class which needs to be returned from
    -the ``configure_layout`` method of the Lightning Component you want to connect to Panel.
    -
    -.. code:: python
    -    :emphasize-lines: 7-10
    -
    -    import lightning as L
    -    from lightning.app.frontend import PanelFrontend
    -
    -
    -    class LitPanel(L.LightningFlow):
    -
    -        def configure_layout(self):
    -            return PanelFrontend("app_panel.py")
    -
    -
    -    class LitApp(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.lit_panel = LitPanel()
    -
    -        def run(self):
    -            self.lit_panel.run()
    -
    -        def configure_layout(self):
    -            return {"name": "home", "content": self.lit_panel}
    -
    -
    -    app = L.LightningApp(LitApp())
    -
    -The argument of the ``PanelFrontend`` class, points to the script, notebook, or function that
    -runs your Panel app.
    -
    -----
    -
    -2. Route the UI in the root component
    -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    -
    -The second step, is to tell the Root component in which tab to render this component's UI.
    -In this case, we render the ``LitPanel`` UI in the ``home`` tab of the app.
    -
    -.. code:: python
    -    :emphasize-lines: 19-20
    -
    -    import lightning as L
    -    from lightning.app.frontend import PanelFrontend
    -
    -
    -    class LitPanel(L.LightningFlow):
    -
    -        def configure_layout(self):
    -            return PanelFrontend("app_panel.py")
    -
    -
    -    class LitApp(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.lit_panel = LitPanel()
    -
    -        def run(self):
    -            self.lit_panel.run()
    -
    -        def configure_layout(self):
    -            return {"name": "home", "content": self.lit_panel}
    -
    -    app = L.LightningApp(LitApp())
    -
    -----
    -
    -*************
    -Tips & Tricks
    -*************
    -
    -0. Use autoreload while developing
    -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    -
    -To speed up your development workflow, you can run your Lightning App with Panel **autoreload** by
    -setting the environment variable ``PANEL_AUTORELOAD`` to ``yes``.
    -
    -Try running the following:
    -
    -.. code-block::
    -
    -    PANEL_AUTORELOAD=yes lightning run app app.py
    -
    -.. figure:: https://pl-public-data.s3.amazonaws.com/assets_lightning/panel-lightning-autoreload.gif
    -   :alt: Basic Panel Lightning App with autoreload
    -
    -   Basic Panel Lightning App with autoreload
    -
    -1. Theme your App
    -^^^^^^^^^^^^^^^^^
    -
    -To theme your App you, can use the Lightning accent color ``#792EE5`` with the `FastListTemplate`_.
    -
    -Try replacing the contents of ``app_panel.py`` with the following:
    -
    -.. code:: bash
    -
    -    # app_panel.py
    -
    -    import panel as pn
    -    import plotly.express as px
    -
    -    ACCENT = "#792EE5"
    -
    -    pn.extension("plotly", sizing_mode="stretch_width", template="fast")
    -    pn.state.template.param.update(
    -        title="⚡ Hello Panel + Lightning ⚡", accent_base_color=ACCENT, header_background=ACCENT
    -    )
    -
    -    pn.config.raw_css.append(
    -        """
    -    .bk-root:first-of-type {
    -        height: calc( 100vh - 200px ) !important;
    -    }
    -    """
    -    )
    -
    -
    -    def get_panel_theme():
    -        """Returns 'default' or 'dark'"""
    -        return pn.state.session_args.get("theme", [b"default"])[0].decode()
    -
    -
    -    def get_plotly_template():
    -        if get_panel_theme() == "dark":
    -            return "plotly_dark"
    -        return "plotly_white"
    -
    -
    -    def get_plot(length=5):
    -        xseries = [index for index in range(length + 1)]
    -        yseries = [x**2 for x in xseries]
    -        fig = px.line(
    -            x=xseries,
    -            y=yseries,
    -            template=get_plotly_template(),
    -            color_discrete_sequence=[ACCENT],
    -            range_x=(0, 10),
    -            markers=True,
    -        )
    -        fig.layout.autosize = True
    -        return fig
    -
    -
    -    length = pn.widgets.IntSlider(value=5, start=1, end=10, name="Length")
    -    dynamic_plot = pn.panel(
    -        pn.bind(get_plot, length=length), sizing_mode="stretch_both", config={"responsive": True}
    -    )
    -    pn.Column(length, dynamic_plot).servable()
    -
    -
    -Install some additional libraries and remember to add the dependencies to the ``requirements.txt`` file:
    -
    -
    -.. code:: bash
    -
    -    echo 'plotly' >> requirements.txt
    -    echo 'pandas' >> requirements.txt
    -
    -Finally run the App
    -
    -.. code:: bash
    -
    -    lightning_app run app app.py
    -
    -.. figure:: https://pl-public-data.s3.amazonaws.com/assets_lightning/panel-lightning-theme.gif
    -   :alt: Basic Panel Plotly Lightning App with theming
    -
    -   Basic Panel Plotly Lightning App with theming
    -
    -.. _Panel: https://panel.holoviz.org/
    -.. _FastListTemplate: https://panel.holoviz.org/reference/templates/FastListTemplate.html#templates-gallery-fastlisttemplate
    -.. _HoloViz: https://holoviz.org/
    -.. _DataShader: https://datashader.org/
    -.. _HoloViews: https://holoviews.org/
    -.. _Lightning: https://lightning.ai/
    -.. _CuxFilter: https://github.com/rapidsai/cuxfilter
    -.. _AwesomePanel: https://github.com/awesome-panel/awesome-panel
    -
    -
    -----
    -
    -**********
    -Next Steps
    -**********
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: 2: Enable two-way communication
    -   :description: Enable two-way communication between Panel and a Lightning App.
    -   :col_css: col-md-6
    -   :button_link: intermediate.html
    -   :height: 150
    -   :tag: intermediate
    -
    -.. displayitem::
    -   :header: Add a web user interface (UI)
    -   :description: Users who want to add a UI to their Lightning Apps
    -   :col_css: col-md-6
    -   :button_link: ../index.html
    -   :height: 150
    -   :tag: intermediate
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/workflows/add_web_ui/panel/index.rst+0 85 removed
    @@ -1,85 +0,0 @@
    -:orphan:
    -
    -.. toctree::
    -   :maxdepth: 1
    -   :hidden:
    -
    -   basic
    -   intermediate
    -
    -#######################
    -Add a web UI with Panel
    -#######################
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: 1: Connect Panel
    -   :description: Learn how to connect Panel to a Lightning Component.
    -   :col_css: col-md-6
    -   :button_link: basic.html
    -   :height: 150
    -   :tag: basic
    -
    -.. displayitem::
    -   :header: 2: Enable two-way communication
    -   :description: Enable two-way communication between Panel and a Lightning App.
    -   :col_css: col-md-6
    -   :button_link: intermediate.html
    -   :height: 150
    -   :tag: intermediate
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    -
    -----
    -
    -********
    -Examples
    -********
    -
    -Here are a few example apps that use a Panel web UI.
    -
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -    :header: Example 1
    -    :description: Show off your work! Contribute an example.
    -    :col_css: col-md-4
    -    :button_link: ../../../contribute_app.html
    -    :height: 150
    -    :tag: Waiting for contributed example
    -
    -.. displayitem::
    -    :header: Example 2
    -    :description: Show off your work! Contribute an example.
    -    :col_css: col-md-4
    -    :button_link: ../../../contribute_app.html
    -    :height: 150
    -    :tag: Waiting for contributed example
    -
    -.. displayitem::
    -    :header: Example 3
    -    :description: Show off your work! Contribute an example.
    -    :col_css: col-md-4
    -    :button_link: ../../../contribute_app.html
    -    :height: 150
    -    :tag: Waiting for contributed example
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/workflows/add_web_ui/panel/intermediate.rst+0 210 removed
    @@ -1,210 +0,0 @@
    -:orphan:
    -
    -######################################
    -Add a web UI with Panel (intermediate)
    -######################################
    -
    -**Audience:** Users who want to communicate between the Lightning App and Panel.
    -
    -**Prereqs:** Must have read the :doc:`Panel basic <basic>` guide.
    -
    -----
    -
    -**************************************
    -Interact with the Component from Panel
    -**************************************
    -
    -The ``PanelFrontend`` enables user interactions with the Lightning App using widgets.
    -You can modify the state variables of a Lightning Component using the ``AppStateWatcher``.
    -
    -For example, here we increase the ``count`` variable of the Lightning Component every time a user
    -presses a button:
    -
    -.. code:: python
    -
    -    # app_panel.py
    -
    -    import panel as pn
    -    from lightning.app.frontend import AppStateWatcher
    -
    -    pn.extension(sizing_mode="stretch_width")
    -
    -    app = AppStateWatcher()
    -
    -    submit_button = pn.widgets.Button(name="submit")
    -
    -    @pn.depends(submit_button, watch=True)
    -    def submit(_):
    -        app.state.count += 1
    -
    -    @pn.depends(app.param.state)
    -    def current_count(_):
    -        return f"current count: {app.state.count}"
    -
    -    pn.Column(
    -        submit_button,
    -        current_count,
    -    ).servable()
    -
    -
    -
    -.. code:: python
    -
    -    # app.py
    -
    -    import lightning as L
    -    from lightning.app.frontend import PanelFrontend
    -
    -    class LitPanel(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.count = 0
    -            self.last_count = 0
    -
    -        def run(self):
    -            if self.count != self.last_count:
    -                self.last_count = self.count
    -                print("Count changed to: ", self.count)
    -
    -        def configure_layout(self):
    -            return PanelFrontend("app_panel.py")
    -
    -
    -    class LitApp(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.lit_panel = LitPanel()
    -
    -        def run(self):
    -            self.lit_panel.run()
    -
    -        def configure_layout(self):
    -            return {"name": "home", "content": self.lit_panel}
    -
    -
    -    app = L.LightningApp(LitApp())
    -
    -.. figure:: https://pl-public-data.s3.amazonaws.com/assets_lightning/panel-lightning-counter-from-frontend.gif
    -   :alt: Panel Lightning App updating a counter from the frontend
    -
    -   Panel Lightning App updating a counter from the frontend
    -
    -----
    -
    -************************************
    -Interact with Panel from a Component
    -************************************
    -
    -To update the `PanelFrontend` from any Lightning Component, update the property in the Component.
    -Make sure to call the ``run`` method from the parent component.
    -
    -In this example, we update the ``count`` value of the Component:
    -
    -.. code:: python
    -
    -    # app_panel.py
    -
    -    import panel as pn
    -    from lightning.app.frontend import AppStateWatcher
    -
    -    app = AppStateWatcher()
    -
    -    pn.extension(sizing_mode="stretch_width")
    -
    -    def counter(state):
    -        return f"Counter: {state.count}"
    -
    -    last_update = pn.bind(counter, app.param.state)
    -
    -    pn.panel(last_update).servable()
    -
    -.. code:: python
    -
    -    # app.py
    -
    -    from datetime import datetime as dt
    -    from lightning.app.frontend import PanelFrontend
    -
    -    import lightning as L
    -
    -
    -    class LitPanel(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.count = 0
    -            self._last_update = dt.now()
    -
    -        def run(self):
    -            now = dt.now()
    -            if (now - self._last_update).microseconds >= 250:
    -                self.count += 1
    -                self._last_update = now
    -                print("Counter changed to: ", self.count)
    -
    -        def configure_layout(self):
    -            return PanelFrontend("app_panel.py")
    -
    -
    -    class LitApp(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.lit_panel = LitPanel()
    -
    -        def run(self):
    -            self.lit_panel.run()
    -
    -        def configure_layout(self):
    -            tab1 = {"name": "home", "content": self.lit_panel}
    -            return tab1
    -
    -    app = L.LightningApp(LitApp())
    -
    -.. figure:: https://pl-public-data.s3.amazonaws.com/assets_lightning/panel-lightning-counter-from-component.gif
    -   :alt: Panel Lightning App updating a counter from the component
    -
    -   Panel Lightning App updating a counter from the Component
    -
    -----
    -
    -*************
    -Tips & Tricks
    -*************
    -
    -* Caching: Panel provides the easy to use ``pn.state.cache`` memory based, ``dict`` caching. If you are looking for something persistent try `DiskCache <https://grantjenks.com/docs/diskcache/>`_ its really powerful and simple to use. You can use it to communicate large amounts of data between the components and frontend(s).
    -
    -* Notifications: Panel provides easy to use `notifications <https://blog.holoviz.org/panel_0.13.0.html#Notifications>`_. You can for example use them to provide notifications about runs starting or ending.
    -
    -* Tabulator Table: Panel provides the `Tabulator table <https://blog.holoviz.org/panel_0.13.0.html#Expandable-rows>`_ which features expandable rows. The table is useful to provide for example an overview of you runs. But you can dig into the details by clicking and expanding the row.
    -
    -* Task Scheduling: Panel provides easy to use `task scheduling <https://blog.holoviz.org/panel_0.13.0.html#Task-scheduling>`_. You can use this to for example read and display files created by your components on a scheduled basis.
    -
    -* Terminal: Panel provides the `Xterm.js terminal <https://panel.holoviz.org/reference/widgets/Terminal.html>`_ which can be used to display live logs from your components and allow you to provide a terminal interface to your component.
    -
    -.. figure:: https://pl-public-data.s3.amazonaws.com/assets_lightning/panel-lightning-github-runner.gif
    -   :alt: Panel Lightning App running models on github
    -
    -   Panel Lightning App running models on GitHub
    -
    -----
    -
    -**********
    -Next Steps
    -**********
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: Add a web user interface (UI)
    -   :description: Users who want to add a UI to their Lightning Apps
    -   :col_css: col-md-6
    -   :button_link: ../index.html
    -   :height: 150
    -   :tag: intermediate
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/workflows/add_web_ui/react/communicate_between_react_and_lightning.rst+0 58 removed
    @@ -1,58 +0,0 @@
    -#######################################
    -Communicate Between React and Lightning
    -#######################################
    -**Audience:** Anyone who wants to add a web user interface (UI) written in react to their app.
    -
    -**pre-requisites:** Make sure you've already connected the React and Lightning app.
    -
    -**Difficulty level:** intermediate.
    -
    -----
    -
    -************
    -Example code
    -************
    -To illustrate how to communicate between a React app and a lightning App, we'll be using the `example_app.py` file
    -which :doc:`lightning init react-ui <create_react_template>` created:
    -
    -.. literalinclude:: ../../../../../src/lightning/app/cli/react-ui-template/example_app.py
    -
    -and the App.tsx file also created by :doc:`lightning init react-ui <create_react_template>`:
    -
    -.. literalinclude:: ../../../../../src/lightning/app/cli/react-ui-template/ui/src/App.tsx
    -
    -----
    -
    -******************************
    -Update React --> Lightning app
    -******************************
    -To change the Lightning app from the React app, use `updateLightningState`.
    -
    -In this example, when you press **Start printing** in the React UI, it toggles
    -the `react_ui.vars.should_print`:
    -
    -.. literalinclude:: ../../../../../src/lightning/app/cli/react-ui-template/ui/src/App.tsx
    -    :emphasize-lines: 20, 21, 23
    -
    -By changing that variable in the Lightning app state, it sets **react_ui.should_print** to True, which enables the
    -Lightning app to print:
    -
    -.. literalinclude:: ../../../../../src/lightning/app/cli/react-ui-template/example_app.py
    -    :emphasize-lines: 10, 22
    -
    -----
    -
    -******************************
    -Update React <-- Lightning app
    -******************************
    -To change the React app from the Lightning app, use the values from the `lightningState`.
    -
    -In this example, when the ``react_ui.counter`` increaes in the Lightning app:
    -
    -.. literalinclude:: ../../../../../src/lightning/app/cli/react-ui-template/example_app.py
    -    :emphasize-lines: 18, 24
    -
    -The React UI updates the text on the screen to reflect the count
    -
    -.. literalinclude:: ../../../../../src/lightning/app/cli/react-ui-template/ui/src/App.tsx
    -    :emphasize-lines: 15
    
  • docs/source-app/workflows/add_web_ui/react/connect_react_and_lightning.rst+0 107 removed
    @@ -1,107 +0,0 @@
    -################################
    -Connect React to a Lightning app
    -################################
    -**Audience:** Users who already have a react app and want to connect it to a Lightning app.
    -
    -**pre-requisites:** Make sure you already have a react app you want to connect.
    -
    -**Difficulty level:** intermediate.
    -
    -----
    -
    -************
    -Example code
    -************
    -To illustrate how to connect a React app and a lightning App, we'll be using the `example_app.py` file
    -which :doc:`lightning_app init react-ui <create_react_template>` created:
    -
    -.. literalinclude:: ../../../../../src/lightning/app/cli/react-ui-template/example_app.py
    -
    -and the App.tsx file also created by :doc:`lightning_app init react-ui <create_react_template>`:
    -
    -.. literalinclude:: ../../../../../src/lightning/app/cli/react-ui-template/ui/src/App.tsx
    -
    -----
    -
    -*************************************
    -Connect the component to the react UI
    -*************************************
    -The first step is to connect the dist folder of the react app using `StaticWebFrontend`:
    -
    -.. literalinclude:: ../../../../../src/lightning/app/cli/react-ui-template/example_app.py
    -    :emphasize-lines: 13
    -
    -the dist folder must contain an index.html file which is generated by the compilating command `yarn build` which
    -we'll explore later.
    -
    -----
    -
    -**********************************
    -Connect component to the root flow
    -**********************************
    -Next, connect your component to the root flow. Display the react app on the tab of your choice
    -using `configure_layout`:
    -
    -.. literalinclude:: ../../../../../src/lightning/app/cli/react-ui-template/example_app.py
    -    :emphasize-lines: 19, 27
    -
    -----
    -
    -*********************************
    -Connect React and Lightning state
    -*********************************
    -At this point, the React app will render in the Lightning app. Test it out!
    -
    -.. code:: bash
    -
    -    lightning_app run app example_app.py
    -
    -However, to make powerful React+Lightning apps, you must also connect the Lightning App state to the react app.
    -These lines enable two-way communication between the react app and the Lightning app.
    -
    -.. literalinclude:: ../../../../../src/lightning/app/cli/react-ui-template/ui/src/App.tsx
    -    :emphasize-lines: 10, 13
    -
    -----
    -
    -****************
    -Component vs App
    -****************
    -Notice that in this guide, we connected a single react app to a single component.
    -
    -.. literalinclude:: ../../../../../src/lightning/app/cli/react-ui-template/example_app.py
    -    :emphasize-lines: 6-13
    -
    -You can use this single react app for the FULL Lightning app, or you can specify a React app for EACH component.
    -
    -.. code:: python
    -    :emphasize-lines: 5, 9, 18-20
    -
    -    import lightning as L
    -
    -
    -    class ComponentA(L.LightningFlow):
    -        def configure_layout(self):
    -            return L.app.frontend.StaticWebFrontend(Path(__file__).parent / "react_app_1/dist")
    -
    -
    -    class ComponentB(L.LightningFlow):
    -        def configure_layout(self):
    -            return L.app.frontend.StaticWebFrontend(Path(__file__).parent / "react_app_2/dist")
    -
    -
    -    class HelloLitReact(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.react_app_1 = ComponentA()
    -            self.react_app_2 = ComponentB()
    -
    -        def configure_layout(self):
    -            tab_1 = {"name": "App 1", "content": self.react_app_1}
    -            tab_2 = {"name": "App 2", "content": self.react_app_2}
    -            return tab_1, tab_2
    -
    -
    -    app = L.LightningApp(HelloLitReact())
    -
    -This is a powerful idea that allows each Lightning component to have a self-contained web UI.
    
  • docs/source-app/workflows/add_web_ui/react/create_react_template.rst+0 51 removed
    @@ -1,51 +0,0 @@
    -######################################
    -Create a React Template (intermediate)
    -######################################
    -**Audience:** Anyone who wants to add a web user interface (UI) written in react to their app.
    -
    -----
    -
    -**************
    -What is react?
    -**************
    -`React.js <https://reactjs.org/>`_ is a JavaScript library for building user interfaces.
    -A huge number of websites are written in React.js (like Facebook).
    -
    -----
    -
    -************************
    -Bring your own React app
    -************************
    -If you already have a React.js app, then you don't need the section below. However, it might be helpful
    -to see our React template so you can understand how to connect it to a Lightning app.
    -
    -----
    -
    -****************************
    -Create the react-ui template
    -****************************
    -Lightning can generate a react-ui template out of the box (generated with `Vite <https://github.com/vitejs/vite>`_).
    -
    -Run this command to set up a react-ui template for a component:
    -
    -.. code:: bash
    -
    -    lightning init react-ui
    -
    -If everything was successful, run the example_app.py listed in the output of the command:
    -
    -.. code:: bash
    -
    -    INFO: Checking pre-requisites for react
    -    INFO:
    -        found npm  version: 8.5.5
    -        found node version: 16.15.0
    -        found yarn version: 1.22.10
    -
    -    ...
    -    ...
    -
    -    ⚡ run the example_app.py to see it live!
    -    lightning run app react-ui/example_app.py
    -
    -If the command didn't work, make sure to install `npm+nodejs <https://docs.npmjs.com/downloading-and-installing-node-js-and-npm>`_, and `yarn <https://classic.yarnpkg.com/lang/en/docs/install/#mac-stable>`_.
    
  • docs/source-app/workflows/add_web_ui/react/index.rst+0 106 removed
    @@ -1,106 +0,0 @@
    -:orphan:
    -
    -.. toctree::
    -   :maxdepth: 1
    -   :hidden:
    -
    -   create_react_template
    -   connect_react_and_lightning
    -   communicate_between_react_and_lightning
    -   react_development_workflow
    -
    -##########################
    -Add a web UI with React.js
    -##########################
    -**Audience:** Anyone who wants to add a web user interface (UI) written in react to their app.
    -
    -**Prereqs:** Basic html knowledge.
    -
    -----
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: 1: Create a React project template
    -   :description: Use our React template to start a react app or bring your own.
    -   :col_css: col-md-6
    -   :button_link: create_react_template.html
    -   :height: 150
    -   :tag: basic
    -
    -.. displayitem::
    -   :header: 2: Connect a React app and a Lightning app
    -   :description: Learn how to connect a React app to a Lightning app.
    -   :col_css: col-md-6
    -   :button_link: connect_react_and_lightning.html
    -   :height: 150
    -   :tag: intermediate
    -
    -.. displayitem::
    -   :header: 3: Communicate between React and Lightning
    -   :description: Learn how to communicate between a React app and a Lightning app.
    -   :col_css: col-md-6
    -   :button_link: communicate_between_react_and_lightning.html
    -   :height: 150
    -   :tag: intermediate
    -
    -.. displayitem::
    -   :header: 4: Develop like a React pro
    -   :description: Learn the development workflow of a React developer.
    -   :col_css: col-md-6
    -   :button_link: react_development_workflow.html
    -   :height: 150
    -   :tag: intermediate
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    -
    -----
    -
    -********
    -Examples
    -********
    -Here are a few example apps that use a React web UI.
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -    :header: Example 1
    -    :description: Show off your work! Contribute an example.
    -    :col_css: col-md-4
    -    :button_link: ../../../contribute_app.html
    -    :height: 150
    -    :tag: Waiting for contributed example
    -
    -.. displayitem::
    -    :header: Example 2
    -    :description: Show off your work! Contribute an example.
    -    :col_css: col-md-4
    -    :button_link: ../../../contribute_app.html
    -    :height: 150
    -    :tag: Waiting for contributed example
    -
    -.. displayitem::
    -    :header: Example 3
    -    :description: Show off your work! Contribute an example.
    -    :col_css: col-md-4
    -    :button_link: ../../../contribute_app.html
    -    :height: 150
    -    :tag: Waiting for contributed example
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/workflows/add_web_ui/react/react_development_workflow.rst+0 27 removed
    @@ -1,27 +0,0 @@
    -#########################################
    -Add a web UI with React.js (intermediate)
    -#########################################
    -**Audience:** Anyone who wants to add a web user interface (UI) written in react to their app.
    -
    -**pre-requisites:** You already have a React app connected with a Lightning app.
    -
    -----
    -
    -**********************
    -Develop your react app
    -**********************
    -Every time you make a change to your React.js app, you must call `yarn build` to apply the changes (this is a React.js thing):
    -
    -.. code:: bash
    -
    -    # if you're lost, the right folder has a package.json in it
    -    cd folder-with-ui-folder/ui
    -    yarn build
    -
    -This can get very repetitive, there is a "hot reload" command that you can enable with:
    -
    -.. code:: bash
    -
    -    # TODO
    -
    -There are many other tricks that React.js developers use to improve their development speed.
    
  • docs/source-app/workflows/add_web_ui/streamlit/basic.rst+0 186 removed
    @@ -1,186 +0,0 @@
    -###################################
    -Add a web UI with Streamlit (basic)
    -###################################
    -**Audience:** Users who want to add a web UI written with Python.
    -
    -**Prereqs:** Basic python knowledge.
    -
    -----
    -
    -******************
    -What is Streamlit?
    -******************
    -Streamlit is a web user interface builder for Python developers. Streamlit builds beautiful web pages
    -directly from Python.
    -
    -Install Streamlit with:
    -
    -.. code:: bash
    -
    -    pip install streamlit
    -
    -----
    -
    -*************************
    -Run a basic streamlit app
    -*************************
    -
    -..
    -    To explain how to use Streamlit with Lightning, let's replicate the |st_link|.
    -
    -    .. |st_link| raw:: html
    -
    -       <a href="https://01g3p9day7x7fcjtc3h50h1hfg.litng-ai-03.litng.ai/view/home" target="_blank">example running here</a>
    -
    -In the next few sections we'll build an app step-by-step.
    -First **create a file named app.py** with the app content:
    -
    -.. code:: python
    -
    -    # app.py
    -    import lightning as L
    -    import lightning.app.frontend as frontend
    -    import streamlit as st
    -
    -    def your_streamlit_app(lightning_app_state):
    -        st.write('hello world')
    -
    -    class LitStreamlit(L.LightningFlow):
    -        def configure_layout(self):
    -            return frontend.StreamlitFrontend(render_fn=your_streamlit_app)
    -
    -    class LitApp(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.lit_streamlit = LitStreamlit()
    -
    -        def run(self):
    -            self.lit_streamlit.run()
    -
    -        def configure_layout(self):
    -            tab1 = {"name": "home", "content": self.lit_streamlit}
    -            return tab1
    -
    -    app = L.LightningApp(LitApp())
    -
    -add "streamlit" to a requirements.txt file:
    -
    -.. code:: bash
    -
    -    echo 'streamlit' >> requirements.txt
    -
    -this is a best practice to make apps reproducible.
    -
    -----
    -
    -***********
    -Run the app
    -***********
    -Run the app locally to see it!
    -
    -.. code:: python
    -
    -    lightning run app app.py
    -
    -Now run it on the cloud as well:
    -
    -.. code:: python
    -
    -    lightning run app app.py --cloud
    -
    -----
    -
    -************************
    -Step-by-step walkthrough
    -************************
    -In this section, we explain each part of this code in detail.
    -
    -----
    -
    -0. Define a streamlit app
    -^^^^^^^^^^^^^^^^^^^^^^^^^
    -First, find the streamlit app you want to integrate. In this example, that app looks like:
    -
    -.. code:: python
    -
    -    import streamlit as st
    -
    -    def your_streamlit_app():
    -        st.write('hello world')
    -
    -Refer to the `Streamlit documentation <https://docs.streamlit.io/>`_ for more complex examples.
    -
    -----
    -
    -1. Add Streamlit to a component
    -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    -Link this function to the Lightning App by using the ``StreamlitFrontend`` class which needs to be returned from
    -the ``configure_layout`` method of the Lightning component you want to connect to Streamlit.
    -
    -.. code:: python
    -    :emphasize-lines: 9-11
    -
    -    # app.py
    -    import lightning as L
    -    import lightning.app.frontend as frontend
    -    import streamlit as st
    -
    -    def your_streamlit_app(lightning_app_state):
    -        st.write('hello world')
    -
    -    class LitStreamlit(L.LightningFlow):
    -        def configure_layout(self):
    -            return frontend.StreamlitFrontend(render_fn=your_streamlit_app)
    -
    -    class LitApp(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.lit_streamlit = LitStreamlit()
    -
    -        def run(self):
    -            self.lit_streamlit.run()
    -
    -        def configure_layout(self):
    -            tab1 = {"name": "home", "content": self.lit_streamlit}
    -            return tab1
    -
    -    app = L.LightningApp(LitApp())
    -
    -The ``render_fn`` argument of the ``StreamlitFrontend`` class, points to a function that runs your Streamlit app.
    -The first argument to the function is the lightning app state. Any changes to the app state update the app.
    -
    -----
    -
    -2. Route the UI in the root component
    -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    -The second step, is to tell the Root component in which tab to render this component's UI.
    -In this case, we render the ``LitStreamlit`` UI in the ``home`` tab of the application.
    -
    -.. code:: python
    -    :emphasize-lines: 22
    -
    -    # app.py
    -    import lightning as L
    -    import lightning.app.frontend as frontend
    -    import streamlit as st
    -
    -    def your_streamlit_app(lightning_app_state):
    -        st.write('hello world')
    -
    -    class LitStreamlit(L.LightningFlow):
    -        def configure_layout(self):
    -            return frontend.StreamlitFrontend(render_fn=your_streamlit_app)
    -
    -    class LitApp(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.lit_streamlit = LitStreamlit()
    -
    -        def run(self):
    -            self.lit_streamlit.run()
    -
    -        def configure_layout(self):
    -            tab1 = {"name": "home", "content": self.lit_streamlit}
    -            return tab1
    -
    -    app = L.LightningApp(LitApp())
    
  • docs/source-app/workflows/add_web_ui/streamlit/index.rst+0 84 removed
    @@ -1,84 +0,0 @@
    -:orphan:
    -
    -.. toctree::
    -   :maxdepth: 1
    -   :hidden:
    -
    -   basic
    -   intermediate
    -
    -###########################
    -Add a web UI with Streamlit
    -###########################
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: 1: Connect Streamlit
    -   :description: Learn how to connect Streamlit to a Lightning Component.
    -   :col_css: col-md-6
    -   :button_link: basic.html
    -   :height: 150
    -   :tag: basic
    -
    -.. displayitem::
    -   :header: 2: Enable two-way communication
    -   :description: Enable two-way communication between Streamlit and a Lightning App.
    -   :col_css: col-md-6
    -   :button_link: intermediate.html
    -   :height: 150
    -   :tag: intermediate
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    -
    -----
    -
    -********
    -Examples
    -********
    -Here are a few example apps that use a Streamlit web UI.
    -
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -    :header: Example 1
    -    :description: Show off your work! Contribute an example.
    -    :col_css: col-md-4
    -    :button_link: ../../../contribute_app.html
    -    :height: 150
    -    :tag: Waiting for contributed example
    -
    -.. displayitem::
    -    :header: Example 2
    -    :description: Show off your work! Contribute an example.
    -    :col_css: col-md-4
    -    :button_link: ../../../contribute_app.html
    -    :height: 150
    -    :tag: Waiting for contributed example
    -
    -.. displayitem::
    -    :header: Example 3
    -    :description: Show off your work! Contribute an example.
    -    :col_css: col-md-4
    -    :button_link: ../../../contribute_app.html
    -    :height: 150
    -    :tag: Waiting for contributed example
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/workflows/add_web_ui/streamlit/intermediate.rst+0 105 removed
    @@ -1,105 +0,0 @@
    -##########################################
    -Add a web UI with Streamlit (intermediate)
    -##########################################
    -**Audience:** Users who want to communicate between the Lightning App and Streamlit.
    -
    -**Prereqs:** Must have read the :doc:`streamlit basic <basic>` guide.
    -
    -----
    -
    -************************************
    -Interact with the App from Streamlit
    -************************************
    -The streamlit UI enables user interactions with the Lightning App via UI elements like buttons.
    -To modify the variables of a Lightning component, access the ``lightning_app_state`` variable in .
    -
    -For example, here we increase the count variable of the Lightning Component every time a user presses a button:
    -
    -.. code:: python
    -    :emphasize-lines: 8, 14
    -
    -    # app.py
    -    import lightning as L
    -    import lightning.app.frontend as frontend
    -    import streamlit as st
    -
    -
    -    def your_streamlit_app(lightning_app_state):
    -        if st.button("press to increase count"):
    -            lightning_app_state.count += 1
    -        st.write(f"current count: {lightning_app_state.count}")
    -
    -
    -    class LitStreamlit(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.count = 0
    -
    -        def configure_layout(self):
    -            return frontend.StreamlitFrontend(render_fn=your_streamlit_app)
    -
    -
    -    class LitApp(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.lit_streamlit = LitStreamlit()
    -
    -        def run(self):
    -            self.lit_streamlit.run()
    -
    -        def configure_layout(self):
    -            tab1 = {"name": "home", "content": self.lit_streamlit}
    -            return tab1
    -
    -
    -    app = L.LightningApp(LitApp())
    -
    -----
    -
    -****************************************
    -Interact with Streamlit from a component
    -****************************************
    -To update the streamlit UI from any Lightning component, update the property in the component and make sure to call ``run`` from the
    -parent component.
    -
    -In this example we update the value of the counter from the component:
    -
    -.. code:: python
    -    :emphasize-lines: 7, 15
    -
    -    # app.py
    -    import lightning as L
    -    import lightning.app.frontend as frontend
    -    import streamlit as st
    -
    -
    -    def your_streamlit_app(lightning_app_state):
    -        st.write(f"current count: {lightning_app_state.count}")
    -
    -
    -    class LitStreamlit(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.count = 0
    -
    -        def run(self):
    -            self.count += 1
    -
    -        def configure_layout(self):
    -            return frontend.StreamlitFrontend(render_fn=your_streamlit_app)
    -
    -
    -    class LitApp(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.lit_streamlit = LitStreamlit()
    -
    -        def run(self):
    -            self.lit_streamlit.run()
    -
    -        def configure_layout(self):
    -            tab1 = {"name": "home", "content": self.lit_streamlit}
    -            return tab1
    -
    -
    -    app = L.LightningApp(LitApp())
    
  • docs/source-app/workflows/add_web_ui/vue_js_intermediate.rst+0 6 removed
    @@ -1,6 +0,0 @@
    -:orphan:
    -
    -#######################################
    -Add a web UI with Vue.js (intermediate)
    -#######################################
    -coming...
    
  • docs/source-app/workflows/arrange_tabs/arrange_app_basic.rst+0 69 removed
    @@ -1,69 +0,0 @@
    -########################
    -Arrange app tabs (basic)
    -########################
    -**Audience:** Users who want to control the layout of their app user interface.
    -
    -----
    -
    -*****************************
    -Enable a full-page single tab
    -*****************************
    -
    -To enable a single tab on the app UI, return a single dictionary from the ``configure_layout`` method:
    -
    -.. code:: python
    -    :emphasize-lines: 9
    -
    -    import lightning as L
    -
    -
    -    class DemoComponent(L.demo.dumb_component):
    -        def configure_layout(self):
    -            tab1 = {"name": "THE TAB NAME", "content": self.component_a}
    -            return tab1
    -
    -
    -    app = L.LightningApp(DemoComponent())
    -
    -
    -The "name" key defines the visible name of the tab on the UI. It also shows up in the URL.
    -The **"content"** key defines the target component to render in that tab.
    -When returning a single tab element like shown above, the UI will display it in full-page mode.
    -
    -
    -----
    -
    -********************
    -Enable multiple tabs
    -********************
    -
    -.. code:: python
    -    :emphasize-lines: 7
    -
    -    import lightning as L
    -
    -
    -    class DemoComponent(L.demo.dumb_component):
    -        def configure_layout(self):
    -            tab1 = {"name": "Tab A", "content": self.component_a}
    -            tab2 = {"name": "Tab B", "content": self.component_b}
    -            return tab1, tab2
    -
    -
    -    app = L.LightningApp(DemoComponent())
    -
    -The order matters! Try any of the following configurations:
    -
    -.. code:: python
    -    :emphasize-lines: 4, 9
    -
    -    def configure_layout(self):
    -        tab1 = {"name": "Tab A", "content": self.component_a}
    -        tab2 = {"name": "Tab B", "content": self.component_b}
    -        return tab1, tab2
    -
    -
    -    def configure_layout(self):
    -        tab1 = {"name": "Tab A", "content": self.component_a}
    -        tab2 = {"name": "Tab B", "content": self.component_b}
    -        return tab2, tab1
    
  • docs/source-app/workflows/arrange_tabs/arrange_app_intermediate.rst+0 21 removed
    @@ -1,21 +0,0 @@
    -###############################
    -Arrange app tabs (intermediate)
    -###############################
    -
    -.. TODO:: fill-in
    -
    -----
    -
    -***********************************
    -Render components with a defined UI
    -***********************************
    -
    -component directly
    -
    -----
    -
    -*************
    -Render a link
    -*************
    -
    -tensorboard link
    
  • docs/source-app/workflows/arrange_tabs/index_content.rst+0 34 removed
    @@ -1,34 +0,0 @@
    -.. toctree::
    -   :maxdepth: 1
    -   :hidden:
    -
    -   arrange_app_basic
    -   arrange_app_intermediate
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. Add callout items below this line
    -
    -.. displayitem::
    -   :header: Basic
    -   :description: Learn how to enable and layout your app UI
    -   :col_css: col-md-6
    -   :button_link: arrange_app_basic.html
    -   :height: 150
    -   :tag: basic
    -
    -.. displayitem::
    -   :header: Intermediate
    -   :description: Learn about all the possible ways of rendering a component.
    -   :col_css: col-md-6
    -   :button_link: arrange_app_intermediate.html
    -   :height: 150
    -   :tag: intermediate
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/workflows/arrange_tabs/index.rst+0 5 removed
    @@ -1,5 +0,0 @@
    -################
    -Arrange App Tabs
    -################
    -
    -.. include:: index_content.rst
    
  • docs/source-app/workflows/build_command_line_interface/app.py+0 35 removed
    @@ -1,35 +0,0 @@
    -from commands.notebook.run import RunNotebook, RunNotebookConfig
    -from lit_jupyter import JupyterLab
    -
    -from lightning.app import LightningFlow, LightningApp, CloudCompute
    -from lightning.app.structures import Dict
    -
    -
    -class Flow(LightningFlow):
    -    def __init__(self):
    -        super().__init__()
    -        self.notebooks = Dict()
    -
    -    # 1. Annotates the handler input with the Notebook config.
    -    def run_notebook(self, config: RunNotebookConfig):
    -        if config.name in self.notebooks:
    -            return f"The Notebook {config.name} already exists."
    -        else:
    -            # 2. Dynamically creates the Notebook if it doesn't exist and runs it.
    -            self.notebooks[config.name] = JupyterLab(
    -                cloud_compute=CloudCompute(config.cloud_compute)
    -            )
    -            self.notebooks[config.name].run()
    -            return f"The Notebook {config.name} was created."
    -
    -    def configure_commands(self):
    -        # 3. Returns a list of dictionaries with the format:
    -        # {"command_name": CustomClientCommand(method=self.custom_server_handler)}
    -        return [{"run notebook": RunNotebook(method=self.run_notebook)}]
    -
    -    def configure_layout(self):
    -        # 4. Dynamically displays the Notebooks in the Lightning App View.
    -        return [{"name": n, "content": w} for n, w in self.notebooks.items()]
    -
    -
    -app = LightningApp(Flow())
    
  • docs/source-app/workflows/build_command_line_interface/cli_client.rst+0 175 removed
    @@ -1,175 +0,0 @@
    -:orphan:
    -
    -######################################################
    -2. Develop a CLI with server and client code execution
    -######################################################
    -
    -We've learned how to create a simple command-line interface. But in real-world use-cases, an App Builder wants to provide more complex functionalities where trusted code is executed on the client side.
    -
    -Lightning provides a flexible way to create complex CLI without much effort.
    -
    -In this example, we’ll create a CLI to dynamically run Notebooks:
    -
    -
    -----
    -
    -**************************
    -1. Implement a complex CLI
    -**************************
    -
    -First of all, lets' create the following file structure:
    -
    -.. code-block:: python
    -
    -    app_folder/
    -        commands/
    -            notebook/
    -                run.py
    -        app.py
    -
    -We'll use the `Jupyter-Component <https://github.com/Lightning-AI/LAI-Jupyter-Component>`_. Follow the installation steps on the repo to install the Component.
    -
    -Add the following code to ``commands/notebook/run.py``:
    -
    -.. literalinclude:: commands/notebook/run.py
    -
    -Add the following code to ``app.py``:
    -
    -.. literalinclude:: app.py
    -
    -----
    -
    -**********************************************
    -2. Run the App and check the API documentation
    -**********************************************
    -
    -In a terminal, run the following command and open ``http://127.0.0.1:7501/docs`` in a browser.
    -
    -.. code-block:: python
    -
    -    lightning_app run app app.py
    -    Your Lightning App is starting. This won't take long.
    -    INFO: Your app has started. View it in your browser: http://127.0.0.1:7501/view
    -
    -----
    -
    -***************************
    -3. Connect to a running App
    -***************************
    -
    -In another terminal, connect to the running App.
    -When you connect to an App, the Lightning CLI is replaced by the App CLI. To exit the App CLI, you need to run ``lightning_app disconnect``.
    -
    -.. code-block::
    -
    -    lightning_app connect localhost
    -
    -    Storing `run_notebook` under /Users/thomas/.lightning/lightning_connection/commands/run_notebook.py
    -    You can review all the downloaded commands under /Users/thomas/.lightning/lightning_connection/commands folder.
    -    You are connected to the local Lightning App.
    -
    -To see a list of available commands:
    -
    -.. code-block::
    -
    -    lightning_app --help
    -
    -    You are connected to the cloud Lightning App: localhost.
    -    Usage: lightning_app [OPTIONS] COMMAND [ARGS]...
    -
    -    --help     Show this message and exit.
    -
    -    Lightning App Commands
    -        run notebook Run a Notebook.
    -
    -
    -To find the arguments of the commands:
    -
    -.. code-block::
    -
    -    lightning_app run notebook --help
    -
    -    You are connected to the cloud Lightning App: localhost.
    -    usage: notebook [-h] [--name NAME] [--cloud_compute CLOUD_COMPUTE]
    -
    -    Run Notebook Parser
    -
    -    optional arguments:
    -        -h, --help            show this help message and exit
    -        --name NAME
    -        --cloud_compute CLOUD_COMPUTE
    -
    -----
    -
    -********************
    -4. Execute a command
    -********************
    -
    -And then you can trigger the command-line exposed by your App.
    -
    -Run the first Notebook with the following command:
    -
    -.. code-block:: python
    -
    -    lightning_app run notebook --name="my_notebook"
    -    WARNING: Lightning Command Line Interface is an experimental feature and unannounced changes are likely.
    -    The notebook my_notebook was created.
    -
    -And run a second notebook.
    -
    -.. code-block:: python
    -
    -    lightning_app run notebook --name="my_notebook_2"
    -    WARNING: Lightning Command Line Interface is an experimental feature and unannounced changes are likely.
    -    The notebook my_notebook_2 was created.
    -
    -Here is a recording of the Lightning App:
    -
    -.. video:: https://pl-public-data.s3.amazonaws.com/assets_lightning/commands_1.mp4
    -    :poster: https://pl-public-data.s3.amazonaws.com/assets_lightning/commands_1.png
    -    :width: 600
    -    :class: background-video
    -    :autoplay:
    -    :loop:
    -    :muted:
    -
    -**************************
    -5. Disconnect from the App
    -**************************
    -
    -To exit the App CLI, you need to run **lightning disconnect**.
    -
    -.. code-block::
    -
    -    lightning_app disconnect
    -    You are disconnected from the local Lightning App.
    -
    -----
    -
    -**********
    -Learn more
    -**********
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: 1. Develop a CLI with server side code only
    -   :description: Learn how to develop a simple CLI for your App.
    -   :col_css: col-md-6
    -   :button_link: cli.html
    -   :height: 150
    -
    -.. displayitem::
    -   :header: Develop a RESTful API
    -   :description: Learn how to develop an API for your App.
    -   :col_css: col-md-6
    -   :button_link: ../build_rest_api/index.html
    -   :height: 150
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/workflows/build_command_line_interface/cli.rst+0 144 removed
    @@ -1,144 +0,0 @@
    -:orphan:
    -
    -###########################################
    -1. Develop a CLI with server side code only
    -###########################################
    -
    -We are going to learn how to create a simple command-line interface.
    -
    -Lightning provides a flexible way to create complex CLI without much effort.
    -
    -----
    -
    -*************************
    -1. Implement a simple CLI
    -*************************
    -
    -To create your first CLI, you need to override the :class:`~lightning.app.core.flow.LightningFlow.configure_commands` hook and return a list of dictionaries where the keys are the commands and the values are the server side handlers.
    -
    -First, create a file ``app.py`` and copy-paste the following code in to the file:
    -
    -.. literalinclude:: example_command.py
    -
    -----
    -
    -**************
    -2. Run the App
    -**************
    -
    -Execute the following command in a terminal:
    -
    -.. code-block::
    -
    -    lightning_app run app app.py
    -
    -The following appears the terminal:
    -
    -.. code-block::
    -
    -    Your Lightning App is starting. This won't take long.
    -    INFO: Your app has started. View it in your browser: http://127.0.0.1:7501/view
    -    []
    -
    -----
    -
    -***************************
    -3. Connect to a running App
    -***************************
    -
    -In another terminal, connect to the running App.
    -When you connect to an App, the Lightning CLI is replaced by the App CLI. To exit the App CLI, you need to run ``lightning_app disconnect``.
    -
    -.. code-block::
    -
    -    lightning_app connect localhost
    -
    -To see a list of available commands:
    -
    -.. code-block::
    -
    -    lightning_app --help
    -    You are connected to the cloud Lightning App: localhost.
    -    Usage: lightning_app [OPTIONS] COMMAND [ARGS]...
    -
    -    --help     Show this message and exit.
    -
    -    Lightning App Commands
    -        add Add a name.
    -
    -To find the arguments of the commands:
    -
    -.. code-block::
    -
    -    lightning_app add --help
    -    You are connected to the cloud Lightning App: localhost.
    -    Usage: lightning_app add [ARGS]...
    -
    -    Options
    -        name: Add description
    -
    -----
    -
    -********************
    -4. Execute a command
    -********************
    -
    -Trigger the command line exposed by your App:
    -
    -.. code-block::
    -
    -    lightning_app add --name=my_name
    -    WARNING: Lightning Command Line Interface is an experimental feature and unannounced changes are likely.
    -
    -In your first terminal, **Received name: my_name** and **["my_name"]** are printed.
    -
    -.. code-block::
    -
    -    Your Lightning App is starting. This won't take long.
    -    INFO: Your app has started. View it in your browser: http://127.0.0.1:7501/view
    -    []
    -    Received name: my_name
    -    ["my_name]
    -
    -----
    -
    -**************************
    -5. Disconnect from the App
    -**************************
    -
    -To exit the App CLI, you need to run ``lightning_app disconnect``.
    -
    -.. code-block::
    -
    -    lightning_app disconnect
    -    You are disconnected from the local Lightning App.
    -
    -----
    -
    -**********
    -Learn more
    -**********
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: 2. Implement a CLI with client side code execution
    -   :description: Learn how to develop a complex API for your application
    -   :col_css: col-md-6
    -   :button_link: cli_client.html
    -   :height: 150
    -
    -.. displayitem::
    -   :header: Develop a RESTful API
    -   :description: Learn how to develop an API for your application.
    -   :col_css: col-md-6
    -   :button_link: ../build_rest_api/index.html
    -   :height: 150
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/workflows/build_command_line_interface/commands/__init__.py+0 0 removed
  • docs/source-app/workflows/build_command_line_interface/commands/notebook/__init__.py+0 0 removed
  • docs/source-app/workflows/build_command_line_interface/commands/notebook/run.py+0 33 removed
    @@ -1,33 +0,0 @@
    -from argparse import ArgumentParser
    -from uuid import uuid4
    -
    -from pydantic import BaseModel
    -
    -from lightning.app.utilities.commands import ClientCommand
    -
    -
    -class RunNotebookConfig(BaseModel):
    -    name: str
    -    cloud_compute: str
    -
    -
    -class RunNotebook(ClientCommand):
    -    description = "Run a Notebook."
    -
    -    def run(self):
    -        # 1. Define your own argument parser. You can use argparse, click, etc...
    -        parser = ArgumentParser(description='Run Notebook Parser')
    -        parser.add_argument("--name", type=str, default=None)
    -        parser.add_argument("--cloud_compute", type=str, default="cpu")
    -        hparams = parser.parse_args()
    -
    -        # 2. Invoke the server side handler by sending a payload.
    -        response = self.invoke_handler(
    -            config=RunNotebookConfig(
    -                name=hparams.name or str(uuid4()),
    -                cloud_compute=hparams.cloud_compute,
    -            ),
    -        )
    -
    -        # 3. Print the server response.
    -        print(response)
    
  • docs/source-app/workflows/build_command_line_interface/example_command.py+0 25 removed
    @@ -1,25 +0,0 @@
    -from lightning import LightningApp, LightningFlow
    -
    -
    -class Flow(LightningFlow):
    -    def __init__(self):
    -        super().__init__()
    -        self.names = []
    -
    -    def run(self):
    -        print(self.names)
    -
    -    def add_name(self, name: str):
    -        """Add a name."""
    -        print(f"Received name: {name}")
    -        self.names.append(name)
    -
    -    def configure_commands(self):
    -        # This can be invoked with `lightning add --name=my_name`
    -        commands = [
    -            {"add": self.add_name},
    -        ]
    -        return commands
    -
    -
    -app = LightningApp(Flow())
    
  • docs/source-app/workflows/build_command_line_interface/index_content.rst+0 51 removed
    @@ -1,51 +0,0 @@
    -**************************************
    -Develop a command line interface (CLI)
    -**************************************
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: 1. Develop a CLI with server side code only
    -   :description: Learn how to develop a simple CLI for your application
    -   :col_css: col-md-6
    -   :button_link: cli.html
    -   :height: 150
    -
    -.. displayitem::
    -   :header: 2. Develop a CLI with server and client code execution
    -   :description: Learn how to develop a complex CLI for your application
    -   :col_css: col-md-6
    -   :button_link: cli_client.html
    -   :height: 150
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    -
    -
    -----
    -
    -**********
    -Learn more
    -**********
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: Develop a RESTful API
    -   :description: Learn how to develop an API for your application.
    -   :col_css: col-md-6
    -   :button_link: ../build_rest_api/index.html
    -   :height: 150
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/workflows/build_command_line_interface/index.rst+0 48 removed
    @@ -1,48 +0,0 @@
    -############################
    -Command-line Interface (CLI)
    -############################
    -
    -**Audience:** Users looking to create a command line interface (CLI) for their application.
    -
    -----
    -
    -**************
    -What is a CLI?
    -**************
    -
    -A Command-line Interface (CLI) is an user interface (UI) in a terminal to interact with a specific program.
    -
    -.. note::
    -
    -    The Lightning guideline to build CLI is `lightning_app <VERB> <NOUN> ...` or `<ACTION> <OBJECT> ...`.
    -
    -As an example, Lightning provides a CLI to interact with your Lightning Apps and the `lightning.ai <https://lightning.ai/>`_ platform as follows:
    -
    -.. code-block:: bash
    -
    -    main
    -    ├── fork - Forks an App.
    -    ├── init - Initializes a Lightning App and/or Component.
    -    │   ├── app
    -    │   ├── component
    -    │   ├── pl-app - Creates an App from your PyTorch Lightning source files.
    -    │   └── react-ui - Creates a React UI to give a Lightning Component a React.js web UI
    -    ├── install - Installs a Lightning App and/or Component.
    -    │   ├── app
    -    │   └── component
    -    ├── list - Lists Lightning AI self-managed resources (apps)
    -    │   └── apps - Lists your Lightning AI Apps.
    -    ├── login - Logs in to your lightning.ai account.
    -    ├── logout - Logs out of your lightning.ai account.
    -    ├── run - Runs a Lightning App locally or on the cloud.
    -    │   └── app - Runs an App from a file.
    -    ├── show - Shows given resource.
    -    │   └── logs - Shows cloud application logs. By default prints logs for all currently available Components.
    -    ├── stop - Stops your App.
    -    └── tree - Shows the command tree of your CLI.
    -
    -Learn more about `Command-line interfaces here <https://en.wikipedia.org/wiki/Command-line_interface>`_.
    -
    -----
    -
    -.. include:: index_content.rst
    
  • docs/source-app/workflows/build_command_line_interface/post_example.py+0 26 removed
    @@ -1,26 +0,0 @@
    -from lightning.app import LightningFlow, LightningApp
    -from lightning.app.api import Post
    -
    -
    -class Flow(LightningFlow):
    -    # 1. Define the state
    -    def __init__(self):
    -        super().__init__()
    -        self.names = []
    -
    -    # 2. Optional, but used to validate names
    -    def run(self):
    -        print(self.names)
    -
    -    # 3. Method executed when a request is received.
    -    def handle_post(self, name: str):
    -        self.names.append(name)
    -        return f'The name {name} was registered'
    -
    -    # 4. Defines this Component's Restful API. You can have several routes.
    -    def configure_api(self):
    -        # Your own defined route and handler
    -        return [Post(route="/name", method=self.handle_post)]
    -
    -
    -app = LightningApp(Flow())
    
  • docs/source-app/workflows/build_lightning_app/from_pytorch_lightning_script.rst+0 109 removed
    @@ -1,109 +0,0 @@
    -#######################################################
    -Develop a Lightning App from a PyTorch Lightning script
    -#######################################################
    -
    -**Audience:** Users who want to develop a Lightning App (App) from their PyTorch Lightning (PL) scripts.
    -
    -----
    -
    -*************************************************************
    -What developing a Lightning App from a PL script does for you
    -*************************************************************
    -
    -Developing an App from a PL script allows you to immediately run on the cloud and share the progress with friends.
    -Once you're happy with your model, you can immediately expand beyond just model development to things like
    -making your own inference APIs, research demos, or even speeding up your data pipeline.
    -
    -The PyTorch Lightning App is your entry point to the full end-to-end ML licefycle.
    -
    -----
    -
    -******************
    -Develop a template
    -******************
    -
    -To develop a template from a PyTorch Lightning script, use this command:
    -
    -.. code:: bash
    -
    -    lightning_app init pl-app path/to/the/pl_script.py
    -
    -
    -If your script is not at the root of the project folder, and you'd like to include all source files within that folder, you can specify the root path as the first argument:
    -
    -.. code:: bash
    -
    -    lightning_app init pl-app path/to/project/root path/to/the/pl_script.py
    -
    -
    -The default trainer App lets you train a model with a beautiful UI locally and on the cloud with zero effort!
    -
    -----
    -
    -***********
    -Run the App
    -***********
    -
    -.. note:: This section is under construction.
    -
    -Run the App locally:
    -
    -.. code:: bash
    -
    -    lightning_app run app pl-app/app.py
    -
    -Or run the App on the cloud so you can share with collaborators and even use all the cloud GPUs you want.
    -
    -.. code:: bash
    -
    -    lightning_app run app pl-app/app.py --cloud
    -
    -
    -.. figure:: https://storage.googleapis.com/grid-packages/pytorch-lightning-app/docs-thumbnail.png
    -    :alt: Screenshot of the PyTorch Lightning app running in the cloud
    -
    -
    -----
    -
    -*******************
    -Modify the template
    -*******************
    -
    -The command above generates an App file like this:
    -
    -.. TODO:: list the file and show how to extend it
    -
    -.. code:: python
    -
    -    from your_app_name import ComponentA, ComponentB
    -
    -    import lightning as L
    -
    -
    -    class LitApp(L.LightningFlow):
    -        def __init__(self) -> None:
    -            super().__init__()
    -            self.component_a = ComponentA()
    -            self.component_b = ComponentB()
    -
    -        def run(self):
    -            self.component_a.run()
    -            self.component_b.run()
    -
    -
    -    app = L.LightningApp(LitApp())
    -
    -Now you can add your own components as you wish!
    -
    -----
    -
    -************
    -Known issues
    -************
    -
    -- The UI takes a couple seconds to load when opening the App, so please be patient.
    -- The timer resets when refreshing the page.
    -- The UI for adding new environment variables does not provide an option to delete an entry.
    -- A bug exists that leaves the script hanging at the start of training when using the DDP strategy.
    -- DDP-spawn is not supported due to pickling issues.
    -- It is currently not possible to submit a new run once the script has finished or failed.
    
  • docs/source-app/workflows/build_lightning_app/from_scratch_content.rst+0 60 removed
    @@ -1,60 +0,0 @@
    -
    -**************
    -WAIT!
    -**************
    -Before you build a Lightning App from scratch, see if you can find an app that is similar to what you need
    -in the `Lightning App Gallery <https://lightning.ai/apps>`_.
    -
    -Once you find the Lightning App you want, press "Clone & Run" to see it running on the cloud, then download the code
    -and change what you want!
    -
    -----
    -
    -******************
    -Build from scratch
    -******************
    -If you didn't find a Lightning App similar to the one you need, simply create a file named **app.py** with these contents:
    -
    -.. code:: python
    -
    -    import lightning as L
    -
    -
    -    class WordComponent(L.LightningWork):
    -        def __init__(self, word):
    -            super().__init__()
    -            self.word = word
    -
    -        def run(self):
    -            print(self.word)
    -
    -
    -    class LitApp(L.LightningFlow):
    -        def __init__(self) -> None:
    -            super().__init__()
    -            self.hello = WordComponent("hello")
    -            self.world = WordComponent("world")
    -
    -        def run(self):
    -            print("This is a simple Lightning app, make a better app!")
    -            self.hello.run()
    -            self.world.run()
    -
    -
    -    app = L.LightningApp(LitApp())
    -
    -----
    -
    -Run the Lightning App
    -^^^^^^^^^^^^^^^^^^^^^
    -Run the Lightning App locally:
    -
    -.. code:: bash
    -
    -    lightning_app run app app.py
    -
    -Run the Lightning App on the cloud:
    -
    -.. code:: bash
    -
    -    lightning_app run app app.py --cloud
    
  • docs/source-app/workflows/build_lightning_app/from_scratch.rst+0 11 removed
    @@ -1,11 +0,0 @@
    -####################################
    -Develop a Lightning App from Scratch
    -####################################
    -
    -**Audience:** Users who want to develop a Lightning App from scratch.
    -
    -**Prereqs:** You must have finished the `Basic levels <https://lightning.ai/lightning-docs/levels/basic/>`_.
    -
    -----
    -
    -.. include:: from_scratch_content.rst
    
  • docs/source-app/workflows/build_lightning_app/index_content.rst+0 32 removed
    @@ -1,32 +0,0 @@
    -.. toctree::
    -   :maxdepth: 1
    -   :hidden:
    -
    -   from_scratch
    -   from_pytorch_lightning_script
    -
    -.. raw:: html
    -
    -    <div class="display-card-container">
    -        <div class="row">
    -
    -.. displayitem::
    -   :header: Develop a Lightning App from scratch
    -   :description: Learn how to Develop a Lightning App from scratch
    -   :col_css: col-md-6
    -   :button_link: from_scratch.html
    -   :height: 150
    -   :tag: basic
    -
    -.. displayitem::
    -   :header: Develop an App from a PyTorch Lightning script
    -   :description: Share your PyTorch Lightning training on the cloud, run on cloud GPUs, or extend your App
    -   :col_css: col-md-6
    -   :button_link: from_pytorch_lightning_script.html
    -   :height: 150
    -   :tag: basic
    -
    -.. raw:: html
    -
    -        </div>
    -    </div>
    
  • docs/source-app/workflows/build_lightning_app/index.rst+0 11 removed
    @@ -1,11 +0,0 @@
    -:orphan:
    -
    -#######################
    -Develop a Lightning App
    -#######################
    -
    -A Lightning App (App) is a collection of components interacting together. Learn how to develop a basic App template.
    -
    -----
    -
    -.. include:: index_content.rst
    
  • docs/source-app/workflows/build_lightning_component/basic.rst+0 9 removed
    @@ -1,9 +0,0 @@
    -#############################
    -Develop a Lightning Component
    -#############################
    -
    -**Audience:** Users who want to develop a Lightning Component.
    -
    -----
    -
    -.. include:: from_scratch_component_content.rst
    
  • docs/source-app/workflows/build_lightning_component/from_scratch_component_content.rst+0 153 removed
    @@ -1,153 +0,0 @@
    -*******************************
    -LightningFlow vs. LightningWork
    -*******************************
    -
    -.. _flow_vs_work:
    -
    -.. raw:: html
    -
    -    <img src="https://pl-bolts-doc-images.s3.us-east-2.amazonaws.com/flow_work_choice.png"
    -        alt="Choosing between LightningFlow and LightningWork"
    -        style="display: block; margin-left: auto; margin-right: auto; width: 70%; max-width: 600px; padding: 20px 0 40px 0"
    -    >
    -
    -There are two types of components in Lightning, **LightningFlow** and **LightningWork**.
    -
    -Use a **LightningFlow** component for any programming logic that runs in less than 1 second.
    -
    -.. code:: python
    -
    -    for i in range(10):
    -        print(f"{i}: this kind of code belongs in a LightningFlow")
    -
    -Use a **LightningWork** component for any programming logic that takes more than 1 second or requires its own hardware.
    -
    -.. code:: python
    -
    -    from time import sleep
    -
    -    for i in range(100000):
    -        sleep(2.0)
    -        print(f"{i} LightningWork: work that is long running or may never end (like a server)")
    -
    -----
    -
    -**************************************************
    -What developing a Lightning Component does for you
    -**************************************************
    -Lightning Components break up complex systems into modular components. The first obvious benefit is that components
    -can be reused across other apps. This means you can build once, test it and forget it.
    -
    -As a researcher it also means that your code can be taken to production without needing a team of engineers to help
    -productionize it.
    -
    -As a machine learning engineer, it means that your cloud system is:
    -
    -- fault tolerant
    -- cloud agnostic
    -- testable (unlike YAML/CI/CD code)
    -- version controlled
    -- enables cross-functional collaboration
    -
    -----
    -
    -**************
    -WAIT!
    -**************
    -Before you build a Lightning component from scratch, see if you can find a component that is similar to what you need
    -in the `Lightning component Gallery <https://lightning.ai/components>`_.
    -
    -Once you find the component you want, download the code and change what you want!
    -
    -----
    -
    -*****************************************
    -Build a Lighitning component from scratch
    -*****************************************
    -If you didn't find a Lightning component similar to the one you need, you can build one from scratch.
    -
    -----
    -
    -Build a LightningFlow
    -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    -To implement a LightningFlow, simply subclass ``LightningFlow`` and define the run method:
    -
    -.. code:: python
    -    :emphasize-lines: 5
    -
    -    # app.py
    -    import lightning as L
    -
    -
    -    class LitFlow(L.LightningFlow):
    -        def run(self):
    -            for i in range(10):
    -                print(f"{i}: this kind of code belongs in a LightningFlow")
    -
    -
    -    app = L.LightningApp(LitFlow())
    -
    -run the app
    -
    -.. code:: bash
    -
    -    lightning_app run app app.py
    -
    -----
    -
    -Build a LightningWork
    -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    -Only implement a LightningWork if this particular piece of code:
    -
    -- takes more than 1 second to execute
    -- requires its own set of cloud resources
    -- or both
    -
    -To implement a LightningWork, simply subclass ``LightningWork`` and define the run method:
    -
    -.. code:: python
    -    :emphasize-lines: 6
    -
    -    # app.py
    -    from time import sleep
    -    import lightning as L
    -
    -
    -    class LitWork(L.LightningWork):
    -        def run(self):
    -            for i in range(100000):
    -                sleep(2.0)
    -                print(f"{i} LightningWork: work that is long running or may never end (like a server)")
    -
    -A LightningWork must always be attached to a LightningFlow and explicitly asked to ``run()``:
    -
    -.. code:: python
    -    :emphasize-lines: 13, 16
    -
    -    from time import sleep
    -    import lightning as L
    -
    -
    -    class LitWork(L.LightningWork):
    -        def run(self):
    -            for i in range(100000):
    -                sleep(2.0)
    -                print(f"{i} LightningWork: work that is long running or may never end (like a server)")
    -
    -
    -    class LitFlow(L.LightningFlow):
    -        def __init__(self):
    -            super().__init__()
    -            self.lit_work = LitWork()
    -
    -        def run(self):
    -            self.lit_work.run()
    -
    -
    -    app = L.LightningApp(LitFlow())
    -
    -run the app
    -
    -.. code:: bash
    -
    -    lightning_app run app app.py
    
  • .github/actions/pkg-install/action.yml+1 1 modified
    @@ -25,7 +25,7 @@ runs:
           run: |
             import os, glob
     
    -        lut = {'app': 'lightning_app', 'fabric': 'lightning_fabric', 'pytorch': 'pytorch_lightning'}
    +        lut = {'fabric': 'lightning_fabric', 'pytorch': 'pytorch_lightning'}
             act_pkg = lut.get('${{inputs.pkg-name}}', 'lightning')
             pkg_sdist = glob.glob('*.tar.gz')[0]
             pkg_wheel = glob.glob('*.whl')[0]
    
  • .github/actions/prep-apps/action.yml+0 38 removed
    @@ -1,38 +0,0 @@
    -name: Adjust App environment
    -description: make adjustment specific for selected App
    -
    -inputs:
    -  name:
    -    description: application name
    -    required: true
    -
    -runs:
    -  using: "composite"
    -  steps:
    -    - name: adjust env -> Flashy
    -      if: inputs.name == 'flashy'
    -      working-directory: tests/_flagship-app
    -      run: |
    -        ls -l .
    -        pip install -r requirements-dev.txt -f $TORCH_URL
    -        pip install -e . -f $TORCH_URL
    -      shell: bash
    -
    -    - name: adjust env -> Muse
    -      if: inputs.name == 'muse'
    -      working-directory: tests/
    -      run: |
    -        pip install -e _flagship-app -f $TORCH_URL
    -        cp _flagship-app/tests/test_app.py \
    -          integrations_app/flagship/test_${{ inputs.name }}.py
    -      shell: bash
    -
    -    - name: adjust env -> Jupyter
    -      if: inputs.name == 'jupyter'
    -      working-directory: tests/
    -      run: |
    -        pip install -e _flagship-app -f $TORCH_URL
    -        # pip install -r _flagship-app/tests/requirements-dev.txt
    -        cp _flagship-app/tests/test_jupyter_app.py \
    -          integrations_app/flagship/test_${{ inputs.name }}.py
    -      shell: bash
    
  • .github/checkgroup.yml+0 121 modified
    @@ -213,121 +213,6 @@ subprojects:
         checks:
           - "test-on-tpus (pytorch, pjrt, v4-8)"
     
    -  # SECTION: lightning_app
    -
    -  - id: "lightning_app: Tests workflow"
    -    paths:
    -      - ".actions/*"
    -      - ".github/workflows/ci-tests-app.yml"
    -      - "src/lightning/app/**"
    -      - "src/lightning_app/*"
    -      - "tests/tests_app/**"
    -      - "requirements/app/**"
    -      - "setup.py"
    -      - "!requirements/*/docs.txt"
    -      - "!*.md"
    -      - "!**/*.md"
    -    checks:
    -      - "app-pytest (macOS-12, lightning, 3.8, latest)"
    -      - "app-pytest (macOS-12, lightning, 3.8, oldest)"
    -      - "app-pytest (macOS-12, app, 3.9, latest)"
    -      - "app-pytest (macOS-12, app, 3.11, latest)"
    -      - "app-pytest (ubuntu-20.04, lightning, 3.8, latest)"
    -      - "app-pytest (ubuntu-20.04, lightning, 3.8, oldest)"
    -      - "app-pytest (ubuntu-20.04, app, 3.9, latest)"
    -      - "app-pytest (ubuntu-22.04, app, 3.11, latest)"
    -      - "app-pytest (windows-2022, lightning, 3.8, latest)"
    -      - "app-pytest (windows-2022, lightning, 3.8, oldest)"
    -      - "app-pytest (windows-2022, app, 3.8, latest)"
    -      - "app-pytest (windows-2022, app, 3.11, latest)"
    -
    -  - id: "lightning_app: Examples"
    -    paths:
    -      - ".actions/*"
    -      - ".github/workflows/ci-examples-app.yml"
    -      - "src/lightning/app/**"
    -      - "src/lightning_app/*"
    -      - "tests/integrations_app/**"
    -      - "!tests/integrations_app/flagship/**"
    -      - "examples/app/**"
    -      - "requirements/app/**"
    -      - "setup.py"
    -      - "!requirements/*/docs.txt"
    -      - "!*.md"
    -      - "!**/*.md"
    -    checks:
    -      - "app-examples (macOS-12, lightning, 3.9, latest)"
    -      - "app-examples (macOS-12, lightning, 3.9, oldest)"
    -      - "app-examples (macOS-12, app, 3.9, latest)"
    -      - "app-examples (ubuntu-20.04, lightning, 3.9, latest)"
    -      - "app-examples (ubuntu-20.04, lightning, 3.9, oldest)"
    -      - "app-examples (ubuntu-20.04, app, 3.9, latest)"
    -      - "app-examples (windows-2022, lightning, 3.9, latest)"
    -      - "app-examples (windows-2022, lightning, 3.9, oldest)"
    -      - "app-examples (windows-2022, app, 3.9, latest)"
    -
    -  #- id: "lightning: Flagships"
    -  #  paths:
    -  #    - ".github/workflows/_flagship-apps.yml"
    -  #    - ".github/workflows/ci-flagship-apps.yml"
    -  #    - "github/actions/prep-apps/action.yml"
    -  #    - "tests/integrations_app/flagship/**"
    -  #  checks:
    -  #    - "test-flagships / run-flagships (flashy, Lightning-Universe/Flashy-app)"
    -
    -  - id: "lightning: Store"
    -    paths:
    -      - ".github/workflows/ci-tests-store.yml"
    -      - "src/lightning/__init__.py"
    -      - "src/lightning/__setup__.py"
    -      - "src/lightning/__version__.py"
    -      - "src/lightning/store/**"
    -      - "tests/tests_store/**"
    -    checks:
    -      - "store-cpu (macOS-14, lightning, 3.10, 2.0)"
    -      - "store-cpu (ubuntu-20.04, lightning, 3.10, 2.0)"
    -      - "store-cpu (windows-2022, lightning, 3.10, 2.0)"
    -
    -  # FixMe: re-enable when BE stabilize
    -  # - id: "lightning_app: Azure"
    -  #   paths:
    -  #     - ".actions/*"
    -  #     - ".azure/app-cloud-e2e.yml"
    -  #     - "src/lightning/__about__.py"
    -  #     - "src/lightning/__init__.py"
    -  #     - "src/lightning/__main__.py"
    -  #     - "src/lightning/__setup__.py"
    -  #     - "src/lightning/__version__.py"
    -  #     - "src/lightning/app/**"
    -  #     - "src/lightning_app/*"
    -  #     - "examples/app/**"
    -  #     - "requirements/app/**"
    -  #     - "tests/integrations_app/**"
    -  #     - "!tests/integrations_app/flagship/**"
    -  #     - "setup.py"
    -  #     - "!requirements/*/docs.txt"
    -  #     - "!*.md"
    -  #     - "!**/*.md"
    -  #   checks:
    -  #     - "App.cloud-e2e"
    -
    -  - id: "lightning_app: Docs"
    -    paths:
    -      - ".actions/*"
    -      - "src/lightning/app/**"
    -      - "src/lightning_app/*"
    -      - "docs/source-app/**"
    -      - ".github/workflows/docs-build.yml"
    -      - "requirements/docs.txt"
    -      - "requirements/app/**"
    -      - "setup.py"
    -      - "pyproject.toml" # includes metadata used in the package creation
    -      - "!*.md"
    -      - "!**/*.md"
    -    checks:
    -      - "docs-make (app, doctest)"
    -      - "docs-make (app, html)"
    -
       # SECTION: common
     
       - id: "mypy"
    @@ -359,8 +244,6 @@ subprojects:
           - "!*.md"
           - "!**/*.md"
         checks:
    -      - "install-pkg (ubuntu-22.04, app, 3.8)"
    -      - "install-pkg (ubuntu-22.04, app, 3.11)"
           - "install-pkg (ubuntu-22.04, fabric, 3.8)"
           - "install-pkg (ubuntu-22.04, fabric, 3.11)"
           - "install-pkg (ubuntu-22.04, pytorch, 3.8)"
    @@ -369,8 +252,6 @@ subprojects:
           - "install-pkg (ubuntu-22.04, lightning, 3.11)"
           - "install-pkg (ubuntu-22.04, notset, 3.8)"
           - "install-pkg (ubuntu-22.04, notset, 3.11)"
    -      - "install-pkg (macOS-12, app, 3.8)"
    -      - "install-pkg (macOS-12, app, 3.11)"
           - "install-pkg (macOS-12, fabric, 3.8)"
           - "install-pkg (macOS-12, fabric, 3.11)"
           - "install-pkg (macOS-12, pytorch, 3.8)"
    @@ -379,8 +260,6 @@ subprojects:
           - "install-pkg (macOS-12, lightning, 3.11)"
           - "install-pkg (macOS-12, notset, 3.8)"
           - "install-pkg (macOS-12, notset, 3.11)"
    -      - "install-pkg (windows-2022, app, 3.8)"
    -      - "install-pkg (windows-2022, app, 3.11)"
           - "install-pkg (windows-2022, fabric, 3.8)"
           - "install-pkg (windows-2022, fabric, 3.11)"
           - "install-pkg (windows-2022, pytorch, 3.8)"
    
  • .github/CODEOWNERS+0 10 modified
    @@ -11,7 +11,6 @@
     /.actions/                  @borda @ethanwharris @justusschock
     /.github/                   @borda @ethanwharris @justusschock
     /.azure/                    @borda @ethanwharris @justusschock
    -/.azure/app-cloud-e2e.yml   @awaelchli @ethanwharris @lantiga
     /dockers/                   @borda @ethanwharris @justusschock
     *.yml                       @borda @ethanwharris @justusschock
     
    @@ -25,7 +24,6 @@
     /docs/source-pytorch/conf.py                @borda @awaelchli
     /docs/source-pytorch/index.rst              @williamfalcon @lantiga
     /docs/source-pytorch/levels                 @williamfalcon @lantiga
    -/docs/source-app/                           @williamfalcon @lantiga @tchaton
     
     # PyTorch Lightning
     /src/lightning/pytorch                      @lantiga @borda @tchaton @awaelchli @justusschock
    @@ -36,18 +34,10 @@
     # Lightning Fabric
     /src/lightning/fabric                       @lantiga @borda @tchaton @awaelchli @justusschock
     
    -# Lightning App
    -/src/lightning/app                          @tchaton @lantiga @awaelchli @ethanwharris
    -/src/lightning_app                          @tchaton @lantiga @awaelchli @ethanwharris
    -/tests/tests_app                            @tchaton @lantiga @awaelchli @ethanwharris
    -/tests/integrations_app                     @tchaton @lantiga @awaelchli @ethanwharris
    -/examples/app_*                             @tchaton @lantiga @awaelchli @ethanwharris
    -
     /.github/CODEOWNERS                  @williamfalcon
     /SECURITY.md                         @williamfalcon @lantiga
     /README.md                           @williamfalcon @lantiga
     /setup.py                            @williamfalcon @borda
     /src/pytorch_lightning/__about__.py  @williamfalcon @borda
    -/src/lightning_app/__about__.py      @williamfalcon @lantiga @borda
     /src/lightning_fabric/__about__.py   @williamfalcon @borda @awaelchli
     /src/*/__setup__.py                  @borda @justusschock
    
  • .github/CONTRIBUTING.md+0 14 modified
    @@ -310,20 +310,6 @@ and the last true master commit is `ccc111` and your first commit is `mmm222`.
       git push -f
       ```
     
    -#### How to run an app on the cloud with a local version of lightning
    -
    -The lightning cloud uses the latest release by default. However, you might want to run your app with some local changes you've made to the lightning framework. To use your local version of lightning on the cloud, set the following environment variable:
    -
    -```bash
    -git clone https://github.com/Lightning-AI/lightning.git
    -cd lightning
    -pip install -e .
    -export PACKAGE_LIGHTNING=1  # <- this is the magic to use your version (not mainstream PyPI)!
    -lightning run app app.py --cloud
    -```
    -
    -By setting `PACKAGE_LIGHTNING=1`, lightning packages the lightning source code in your local directory in addition to your app source code and uploads them to the cloud.
    -
     ### Bonus Workflow Tip
     
     If you don't want to remember all the commands above every time you want to push some code/setup a Lightning Dev environment on a new VM, you can set up bash aliases for some common commands. You can add these to one of your `~/.bashrc`, `~/.zshrc`, or `~/.bash_aliases` files.
    
  • .github/ISSUE_TEMPLATE/1_bug_report.yaml+0 2 modified
    @@ -91,9 +91,7 @@ body:
               <summary>Current environment</summary>
     
             ```
    -        #- Lightning Component (e.g. Trainer, LightningModule, LightningApp, LightningWork, LightningFlow):
             #- PyTorch Lightning Version (e.g., 1.5.0):
    -        #- Lightning App Version (e.g., 0.5.2):
             #- PyTorch Version (e.g., 2.0):
             #- Python version (e.g., 3.9):
             #- OS (e.g., Linux):
    
  • .github/label-change.yml+0 20 modified
    @@ -1,28 +1,9 @@
    -app:
    -  - changed-files:
    -      - any-glob-to-any-file:
    -          - "src/lightning/app/**"
    -          - "src/lightning_app/*"
    -          - "tests/tests_app/**"
    -          - "tests/integrations_app/**"
    -          - "tests/integrations_app_examples/**"
    -          - "examples/app/**"
    -          - "docs/source-app/**"
    -          - "requirements/app/**"
    -
     data:
       - changed-files:
           - any-glob-to-any-file:
               - "src/lightning/data/**"
               - "requirements/data/**"
     
    -store:
    -  - changed-files:
    -      - any-glob-to-any-file:
    -          - "src/lightning/store/**"
    -          - "tests/tests_store/**"
    -          - "requirements/store/**"
    -
     pl:
       - changed-files:
           - any-glob-to-any-file:
    @@ -70,7 +51,6 @@ package:
               - "src/version.info"
               - "src/lightning/*/__setup__.py"
               - "src/lightning/*/__version__.py"
    -          - "src/lightning_app/*"
               - "src/lightning_fabric/*"
               - "src/pytorch_lightning/*"
     
    
  • .github/workflows/_build-packages.yml+1 1 modified
    @@ -12,7 +12,7 @@ on:
             required: false
             type: string
             default: |
    -          ["lightning", "app", "fabric", "pytorch"]
    +          ["lightning", "fabric", "pytorch"]
     
     defaults:
       run:
    
  • .github/workflows/ci-examples-app.yml+0 136 removed
    @@ -1,136 +0,0 @@
    -name: Test App - examples
    -
    -# see: https://help.github.com/en/actions/reference/events-that-trigger-workflows
    -on:
    -  push:
    -    branches: [master, "release/*"]
    -  pull_request:
    -    branches: [master, "release/*"]
    -    types: [opened, reopened, ready_for_review, synchronize] # added `ready_for_review` since draft is skipped
    -    paths:
    -      - ".actions/*"
    -      - ".github/workflows/ci-examples-app.yml"
    -      - "src/lightning/app/**"
    -      - "src/lightning_app/*"
    -      - "tests/integrations_app/**"
    -      - "!tests/integrations_app/flagship/**"
    -      - "examples/app/**"
    -      - "requirements/app/**"
    -      - "setup.py"
    -      - "!requirements/*/docs.txt"
    -      - "!*.md"
    -      - "!**/*.md"
    -
    -concurrency:
    -  group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }}
    -  cancel-in-progress: ${{ github.event_name == 'pull_request' }}
    -
    -defaults:
    -  run:
    -    shell: bash
    -
    -jobs:
    -  app-examples:
    -    if: github.event.pull_request.draft == false
    -    runs-on: ${{ matrix.os }}
    -    strategy:
    -      fail-fast: false
    -      matrix:
    -        os: [ubuntu-20.04, macOS-12, windows-2022]
    -        pkg-name: ["lightning"]
    -        python-version: ["3.9"]
    -        requires: ["oldest", "latest"]
    -        include:
    -          # "app" installs the standalone package
    -          - { os: "macOS-12", pkg-name: "app", python-version: "3.9", requires: "latest" }
    -          - { os: "ubuntu-20.04", pkg-name: "app", python-version: "3.9", requires: "latest" }
    -          - { os: "windows-2022", pkg-name: "app", python-version: "3.9", requires: "latest" }
    -    # Timeout: https://stackoverflow.com/a/59076067/4521646
    -    timeout-minutes: 15
    -    env:
    -      PACKAGE_NAME: ${{ matrix.pkg-name }}
    -      FREEZE_REQUIREMENTS: 1
    -      TORCH_URL: "https://download.pytorch.org/whl/cpu/torch_stable.html"
    -      PYPI_CACHE_DIR: "_pip-wheels"
    -    steps:
    -      - uses: actions/checkout@v4
    -      - name: Set up Python ${{ matrix.python-version }}
    -        uses: actions/setup-python@v5
    -        with:
    -          python-version: ${{ matrix.python-version }}
    -
    -      - name: basic setup
    -        run: pip install -q -r .actions/requirements.txt
    -
    -      - name: Set min. dependencies
    -        if: ${{ matrix.requires == 'oldest' }}
    -        run: python .actions/assistant.py replace_oldest_ver
    -
    -      - name: pip wheels cache
    -        uses: actions/cache/restore@v4
    -        with:
    -          path: ${{ env.PYPI_CACHE_DIR }}
    -          key: pypi_wheels
    -
    -      - name: Install Lightning package & dependencies
    -        timeout-minutes: 20
    -        run: |
    -          extra=$(python -c "print({'lightning': 'app-'}.get('${{ matrix.pkg-name }}', ''))")
    -          # do not use `-e` because it will make both packages available since it adds `src` to `sys.path` automatically
    -          pip install ".[${extra}dev]" -U -f ${TORCH_URL} -f ${PYPI_CACHE_DIR} --prefer-binary
    -          pip list
    -      - name: Dump handy wheels
    -        if: github.event_name == 'push' && github.ref == 'refs/heads/master'
    -        continue-on-error: true
    -        uses: ./.github/actions/pip-wheels
    -        with:
    -          wheel-dir: ${{ env.PYPI_CACHE_DIR }}
    -          torch-url: ${{ env.TORCH_URL }}
    -          cache-key: "pypi_wheels"
    -
    -      - name: Setup Node.js
    -        uses: actions/setup-node@v4
    -        with:
    -          node-version: "16"
    -
    -      - name: Install Yarn
    -        timeout-minutes: 20
    -        run: npm install -g yarn
    -
    -      - name: Adjust imports -> App
    -        if: ${{ matrix.pkg-name != 'lightning' }}
    -        run: |
    -          python .actions/assistant.py copy_replace_imports --source_dir="./tests" \
    -            --source_import="lightning.app,lightning.fabric,lightning.pytorch" \
    -            --target_import="lightning_app,lightning_fabric,pytorch_lightning" \
    -            --lightning_by="lightning_app"
    -          python .actions/assistant.py copy_replace_imports --source_dir="./examples" \
    -            --source_import="lightning.app,lightning.fabric,lightning.pytorch,lightning" \
    -            --target_import="lightning_app,lightning_fabric,pytorch_lightning,lightning_app"
    -
    -      - name: Switch coverage scope
    -        run: python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.pkg-name}}' == 'lightning' else 'lightning_app'))" >> $GITHUB_ENV
    -
    -      - name: Tests
    -        working-directory: ./tests
    -        run: |
    -          python -m coverage run --source ${{ env.COVERAGE_SCOPE }} \
    -            -m pytest -m "not cloud" integrations_app \
    -            --timeout=120 --durations=0 -vvvv
    -
    -      - name: Statistics
    -        if: success()
    -        working-directory: ./tests
    -        run: |
    -          coverage xml -i
    -          coverage report -i
    -
    -      - name: Upload coverage to Codecov
    -        uses: codecov/codecov-action@v4
    -        with:
    -          token: ${{ secrets.CODECOV_TOKEN }}
    -          file: tests/coverage.xml
    -          flags: cpu,pytest,app,examples
    -          env_vars: OS,PYTHON
    -          name: codecov-umbrella
    -          fail_ci_if_error: false
    
  • .github/workflows/ci-flagship-apps.yml+0 27 removed
    @@ -1,27 +0,0 @@
    -name: Test App - flagships
    -
    -# see: https://help.github.com/en/actions/reference/events-that-trigger-workflows
    -on:
    -  push:
    -    branches: ["release/*"]
    -  pull_request:
    -    branches: [master, "release/*"]
    -    types: [opened, reopened, ready_for_review, synchronize]
    -    paths:
    -      - ".github/workflows/_flagship-apps.yml"
    -      - ".github/workflows/ci-flagship-apps.yml"
    -      - "github/actions/prep-apps/action.yml"
    -      - "tests/integrations_app/flagship/**"
    -  schedule:
    -    # on Sundays
    -    - cron: "0 0 * * 0"
    -
    -concurrency:
    -  group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }}
    -  cancel-in-progress: ${{ github.event_name == 'pull_request' }}
    -
    -jobs:
    -  test-flagships:
    -    if: github.event.pull_request.draft == false
    -    uses: ./.github/workflows/_flagship-apps.yml
    -    secrets: inherit
    
  • .github/workflows/ci-pkg-install.yml+6 26 modified
    @@ -43,14 +43,8 @@ jobs:
           fail-fast: false
           matrix:
             os: ["ubuntu-22.04", "macOS-12", "windows-2022"]
    -        pkg-name: ["app", "fabric", "pytorch", "lightning", "notset"]
    +        pkg-name: ["fabric", "pytorch", "lightning", "notset"]
             python-version: ["3.8", "3.11"]
    -        # TODO: add also install from source
    -        include:
    -          - { os: "macOS-12", pkg-name: "lightning", python-version: "3.9", pkg-extra: "app" }
    -          - { os: "macOS-12", pkg-name: "notset", python-version: "3.9", pkg-extra: "app" }
    -          - { os: "ubuntu-22.04", pkg-name: "lightning", python-version: "3.9", pkg-extra: "app" }
    -          - { os: "ubuntu-22.04", pkg-name: "notset", python-version: "3.9", pkg-extra: "app" }
         steps:
           - uses: actions/checkout@v4
           - uses: actions/setup-python@v5
    @@ -70,16 +64,6 @@ jobs:
             with:
               pkg-folder: dist/${{ env.PKG_DIR }}
               pkg-name: ${{ matrix.pkg-name }}
    -          pkg-extra: ${{ matrix.pkg-extra }}
    -
    -      - name: Run CLI (via python)
    -        if: ${{ (matrix.pkg-name == 'lightning' || matrix.pkg-name == 'notset') && matrix.pkg-extra == 'app' }}
    -        run: python -m lightning --version
    -      - name: Run CLI (direct bash)
    -        if: |
    -          ((matrix.pkg-name == 'lightning' || matrix.pkg-name == 'notset') && matrix.pkg-extra == 'app') ||
    -          matrix.pkg-name == 'app'
    -        run: lightning_app --version
     
           - name: DocTests actions
             working-directory: .actions/
    @@ -88,28 +72,24 @@ jobs:
               python -m pytest assistant.py
     
           - name: Adjust code for standalone
    -        if: contains(fromJSON('["app", "fabric", "pytorch"]'), matrix.pkg-name)
    +        if: contains(fromJSON('["fabric", "pytorch"]'), matrix.pkg-name)
             run: |
               python .actions/assistant.py copy_replace_imports --source_dir="./src" \
    -            --source_import="lightning.pytorch,lightning.fabric,lightning.app" \
    -            --target_import="pytorch_lightning,lightning_fabric,lightning_app"
    +            --source_import="lightning.pytorch,lightning.fabric" \
    +            --target_import="pytorch_lightning,lightning_fabric"
           - name: Rename src folders
             working-directory: src/
             run: |
    -          python -c "n = '${{matrix.pkg-name}}' ; n = n if n in ('app', 'fabric', 'pytorch') else '' ; print('PKG_NAME=' + n)" >> $GITHUB_ENV
    +          python -c "n = '${{matrix.pkg-name}}' ; n = n if n in ('fabric', 'pytorch') else '' ; print('PKG_NAME=' + n)" >> $GITHUB_ENV
               rm -f ./*/__*.py
               rm -f ./**/__*.py
               mv lightning lit  # rename lightning folder to prevent accidental local imports
           - name: drop Secondary doctest
             if: ${{ matrix.pkg-name == 'lightning' || matrix.pkg-name == 'notset' }}
             working-directory: src/lit
             run: |
    -          items=("data" "store" "app")
    +          items=("data")
               for item in "${items[@]}"; do
    -            if [[ "$item" == "${{ matrix.pkg-extra }}" ]]; then
    -              echo "Skipping $item"
    -              continue # Skip this iteration
    -            fi
                 echo "Removing $item"
                 rm -rf $item
               done
    
  • .github/workflows/ci-tests-app.yml+0 175 removed
    @@ -1,175 +0,0 @@
    -name: Test App
    -
    -# see: https://help.github.com/en/actions/reference/events-that-trigger-workflows
    -on:
    -  push:
    -    branches: [master, "release/*"]
    -  pull_request:
    -    branches: [master, "release/*"]
    -    types: [opened, reopened, ready_for_review, synchronize] # added `ready_for_review` since draft is skipped
    -    paths:
    -      - ".actions/*"
    -      - ".github/workflows/ci-tests-app.yml"
    -      - "requirements/ci.txt"
    -      - "src/lightning/app/**"
    -      - "src/lightning_app/*"
    -      - "tests/tests_app/**"
    -      - "requirements/app/**"
    -      - "setup.py"
    -      - "!requirements/*/docs.txt"
    -      - "!*.md"
    -      - "!**/*.md"
    -  schedule:
    -    # At the end of every day
    -    - cron: "0 0 * * *"
    -
    -concurrency:
    -  group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }}
    -  cancel-in-progress: ${{ github.event_name == 'pull_request' }}
    -
    -defaults:
    -  run:
    -    shell: bash
    -
    -jobs:
    -  app-pytest:
    -    if: github.event.pull_request.draft == false
    -    runs-on: ${{ matrix.os }}
    -    strategy:
    -      fail-fast: false
    -      matrix:
    -        os: ["ubuntu-20.04", "macOS-12", "windows-2022"]
    -        pkg-name: ["lightning"]
    -        python-version: ["3.8"]
    -        requires: ["oldest", "latest"]
    -        include:
    -          # only run Python latest, use App scope to limit dependency issues
    -          - { os: "macOS-12", pkg-name: "app", python-version: "3.11", requires: "latest" }
    -          - { os: "ubuntu-22.04", pkg-name: "app", python-version: "3.11", requires: "latest" }
    -          - { os: "windows-2022", pkg-name: "app", python-version: "3.11", requires: "latest" }
    -          # "app" installs the standalone package
    -          - { os: "macOS-12", pkg-name: "app", python-version: "3.9", requires: "latest" }
    -          - { os: "ubuntu-20.04", pkg-name: "app", python-version: "3.9", requires: "latest" }
    -          - { os: "windows-2022", pkg-name: "app", python-version: "3.8", requires: "latest" }
    -    # Timeout: https://stackoverflow.com/a/59076067/4521646
    -    timeout-minutes: 55
    -    env:
    -      PACKAGE_NAME: ${{ matrix.pkg-name }}
    -      FREEZE_REQUIREMENTS: ${{ ! (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/')) }}
    -      PYPI_CACHE_DIR: "_pip-wheels"
    -      TORCH_URL: "https://download.pytorch.org/whl/cpu/torch_stable.html"
    -    steps:
    -      - uses: actions/checkout@v4
    -      - name: Set up Python ${{ matrix.python-version }}
    -        uses: actions/setup-python@v5
    -        with:
    -          python-version: ${{ matrix.python-version }}
    -
    -      - name: basic setup
    -        run: pip install -q -r .actions/requirements.txt
    -
    -      - name: Set min. dependencies
    -        if: ${{ matrix.requires == 'oldest' }}
    -        run: python .actions/assistant.py replace_oldest_ver
    -
    -      - name: pip wheels cache
    -        uses: actions/cache/restore@v4
    -        with:
    -          path: ${{ env.PYPI_CACHE_DIR }}
    -          key: pypi_wheels
    -      - name: List restored pkgs
    -        run: |
    -          mkdir -p $PYPI_CACHE_DIR
    -          ls -lh $PYPI_CACHE_DIR
    -
    -      - name: Env. variables
    -        run: |
    -          # Switch coverage scope
    -          python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.pkg-name}}' == 'lightning' else 'pytorch_lightning'))" >> $GITHUB_ENV
    -          # if you install mono-package set dependency only for this subpackage
    -          python -c "print('EXTRA_PREFIX=' + str('' if '${{matrix.pkg-name}}' != 'lightning' else 'app-'))" >> $GITHUB_ENV
    -
    -      - name: Install package & dependencies
    -        timeout-minutes: 20
    -        run: |
    -          pip install -e ".[${EXTRA_PREFIX}dev]" -U --prefer-binary \
    -            --find-links="${TORCH_URL}" --find-links="${PYPI_CACHE_DIR}"
    -          pip list
    -      - name: Dump handy wheels
    -        if: github.event_name == 'push' && github.ref == 'refs/heads/master'
    -        continue-on-error: true
    -        uses: ./.github/actions/pip-wheels
    -        with:
    -          wheel-dir: ${{ env.PYPI_CACHE_DIR }}
    -          torch-url: ${{ env.TORCH_URL }}
    -          cache-key: "pypi_wheels"
    -
    -      - name: Setup Node.js
    -        uses: actions/setup-node@v4
    -        with:
    -          node-version: "16"
    -      - name: Install Yarn
    -        timeout-minutes: 20
    -        run: npm install -g yarn
    -
    -      - name: Adjust imports -> App
    -        if: ${{ matrix.pkg-name != 'lightning' }}
    -        run: |
    -          python .actions/assistant.py copy_replace_imports --source_dir="./tests" \
    -            --source_import="lightning.app,lightning.fabric,lightning.pytorch" \
    -            --target_import="lightning_app,lightning_fabric,pytorch_lightning" \
    -            --lightning_by="lightning_app"
    -          python .actions/assistant.py copy_replace_imports --source_dir="./examples" \
    -            --source_import="lightning.app,lightning.fabric,lightning.pytorch" \
    -            --target_import="lightning_app,lightning_fabric,pytorch_lightning" \
    -            --lightning_by="lightning_app"
    -
    -      - name: Switch coverage scope
    -        run: python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.pkg-name}}' == 'lightning' else 'lightning_app'))" >> $GITHUB_ENV
    -
    -      - name: Set parallel for Unix
    -        if: ${{ runner.os != 'windows' }}
    -        # on Win, tests takes even loner then with normal single thread
    -        run: echo "PYTEST_XDIST_ARGS=-n auto --dist=loadfile" >> $GITHUB_ENV
    -      - name: Tests
    -        working-directory: ./tests
    -        run: |
    -          set -e
    -          python -m coverage run --source ${{ env.COVERAGE_SCOPE }} \
    -            -m pytest -m "not cloud" -vvvv tests_app \
    -              --ignore="tests_app/components/python/test_python.py" \
    -              --timeout=120 --durations=50 ${PYTEST_XDIST_ARGS}
    -          pytest -m "not cloud" -v \
    -            tests_app/components/python/test_python.py \
    -            --timeout=120 --durations=50
    -
    -      - name: Statistics
    -        if: success()
    -        working-directory: ./tests
    -        run: |
    -          coverage xml -i
    -          coverage report -i
    -
    -      - name: Upload coverage to Codecov
    -        uses: codecov/codecov-action@v4
    -        with:
    -          token: ${{ secrets.CODECOV_TOKEN }}
    -          file: tests/coverage.xml
    -          flags: ${{ env.COVERAGE_SCOPE }},cpu,pytest
    -          env_vars: OS,PYTHON
    -          name: codecov-umbrella
    -          fail_ci_if_error: false
    -# TODO: figure out why we clone and install quick-start
    -#      - name: Clone Quick Start Example Repo
    -#        uses: actions/checkout@v4
    -#        # TODO: this needs to be git submodule
    -#        if: matrix.os == 'windows-2022'  # because the install doesn't work on windows
    -#        with:
    -#          repository: Lightning-AI/lightning-quick-start
    -#          ref: 'main'
    -#          path: lightning-quick-start
    -#
    -#      - name: Lightning Install quick-start
    -#        if: matrix.os != 'windows-2022'  # because the install doesn't work on windows
    -#        run: |
    -#          python -m lightning install app lightning/quick-start -y
    
  • .github/workflows/ci-tests-store.yml+0 96 removed
    @@ -1,96 +0,0 @@
    -name: Test Store
    -
    -# see: https://help.github.com/en/actions/reference/events-that-trigger-workflows
    -on:
    -  push:
    -    branches: [master, "release/*"]
    -  pull_request:
    -    branches: [master, "release/*"]
    -    types: [opened, reopened, ready_for_review, synchronize] # added `ready_for_review` since draft is skipped
    -    paths:
    -      - ".actions/*"
    -      - "requirements/ci.txt"
    -      - "requirements/store/**"
    -      - "src/lightning/__init__.py"
    -      - "src/lightning/__setup__.py"
    -      - "src/lightning/__version__.py"
    -      - "src/lightning/store/**"
    -      - "tests/tests_store/**"
    -      - "pyproject.toml" # includes pytest config
    -      - ".github/workflows/ci-tests-store.yml"
    -      - "!requirements/*/docs.txt"
    -      - "!*.md"
    -      - "!**/*.md"
    -
    -concurrency:
    -  group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }}
    -  cancel-in-progress: ${{ github.event_name == 'pull_request' }}
    -
    -defaults:
    -  run:
    -    shell: bash
    -
    -jobs:
    -  store-cpu:
    -    runs-on: ${{ matrix.os }}
    -    if: github.event.pull_request.draft == false
    -    strategy:
    -      fail-fast: false
    -      matrix:
    -        os: ["macOS-11", "ubuntu-20.04", "windows-2022"]
    -        pkg-name: ["lightning"]
    -        python-version: ["3.10"]
    -        pytorch-version: ["2.0"]
    -    timeout-minutes: 25 # because of building grpcio on Mac
    -    env:
    -      PACKAGE_NAME: ${{ matrix.pkg-name }}
    -      FREEZE_REQUIREMENTS: ${{ ! (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/')) }}
    -      # PYPI_CACHE_DIR: "_pip-wheels"
    -      TORCH_URL_STABLE: "https://download.pytorch.org/whl/cpu/torch_stable.html"
    -    steps:
    -      - uses: actions/checkout@v4
    -
    -      - name: Set up Python ${{ matrix.python-version }}
    -        uses: actions/setup-python@v5
    -        with:
    -          python-version: ${{ matrix.python-version }}
    -
    -      - name: Adjust PyTorch versions in requirements files
    -        if: ${{ matrix.requires != 'oldest' && matrix.release != 'pre' }}
    -        run: |
    -          pip install -q -r requirements/ci.txt
    -          python -m wget https://raw.githubusercontent.com/Lightning-AI/utilities/main/scripts/adjust-torch-versions.py
    -          for fpath in `ls requirements/store/*.txt`; do \
    -            python ./adjust-torch-versions.py $fpath ${{ matrix.pytorch-version }}; \
    -          done
    -
    -      - name: Install package & dependencies
    -        timeout-minutes: 20
    -        run: |
    -          pip install -e ".[store,store-test]" -U -f ${TORCH_URL} --prefer-binary
    -          pip list
    -
    -      - name: Testing Store
    -        working-directory: tests/tests_store
    -        # NOTE: do not include coverage report here, see: https://github.com/nedbat/coveragepy/issues/1003
    -        run: |
    -          python -m coverage run --source lightning \
    -            -m pytest -v --timeout=60 --durations=60
    -
    -      - name: Statistics
    -        if: success()
    -        working-directory: tests/tests_store
    -        run: |
    -          coverage report
    -          coverage xml
    -
    -      - name: Upload coverage to Codecov
    -        uses: codecov/codecov-action@v4
    -        # see: https://github.com/actions/toolkit/issues/399
    -        continue-on-error: true
    -        with:
    -          token: ${{ secrets.CODECOV_TOKEN }}
    -          file: tests/tests_store/coverage.xml
    -          flags: lightning,cpu,pytest,python${{ matrix.python-version }}
    -          name: CPU-coverage
    -          fail_ci_if_error: false
    
  • .github/workflows/code-checks.yml+0 1 modified
    @@ -44,7 +44,6 @@ jobs:
               FREEZE_REQUIREMENTS: 1
             timeout-minutes: 20
             run: |
    -          # TODO: investigate hanging installation with app sub-package
               pip install -e '.[pytorch-all,fabric-all]' -r requirements/typing.txt
               pip list
     
    
  • .github/workflows/docs-build.yml+2 4 modified
    @@ -15,8 +15,6 @@ on:
           - "docs/**"
           - "_notebooks"
           - "requirements/**"
    -      - "src/lightning/app/**"
    -      - "src/lightning_app/*"
           - "src/lightning/fabric/**"
           - "src/lightning_fabric/*"
           - "src/lightning/pytorch/**"
    @@ -58,7 +56,7 @@ jobs:
         strategy:
           fail-fast: false
           matrix:
    -        pkg-name: ["app", "fabric", "pytorch"]
    +        pkg-name: ["fabric", "pytorch"]
             target: ["html", "doctest", "linkcheck"]
         env:
           DOCS_COPY_NOTEBOOKS: 1
    @@ -144,7 +142,7 @@ jobs:
         strategy:
           fail-fast: false
           matrix:
    -        pkg-name: ["app", "fabric", "pytorch"]
    +        pkg-name: ["fabric", "pytorch"]
         env:
           GCP_TARGET: "gs://lightning-docs-${{ matrix.pkg-name }}"
           # use input if dispatch or git tag
    
  • .github/workflows/_flagship-apps.yml+0 122 removed
    @@ -1,122 +0,0 @@
    -name: Call integration of flagship Apps
    -
    -# see: https://help.github.com/en/actions/reference/events-that-trigger-workflows
    -on:
    -  workflow_call:
    -    inputs:
    -      environment:
    -        description: "Lightning environment"
    -        required: false
    -        default: "PROD"
    -        type: string
    -  workflow_dispatch:
    -    inputs:
    -      environment:
    -        description: "Lightning environment"
    -        required: true
    -        default: "PROD"
    -        type: choice
    -        options:
    -          - PROD
    -          - STAGING
    -
    -defaults:
    -  run:
    -    shell: bash
    -
    -jobs:
    -  run-flagships:
    -    if: github.event.pull_request.draft == false
    -    runs-on: ubuntu-latest
    -    container:
    -      image: mcr.microsoft.com/playwright/python:v1.38.0-focal
    -    strategy:
    -      fail-fast: false
    -      matrix:
    -        include:
    -          - { app: "flashy", repo: "Lightning-Universe/Flashy-app" }
    -          - { app: "muse", repo: "Lightning-Universe/stable-diffusion-deploy" }
    -          - { app: "jupyter", repo: "Lightning-Universe/Jupyter-component" }
    -
    -          # TODO:
    -          # - Training Studio
    -          # - Echo
    -          # - StreamLit / Gradio
    -          # - All homepage & docs apps
    -
    -    env:
    -      HEADLESS: "1"
    -      PACKAGE_LIGHTNING: "1"
    -      CLOUD: "1"
    -      VIDEO_LOCATION: "./videos"
    -      HAR_LOCATION: "./artifacts/hars"
    -      SLOW_MO: "50"
    -      LIGHTNING_DEBUG: "1"
    -      TORCH_URL: "https://download.pytorch.org/whl/cpu/torch_stable.html"
    -    # Timeout: https://stackoverflow.com/a/59076067/4521646
    -    timeout-minutes: 20
    -
    -    steps:
    -      - uses: actions/checkout@v4
    -
    -      - name: basic setup
    -        timeout-minutes: 20
    -        run: |
    -          mkdir -p tests/_flagships
    -          mkdir -p $VIDEO_LOCATION
    -          pip --version
    -          pip list
    -          # for some reason the python package playwright is missing
    -          pip install -r requirements/app/test.txt
    -          python -m playwright install  # --with-deps
    -
    -      - name: Clone the Repo/App
    -        uses: actions/checkout@v4
    -        with:
    -          repository: ${{ matrix.repo }}
    -          path: tests/_flagship-app
    -
    -      - name: Adjust env. for this App
    -        uses: ./.github/actions/prep-apps
    -        with:
    -          name: ${{ matrix.app }}
    -
    -      - name: Install Lightning package
    -        timeout-minutes: 20
    -        run: pip install -e .[cloud,test] -f $TORCH_URL
    -      - name: List pip dependency
    -        run: pip --version && pip list
    -
    -      - name: Run the tests
    -        working-directory: tests/
    -        env:
    -          LIGHTNING_USER_ID: ${{ secrets[format('LIGHTNING_USER_ID_{0}', inputs.environment)] }}
    -          LIGHTNING_API_KEY: ${{ secrets[format('LIGHTNING_API_KEY_{0}', inputs.environment)] }}
    -          LIGHTNING_USERNAME: ${{ secrets[format('LIGHTNING_USERNAME_{0}', inputs.environment)] }}
    -          LIGHTNING_CLOUD_URL: ${{ secrets[format('LIGHTNING_CLOUD_URL_{0}', inputs.environment)] }}
    -          LAI_USER: ${{ secrets.LAI_SSH_USER }}
    -          LAI_PASS: ${{ secrets.LAI_SSH_PASS }}
    -        run: |
    -          ls -l _flagship-app
    -          python -m pytest integrations_app/flagship/test_${{ matrix.app }}.py \
    -            --capture=no -v --color=yes
    -
    -      - name: Upload recordings
    -        uses: actions/upload-artifact@v3
    -        if: failure()
    -        with:
    -          name: flahship-app-${{ matrix.app }}
    -          path: ${{ env.VIDEO_LOCATION }}
    -
    -      - name: Clean Previous Apps
    -        if: always()
    -        timeout-minutes: 3
    -        env:
    -          LIGHTNING_USER_ID: ${{ secrets[format('LIGHTNING_USER_ID_{0}', inputs.environment)] }}
    -          LIGHTNING_API_KEY: ${{ secrets[format('LIGHTNING_API_KEY_{0}', inputs.environment)] }}
    -          LIGHTNING_USERNAME: ${{ secrets[format('LIGHTNING_USERNAME_{0}', inputs.environment)] }}
    -          LIGHTNING_CLOUD_URL: ${{ secrets[format('LIGHTNING_CLOUD_URL_{0}', inputs.environment)] }}
    -          LAI_USER: ${{ secrets.LAI_SSH_USER }}
    -          LAI_PASS: ${{ secrets.LAI_SSH_PASS }}
    -        run: |
    -          time python -c "from lightning.app import testing; testing.delete_cloud_lightning_apps()"
    
  • .github/workflows/README.md+0 3 modified
    @@ -8,15 +8,12 @@ Brief description of all our automation tools used for boosting development perf
     
     | workflow file                          | action                                                                                    | accelerator |
     | -------------------------------------- | ----------------------------------------------------------------------------------------- | ----------- |
    -| .github/workflows/ci-tests-app.yml     | Run all tests (may need internet connectivity).                                           | CPU         |
     | .github/workflows/ci-tests-fabric.yml  | Run all tests except for accelerator-specific and standalone.                             | CPU         |
     | .github/workflows/ci-tests-pytorch.yml | Run all tests except for accelerator-specific and standalone.                             | CPU         |
     | .github/workflows/ci-tests-data.yml    | Run unit and integration tests with data pipelining.                                      | CPU         |
    -| .github/workflows/ci-tests-store.yml   | Run integration tests on uploading models to cloud.                                       | CPU         |
     | .azure-pipelines/gpu-tests-fabric.yml  | Run only GPU-specific tests, standalone\*, and examples.                                  | GPU         |
     | .azure-pipelines/gpu-tests-pytorch.yml | Run only GPU-specific tests, standalone\*, and examples.                                  | GPU         |
     | .azure-pipelines/gpu-benchmarks.yml    | Run speed/memory benchmarks for parity with vanila PyTorch.                               | GPU         |
    -| .github/workflows/ci-examples-app.yml  | Run integration tests with App examples.                                                  | CPU         |
     | .github/workflows/ci-flagship-apps.yml | Run end-2-end tests with full applications, including deployment to the production cloud. | CPU         |
     | .github/workflows/ci-tests-pytorch.yml | Run all tests except for accelerator-specific, standalone and slow tests.                 | CPU         |
     | .github/workflows/tpu-tests.yml        | Run only TPU-specific tests. Requires that the PR title contains '\[TPU\]'                | TPU         |
    
  • .github/workflows/release-pkg.yml+2 2 modified
    @@ -165,7 +165,7 @@ jobs:
         strategy:
           fail-fast: false
           matrix:
    -        name: ["APP", "FABRIC", "PYTORCH", "LIGHTNING"]
    +        name: ["FABRIC", "PYTORCH", "LIGHTNING"]
         steps:
           - uses: actions/checkout@v4 # needed for local action below
           - uses: actions/download-artifact@v3
    @@ -190,7 +190,7 @@ jobs:
         strategy:
           fail-fast: false
           matrix:
    -        name: ["APP", "FABRIC", "PYTORCH", "LIGHTNING"]
    +        name: ["FABRIC", "PYTORCH", "LIGHTNING"]
         steps:
           - uses: actions/checkout@v4 # needed for local action below
           - uses: actions/download-artifact@v3
    
  • .gitignore+0 7 modified
    @@ -9,10 +9,6 @@ lightning_logs/
     # Documentations
     docs/venv*/
     docs/build*/
    -docs/source-app/*/api
    -docs/source-app/generated
    -docs/source-app/*/generated
    -docs/source-app/_static/fetched-s3-assets
     docs/source-fabric/_static/fetched-s3-assets
     docs/source-pytorch/api
     docs/source-pytorch/*.md
    @@ -59,7 +55,6 @@ wheels/
     .installed.cfg
     *.egg
     src/*/version.info
    -src/lightning_app/*
     src/lightning_fabric/*
     src/pytorch_lightning/*
     !src/*/__about__.py
    @@ -182,8 +177,6 @@ cifar-10-batches-py
     # ctags
     tags
     .tags
    -src/lightning_app/ui/*
    -src/lightning/app/ui/*
     *examples/template_react_ui*
     hars*
     artifacts/*
    
  • .lightningignore+0 16 removed
    @@ -1,16 +0,0 @@
    -_notebooks
    -.azure
    -.github
    -.ipynb_checkpoints
    -.pytest_cache
    -.shared
    -.storage
    -.venv
    -.vscode
    -.git
    -artifacts
    -Datasets
    -dist
    -docs
    -examples
    -tests
    
  • Makefile+0 10 modified
    @@ -21,28 +21,22 @@ clean:
     	rm -rf ./docs/source-pytorch/generated
     	rm -rf ./docs/source-pytorch/*/generated
     	rm -rf ./docs/source-pytorch/api
    -	rm -rf ./docs/source-app/generated
    -	rm -rf ./docs/source-app/*/generated
     	rm -rf build
     	rm -rf dist
     	rm -rf *.egg-info
     	rm -rf src/*.egg-info
    -	rm -rf src/lightning_app/*/
     	rm -rf src/lightning_fabric/*/
     	rm -rf src/pytorch_lightning/*/
     
     test: clean
     	# Review the CONTRIBUTING documentation for other ways to test.
     	pip install -e . \
     	-r requirements/pytorch/base.txt \
    -	-r requirements/app/app.txt \
     	-r requirements/fabric/base.txt \
     	-r requirements/pytorch/test.txt \
    -	-r requirements/app/test.txt
     
     	# run tests with coverage
     	python -m coverage run --source src/lightning/pytorch -m pytest src/lightning/pytorch tests/tests_pytorch -v
    -	python -m coverage run --source src/lightning/app -m pytest tests/tests/app -v
     	python -m coverage run --source src/lightning/fabric -m pytest src/lightning/fabric tests/tests_fabric -v
     	python -m coverage report
     
    @@ -54,10 +48,6 @@ sphinx-theme:
     	aws s3 sync --no-sign-request s3://sphinx-packages/ dist/
     	pip install lai-sphinx-theme -f dist/
     
    -docs-app: clean sphinx-theme
    -	pip install -e .[all] --quiet -r requirements/app/docs.txt
    -	cd docs/source-app && $(MAKE) html --jobs $(nproc)
    -
     docs-fabric: clean sphinx-theme
     	pip install -e .[all] --quiet -r requirements/fabric/docs.txt
     	cd docs/source-fabric && $(MAKE) html --jobs $(nproc)
    
  • .pre-commit-config.yaml+0 1 modified
    @@ -90,7 +90,6 @@ repos:
               - mdformat_frontmatter
             exclude: |
               (?x)^(
    -              src/lightning/app/CHANGELOG.md|
                   src/lightning/fabric/CHANGELOG.md|
                   src/lightning/pytorch/CHANGELOG.md|
                   README.md
    
  • .readthedocs.yml+1 2 modified
    @@ -42,8 +42,7 @@ build:
         - pip install -U pip awscli py-tree --user
         - python -m awscli s3 sync --no-sign-request s3://sphinx-packages/ dist/ ; ls -lh dist/
         - >
    -      pip install -e ".[app]" -q -r _notebooks/.actions/requires.txt \
    -          -r requirements/app/docs.txt \
    +      pip install -e . -q -r _notebooks/.actions/requires.txt \
               -r requirements/fabric/docs.txt \
               -r requirements/pytorch/docs.txt \
               -f 'https://download.pytorch.org/whl/cpu/torch_stable.html' -f dist/ ;
    

Vulnerability mechanics

Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

6

News mentions

0

No linked articles in our index yet.