Package: lightning-app
With Lightning Apps, you build exactly what you need: from production-ready, multi-cloud ML systems to simple research demos.Website•Docs•Getting started•Help•SlackFrom 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 startedInstall LightningPrerequisitesTIP: We strongly recommend creating a virtual environment first.
Don’t know what this is? Follow ourbeginner guide here.Python 3.8.x or later (3.8.x, 3.9.x, 3.10.x, ...)GitSet up an alias for python=python3Add the root folder of Lightning to the Environment Variables to PATH(quick-start app requirement) Install Z shell (zsh)pipinstall-UlightningRun your first Lightning AppInstall a simple training and deployment app by typing:lightninginstallapplightning/quick-startIf everything was successful, move into the new directory:cdlightning-quick-startRun the app locallylightningrunappapp.pyAlternatively, run it on the public Lightning Cloud to share your app!lightningrunappapp.py--cloudRead this guideto learn the basics of Lightning Apps in 15 minutes.FeaturesLightning Apps consist of a rootLightningFlowcomponent, that optionally contains a tree of 2 types of components:LightningFlow🌊 andLightningWork⚒️. 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 runlocally💻 oron the cloud🌩️.Easy communication 🛰️ between components is supported with:Directional state updatesfrom 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 foradding 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 agradiobased 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 canspecify 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 usebuilt-in components🧱:PopenPythonScript: This class enables you to easily run a Python Script.ModelInferenceAPI: This class enables you to easily get your model served.App galleryTheLightning AI websitefeatures a curated gallery of Lightning Apps and components that makes it easy to get started. A few highlights:AppDescriptionTrain & Demo PyTorch LightningTrain 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 SweeperRun 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).FlashyFlashy, 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 limitationsLightning 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 helpIf you have any questions please:Read the docs.Search through existing Discussions, oradd a new questionJoin our Discord community.