From 2c70bc38b5a6a752ce08b31bcad398af4ed7e712 Mon Sep 17 00:00:00 2001 From: thomas chaton Date: Wed, 23 Nov 2022 21:37:05 +0000 Subject: [PATCH 1/3] update --- src/lightning_app/core/flow.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lightning_app/core/flow.py b/src/lightning_app/core/flow.py index 18b6fd40f756a..9a50c58fd74bb 100644 --- a/src/lightning_app/core/flow.py +++ b/src/lightning_app/core/flow.py @@ -758,6 +758,9 @@ def __init__(self, work): self.work = work def run(self): + if self.work.has_succeeded: + self.work.stop() + self.work.run() def configure_layout(self): From 3ae2638eee3aad7d87cd5f9dcf4be889932645c7 Mon Sep 17 00:00:00 2001 From: thomas chaton Date: Wed, 23 Nov 2022 21:39:08 +0000 Subject: [PATCH 2/3] update --- src/lightning_app/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lightning_app/CHANGELOG.md b/src/lightning_app/CHANGELOG.md index 5673fcadf48d0..3b221b982728a 100644 --- a/src/lightning_app/CHANGELOG.md +++ b/src/lightning_app/CHANGELOG.md @@ -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 From d943888f8b62727658404c8b99ec403f110623f3 Mon Sep 17 00:00:00 2001 From: thomas chaton Date: Wed, 23 Nov 2022 21:42:45 +0000 Subject: [PATCH 3/3] update --- src/lightning_app/core/flow.py | 2 +- tests/tests_app/core/test_lightning_app.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/lightning_app/core/flow.py b/src/lightning_app/core/flow.py index 9a50c58fd74bb..3773c7a0dd4f0 100644 --- a/src/lightning_app/core/flow.py +++ b/src/lightning_app/core/flow.py @@ -760,7 +760,7 @@ def __init__(self, work): def run(self): if self.work.has_succeeded: self.work.stop() - + self._exit() self.work.run() def configure_layout(self): diff --git a/tests/tests_app/core/test_lightning_app.py b/tests/tests_app/core/test_lightning_app.py index 64bee758af5d5..8bc6c6418e81c 100644 --- a/tests/tests_app/core/test_lightning_app.py +++ b/tests/tests_app/core/test_lightning_app.py @@ -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()