Skip to main content

Use Lightning Apps to build everything from production-ready, multi-cloud ML systems to simple research demos.

Project description

With Lightning Apps, you build exactly what you need: from production-ready, multi-cloud ML systems to simple research demos.


WebsiteDocsGetting startedHelpSlack

PyPI - Python Version PyPI Status PyPI - Downloads Conda

readme-gif

From production-ready, multi-cloud ML systems to simple research demos.

Lightning Apps enable researchers, data scientists, and software engineers to build, share and iterate on highly scalable, complex AI workflows using the tools and technologies of their choice without any of the cloud boilerplate.

With Lightning Apps, your favorite components can work together on any machine at any scale.

Getting started

Install Lightning

Prerequisites

TIP: We strongly recommend creating a virtual environment first. Don’t know what this is? Follow our beginner guide here.

  • Python 3.8.x or later (3.8.x, 3.9.x, 3.10.x, ...)
  • Git
  • Set up an alias for python=python3
  • Add the root folder of Lightning to the Environment Variables to PATH
  • (quick-start app requirement) Install Z shell (zsh)
pip install -U lightning

Run your first Lightning App

  1. Install a simple training and deployment app by typing:
lightning install app lightning/quick-start
  1. If everything was successful, move into the new directory:
cd lightning-quick-start
  1. Run the app locally
lightning run app app.py
  1. Alternatively, run it on the public Lightning Cloud to share your app!
lightning run app app.py --cloud

Read this guide to learn the basics of Lightning Apps in 15 minutes.

Features

Lightning Apps consist of a root LightningFlow component, that optionally contains a tree of 2 types of components: LightningFlow 🌊 and LightningWork ⚒️. Key functionality includes:

  • A shared state between components.
  • A constantly running event loop for reactivity.
  • Dynamic attachment of components at runtime.
  • Start and stop functionality of your works.

Lightning Apps can run locally 💻 or on the cloud 🌩️.

Easy communication 🛰️ between components is supported with:

  • Directional state updates from the Works to the Flow creating an event: When creating interactive apps, you will likely want your components to share information with each other. You might to rely on that information to control their execution, share progress in the UI, trigger a sequence of operations, or more.
  • Storage: 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.
    • 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).
    • Payload: The Payload object enables transferring of Python objects from one work to another in a similar fashion as Path.
    • Drive: 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.

Lightning Apps have built-in support for adding UIs 🎨:

  • StaticWebFrontEnd: A frontend that serves static files from a directory using FastAPI.
  • StreamlitFrontend: A frontend for wrapping Streamlit code in your LightingFlow.
  • ServeGradio: This class enables you to quickly create a gradio based UI for your Lightning App.

Scheduling ⏲️: The Lightning Scheduling system makes it easy to schedule your components execution with any arbitrary conditions.

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.

Environment variables 💬: If your app is using secrets or values, such as API keys or access tokens, use environment variables to avoid sticking them in the source code.

Ready to use built-in components 🧱:

App gallery

The Lightning AI website features a curated gallery of Lightning Apps and components that makes it easy to get started. A few highlights:

App Description
Train & Demo PyTorch Lightning Train a model using PyTorch Lightning and deploy it to an interactive demo. Use this Lightning App as a starting point for building more complex apps around your models.
Lightning Sweeper Run a hyperparameter sweep over any model script across hundreds of cloud machines at once. This Lightning App uses Optuna to provide advanced tuning algorithms (from grid and random search to Hyperband).
Flashy Flashy, the auto-AI Lightning App, selects the best deep learning model for your image or text datasets. It automatically uses state-of-the-art models from Torchision, TIMM and Hugging Face.

Current limitations

  • Lightning requires Python 3.8.x or later (3.8.x, 3.9.x, 3.10.x).
  • For now, you can only run a single app locally at a time.
  • You are required to install the Lightning App requirements locally, even when starting the app on the cloud.
  • Multiple works cannot share the same machine.
  • To run on the cloud, you will need access to a browser.
  • Frontends only support the HTTP protocol. TCP support is coming in the future.
  • App Flow Frontends cannot be changed after startup, but you the layout can be updated reactively.
  • Authentication is not supported.

Asking for help

If you have any questions please:

  1. Read the docs.
  2. Search through existing Discussions, or add a new question
  3. Join our Discord community .

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lightning-app-2.3.2.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

lightning_app-2.3.2-py3-none-any.whl (1.2 MB view details)

Uploaded Python 3

File details

Details for the file lightning-app-2.3.2.tar.gz.

File metadata

  • Download URL: lightning-app-2.3.2.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for lightning-app-2.3.2.tar.gz
Algorithm Hash digest
SHA256 6275e91e8d1698f03ad5b319d8b417bd7d694019d6bae6183cfd3cefabd4e52d
MD5 9fdd8f7c002452356ade24ccf3482044
BLAKE2b-256 725386fc26bd642900350fdb06ba066a2440da11eefb233b7b9a6f8611c9aa8a

See more details on using hashes here.

File details

Details for the file lightning_app-2.3.2-py3-none-any.whl.

File metadata

File hashes

Hashes for lightning_app-2.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1f01bb8ca075656993e36bb9c44d69c7d46db5f7ad6b5ebebe31a81afce05443
MD5 bcb3dd3205a1065d4490e5a3da85506a
BLAKE2b-256 9b0f47826b657217d641cabffd36877f92ebc436ca027d3de634b05830d48b1e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page