Skip to content

Commit

Permalink
rename app _exit 2/2 (#16398)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Jirka Borovec <6035284+Borda@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 17, 2023
1 parent 8f428a6 commit 60f9406
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/lightning_app/core/flow.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import inspect
import warnings
from copy import deepcopy
from datetime import datetime
from types import FrameType
Expand Down Expand Up @@ -367,11 +368,27 @@ def set_state(self, provided_state: Dict, recurse: bool = True) -> None:
getattr(self, structure).set_state(state)

def stop(self, end_msg: str = "") -> None:
"""Private method used to exit the application."""
"""Method used to exit the application."""
if end_msg:
print(end_msg)
raise ExitAppException

def _exit(self, end_msg: str = "") -> None:
"""Used to exit the application.
Private method.
.. deprecated:: 1.9.0
This function is deprecated and will be removed in 2.0.0. Use :meth:`stop` instead.
"""
warnings.warn(
DeprecationWarning(
"This function is deprecated and will be removed in 2.0.0. Use `LightningFlow.stop` instead."
)
)

return self.stop(end_msg=end_msg)

@staticmethod
def _is_state_attribute(name: str) -> bool:
"""Every public attribute is part of the state by default and all protected (prefixed by '_') or private
Expand Down
6 changes: 6 additions & 0 deletions tests/tests_app/core/test_lightning_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -954,3 +954,9 @@ def run(self):
assert len(v.component_names) == 1
assert v.component_names[0][:-1] in ("root.w_list.", "root.w_dict.")
assert v.component_names[0][-1].isdigit()


def test_deprecation_warning_exit():
with pytest.raises(ExitAppException):
with pytest.warns(DeprecationWarning, match="*Use LightningFlow.stop instead"):
RootFlowReady()._exit()

0 comments on commit 60f9406

Please sign in to comment.