Level 5: Debug A Lightning app

Audience: Users who want to debug a distributed app locally.

Prereqs: You must have finished the Basic levels.


Enable breakpoints

To enable a breakpoint, use set_trace() (note direct python pdb support is work in progress and open to contributions).

Toy app
Add a breakpoint. When the program runs, it will stop at this line.
# 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())


Next: Run a component in parallel

Learn to run components in parallel to enable more powerful workflows.