Skip to content

Latest commit

 

History

History
141 lines (93 loc) · 9.03 KB

README.md

File metadata and controls

141 lines (93 loc) · 9.03 KB

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


WebsiteDocsGetting startedHelpSlack

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 Slack community.