code: def run(self):
      if self.work.counter == 0:
          self.work.run()
  
      elif (
          self.work.status.stage == WorkStageStatus.STOPPED
          and self.make_check
      ):
          succeeded_statuses = [
              status
              for status in self.work.statuses
              if status.stage == WorkStageStatus.SUCCEEDED
          ]
          # Ensure the work succeeded at some point
          assert len(succeeded_statuses) > 0
          succeeded_status = succeeded_statuses[-1]
  
          stopped_statuses = [
              status
              for status in self.work.statuses
              if status.stage == WorkStageStatus.STOPPED
          ]
  
          # We want to check that the work started shutting down withing the required timeframe, so we take the first
          # status that has `stage == STOPPED`.
          stopped_status = stopped_statuses[0]
  
          # Note: Account for the controlplane, k8s, SIGTERM handler delays.
          assert (
              stopped_status.timestamp - succeeded_status.timestamp
          ) < 20
  
          fs = _filesystem()
          destination_path = _artifacts_path(self.work) / pathlib.Path(
              *self.work.path.resolve().parts[1:]
          )
          assert fs.exists(destination_path)
          self.dest_work.run(self.work.path)
          self.make_check = False
          print("Successfully stopped SourceFileWriterWork.")
  
      if self.dest_work.status.stage == WorkStageStatus.SUCCEEDED:
          print("Stopping work")
          self.dest_work.stop()
  
      if self.dest_work.status.stage == WorkStageStatus.STOPPED:
          print(self.dest_work.statuses)
          print("Application End")
          self.stop()
  
file_path: pytorch-lightning/tests/integrations_app/apps/idle_timeout/app.py
imports: import pathlib
  from lightning.app import CloudCompute, LightningApp, LightningFlow, LightningWork
  from lightning.app.storage.path import _artifacts_path, _filesystem
  from lightning.app.utilities.enum import WorkStageStatus
label_desc: Use image node_id 2 for calling the RootFlow obj's underlying member method code with example usage: obj.run() without return types