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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[App] Stop App when it has succeeded #15801

Merged
merged 3 commits into from Nov 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/lightning_app/CHANGELOG.md
Expand Up @@ -32,6 +32,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Fixed debugging with VSCode IDE ([#15747](https://github.com/Lightning-AI/lightning/pull/15747))


- Fixed the work not stopped when successful when passed directly to the LightningApp ([#15801](https://github.com/Lightning-AI/lightning/pull/15801))


## [1.8.2] - 2022-11-17

### Added
Expand Down
3 changes: 3 additions & 0 deletions src/lightning_app/core/flow.py
Expand Up @@ -758,6 +758,9 @@ def __init__(self, work):
self.work = work

def run(self):
if self.work.has_succeeded:
self.work.stop()
self._exit()
self.work.run()

def configure_layout(self):
Expand Down
11 changes: 11 additions & 0 deletions tests/tests_app/core/test_lightning_app.py
Expand Up @@ -1134,3 +1134,14 @@ def test_lightning_flow_properties():
assert flow._value is None
flow.run()
assert flow._value is True


class SimpleWork2(LightningWork):
def run(self):
pass


def test_lightning_work_stopped():

app = LightningApp(SimpleWork2())
MultiProcessRuntime(app, start_server=False).dispatch()