Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify work.stop() limitation #16073

Merged
merged 2 commits into from
Dec 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/lightning_app/core/work.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,12 +609,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. "
carmocca marked this conversation as resolved.
Show resolved Hide resolved
"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]
Expand Down