2022-06-30 20:45:15 +00:00
|
|
|
import os
|
|
|
|
from pathlib import Path
|
|
|
|
|
2023-01-10 13:11:08 +00:00
|
|
|
import lightning as L
|
2023-03-03 16:55:48 +00:00
|
|
|
from examples.components.python.component_tracer import PLTracerPythonScript
|
2023-01-10 13:11:08 +00:00
|
|
|
|
2022-06-30 20:45:15 +00:00
|
|
|
|
|
|
|
class RootFlow(L.LightningFlow):
|
|
|
|
def __init__(self):
|
|
|
|
super().__init__()
|
|
|
|
script_path = Path(__file__).parent / "pl_script.py"
|
|
|
|
self.tracer_python_script = PLTracerPythonScript(script_path)
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
assert os.getenv("GLOBAL_RANK", "0") == "0"
|
|
|
|
if not self.tracer_python_script.has_started:
|
|
|
|
self.tracer_python_script.run()
|
|
|
|
if self.tracer_python_script.has_succeeded:
|
2023-01-17 11:06:50 +00:00
|
|
|
self.stop("tracer script succeed")
|
2022-06-30 20:45:15 +00:00
|
|
|
if self.tracer_python_script.has_failed:
|
2023-01-17 11:06:50 +00:00
|
|
|
self.stop("tracer script failed")
|
2022-06-30 20:45:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
app = L.LightningApp(RootFlow())
|