Skip to content

Commit 60f9406

Browse files
justusschockpre-commit-ci[bot]Borda
authored
rename app _exit 2/2 (#16398)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Jirka Borovec <[email protected]>
1 parent 8f428a6 commit 60f9406

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/lightning_app/core/flow.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import inspect
2+
import warnings
23
from copy import deepcopy
34
from datetime import datetime
45
from types import FrameType
@@ -367,11 +368,27 @@ def set_state(self, provided_state: Dict, recurse: bool = True) -> None:
367368
getattr(self, structure).set_state(state)
368369

369370
def stop(self, end_msg: str = "") -> None:
370-
"""Private method used to exit the application."""
371+
"""Method used to exit the application."""
371372
if end_msg:
372373
print(end_msg)
373374
raise ExitAppException
374375

376+
def _exit(self, end_msg: str = "") -> None:
377+
"""Used to exit the application.
378+
379+
Private method.
380+
381+
.. deprecated:: 1.9.0
382+
This function is deprecated and will be removed in 2.0.0. Use :meth:`stop` instead.
383+
"""
384+
warnings.warn(
385+
DeprecationWarning(
386+
"This function is deprecated and will be removed in 2.0.0. Use `LightningFlow.stop` instead."
387+
)
388+
)
389+
390+
return self.stop(end_msg=end_msg)
391+
375392
@staticmethod
376393
def _is_state_attribute(name: str) -> bool:
377394
"""Every public attribute is part of the state by default and all protected (prefixed by '_') or private

tests/tests_app/core/test_lightning_flow.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,3 +954,9 @@ def run(self):
954954
assert len(v.component_names) == 1
955955
assert v.component_names[0][:-1] in ("root.w_list.", "root.w_dict.")
956956
assert v.component_names[0][-1].isdigit()
957+
958+
959+
def test_deprecation_warning_exit():
960+
with pytest.raises(ExitAppException):
961+
with pytest.warns(DeprecationWarning, match="*Use LightningFlow.stop instead"):
962+
RootFlowReady()._exit()

0 commit comments

Comments
 (0)