LightningApp¶
- class lightning.app.core.LightningApp(root, flow_cloud_compute=None, log_level='info', info=None, root_path='')[source]¶
Bases:
object
The Lightning App, or App in short runs a tree of one or more components that interact to create end-to-end applications. There are two kinds of components:
LightningFlow
andLightningWork
. This modular design enables you to reuse components created by other users.The Lightning App alternatively run an event loop triggered by delta changes sent from either
LightningWork
or from the Lightning UI. Once deltas are received, the Lightning App runs theLightningFlow
provided.- Parameters:
root¶ (
Union
[LightningFlow
,LightningWork
]) – The rootLightningFlow
orLightningWork
component, that defines all the app’s nested components, running infinitely. It must define a run() method that the app can call.flow_cloud_compute¶ (
Optional
[CloudCompute
]) – The default Cloud Compute used for flow, Rest API and frontend’s.log_level¶ (
str
) – The log level for the app, one of [info, debug]. This can be helpful when reporting bugs on Lightning repo.info¶ (
Optional
[AppInfo
]) – Provide additional info about the app which will be used to update html title, description and image meta tags and specify any additional tags as list of html strings.root_path¶ (
str
) – Set this to /path if you want to run your app behind a proxy at /path leave empty for “/”. For instance, if you want to run your app at https://customdomain.com/myapp, set root_path to /myapp. You can learn more about proxy here.
- _run()[source]¶
Entry point of the LightningApp.
This would be dispatched by the Runtime objects.
- Return type:
- get_component_by_name(component_name)[source]¶
Returns the instance corresponding to the given component name.
- Return type:
- maybe_apply_changes()[source]¶
Get the deltas from both the flow queue and the work queue, merge the two deltas and update the state.
- property flows: List[Union[LightningWork, LightningFlow]][source]¶
Returns all the flows defined within this application.
- property named_works: List[Tuple[str, LightningWork]][source]¶
Returns all the works defined within this application with their names.
- property root: Union[LightningFlow, LightningWork][source]¶
Returns the root component of the application.
- property state_vars: dict[source]¶
Return the current state restricted to the user defined variables of the application.
- property state_with_changes: dict[source]¶
Return the current state with the new changes of the application.
- property works: List[LightningWork][source]¶
Returns all the works defined within this application.