Skip to content

Commit

Permalink
[App] Stop App when it has succeeded (#15801)
Browse files Browse the repository at this point in the history
  • Loading branch information
tchaton authored Nov 24, 2022
1 parent b682d4c commit 3a99a25
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lightning_app/CHANGELOG.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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()

0 comments on commit 3a99a25

Please sign in to comment.