From 0abd6864082a456c07e03b80b0a60075b3f33efa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Mon, 19 Dec 2022 16:02:21 +0100 Subject: [PATCH] Clarify `work.stop()` limitation (#16073) --- src/lightning_app/core/work.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lightning_app/core/work.py b/src/lightning_app/core/work.py index 061f591277c61..863d50db47cec 100644 --- a/src/lightning_app/core/work.py +++ b/src/lightning_app/core/work.py @@ -630,12 +630,12 @@ def on_exit(self): pass def stop(self): - """Stops LightingWork component and shuts down hardware provisioned via L.CloudCompute.""" + """Stops LightingWork component and shuts down hardware provisioned via L.CloudCompute. + + This can only be called from a ``LightningFlow``. + """ if not self._backend: - raise Exception( - "Can't stop the work, it looks like it isn't attached to a LightningFlow. " - "Make sure to assign the Work to a flow instance." - ) + raise RuntimeError(f"Only the `LightningFlow` can request this work ({self.name!r}) to stop.") if self.status.stage == WorkStageStatus.STOPPED: return latest_hash = self._calls[CacheCallsKeys.LATEST_CALL_HASH]