Skip to content

Commit 0abd686

Browse files
authored
Clarify work.stop() limitation (#16073)
1 parent 2a85d9b commit 0abd686

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/lightning_app/core/work.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -630,12 +630,12 @@ def on_exit(self):
630630
pass
631631

632632
def stop(self):
633-
"""Stops LightingWork component and shuts down hardware provisioned via L.CloudCompute."""
633+
"""Stops LightingWork component and shuts down hardware provisioned via L.CloudCompute.
634+
635+
This can only be called from a ``LightningFlow``.
636+
"""
634637
if not self._backend:
635-
raise Exception(
636-
"Can't stop the work, it looks like it isn't attached to a LightningFlow. "
637-
"Make sure to assign the Work to a flow instance."
638-
)
638+
raise RuntimeError(f"Only the `LightningFlow` can request this work ({self.name!r}) to stop.")
639639
if self.status.stage == WorkStageStatus.STOPPED:
640640
return
641641
latest_hash = self._calls[CacheCallsKeys.LATEST_CALL_HASH]

0 commit comments

Comments
 (0)