From be1e9d609a427e00d17d6d6cd1e8d370a4c0f126 Mon Sep 17 00:00:00 2001 From: Justus Schock Date: Fri, 9 Feb 2024 16:50:17 +0000 Subject: [PATCH 01/20] update --- _notebooks | 1 - docs/source-fabric/fundamentals/launch.rst | 12 ++++++------ src/lightning/__setup__.py | 1 + src/lightning/fabric/cli.py | 12 ++++++++++-- src/lightning_fabric/__setup__.py | 5 +++++ 5 files changed, 22 insertions(+), 9 deletions(-) delete mode 160000 _notebooks diff --git a/_notebooks b/_notebooks deleted file mode 160000 index 543a8d8200662..0000000000000 --- a/_notebooks +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 543a8d82006620906dc9eb669eab18d06ebe6863 diff --git a/docs/source-fabric/fundamentals/launch.rst b/docs/source-fabric/fundamentals/launch.rst index 0f25ebcda6021..d30a75621300c 100644 --- a/docs/source-fabric/fundamentals/launch.rst +++ b/docs/source-fabric/fundamentals/launch.rst @@ -67,7 +67,7 @@ An alternative way to launch your Python script in multiple processes is to use .. code-block:: bash - lightning run model path/to/your/script.py + fabric run model path/to/your/script.py This is essentially the same as running ``python path/to/your/script.py``, but it also lets you configure the following settings externally without changing your code: @@ -80,9 +80,9 @@ This is essentially the same as running ``python path/to/your/script.py``, but i .. code-block:: bash - lightning run model --help + fabric run model --help - Usage: lightning run model [OPTIONS] SCRIPT [SCRIPT_ARGS]... + Usage: fabric run model [OPTIONS] SCRIPT [SCRIPT_ARGS]... Run a Lightning Fabric script. @@ -128,7 +128,7 @@ Here is how you run DDP with 8 GPUs and `torch.bfloat16 `_ w .. code-block:: bash - lightning run model ./path/to/train.py \ + fabric run model ./path/to/train.py \ --strategy=deepspeed_stage_3 \ --devices=8 \ --accelerator=cuda \ @@ -148,7 +148,7 @@ Or `DeepSpeed Zero3 `_ w .. code-block:: bash - lightning run model ./path/to/train.py \ + fabric run model ./path/to/train.py \ --devices=auto \ --accelerator=auto \ --precision=16 diff --git a/src/lightning/__setup__.py b/src/lightning/__setup__.py index f5d3cab96d86c..96eebb1e34341 100644 --- a/src/lightning/__setup__.py +++ b/src/lightning/__setup__.py @@ -115,6 +115,7 @@ def _setup_args() -> Dict[str, Any]: "entry_points": { "console_scripts": [ "lightning = lightning:_cli_entry_point", + "fabric = lightning.fabric.cli:_main", ], }, "setup_requires": [], diff --git a/src/lightning/fabric/cli.py b/src/lightning/fabric/cli.py index 0ff777232a7fb..e3d580bb115b0 100644 --- a/src/lightning/fabric/cli.py +++ b/src/lightning/fabric/cli.py @@ -44,7 +44,15 @@ def _get_supported_strategies() -> List[str]: if _CLICK_AVAILABLE: import click - @click.command( + @click.group() + def _main() -> None: + pass + + @_main.group() + def run() -> None: + pass + + @run.command( "model", context_settings={ "ignore_unknown_options": True, @@ -127,7 +135,7 @@ def _run_model(**kwargs: Any) -> None: """ script_args = list(kwargs.pop("script_args", [])) main(args=Namespace(**kwargs), script_args=script_args) - + def _set_env_variables(args: Namespace) -> None: """Set the environment variables for the new processes. diff --git a/src/lightning_fabric/__setup__.py b/src/lightning_fabric/__setup__.py index 869ffad571f7e..d21dcc6b721ca 100644 --- a/src/lightning_fabric/__setup__.py +++ b/src/lightning_fabric/__setup__.py @@ -78,6 +78,11 @@ def _setup_args() -> Dict[str, Any]: "install_requires": assistant.load_requirements( _PATH_REQUIREMENTS, unfreeze="none" if _FREEZE_REQUIREMENTS else "all" ), + "entry_points": { + "console_scripts": [ + "fabric = lightning_fabric.cli:main", + ], + }, "extras_require": _prepare_extras(), "project_urls": { "Bug Tracker": "https://github.com/Lightning-AI/lightning/issues", From da2866c5760e51f8d04f1c4e51ba55edf6554e22 Mon Sep 17 00:00:00 2001 From: Justus Schock Date: Fri, 9 Feb 2024 16:53:18 +0000 Subject: [PATCH 02/20] update --- _notebooks | 1 + 1 file changed, 1 insertion(+) create mode 160000 _notebooks diff --git a/_notebooks b/_notebooks new file mode 160000 index 0000000000000..543a8d8200662 --- /dev/null +++ b/_notebooks @@ -0,0 +1 @@ +Subproject commit 543a8d82006620906dc9eb669eab18d06ebe6863 From 77b057a24db4d1b984789163ac03cff767aabaa0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 9 Feb 2024 16:55:29 +0000 Subject: [PATCH 03/20] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/lightning/fabric/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lightning/fabric/cli.py b/src/lightning/fabric/cli.py index e3d580bb115b0..c71921a7c358c 100644 --- a/src/lightning/fabric/cli.py +++ b/src/lightning/fabric/cli.py @@ -135,7 +135,7 @@ def _run_model(**kwargs: Any) -> None: """ script_args = list(kwargs.pop("script_args", [])) main(args=Namespace(**kwargs), script_args=script_args) - + def _set_env_variables(args: Namespace) -> None: """Set the environment variables for the new processes. From 40b757ef6705f30b5723ff75017103d57055f61f Mon Sep 17 00:00:00 2001 From: Justus Schock Date: Fri, 9 Feb 2024 16:55:38 +0000 Subject: [PATCH 04/20] changelog --- src/lightning/fabric/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lightning/fabric/CHANGELOG.md b/src/lightning/fabric/CHANGELOG.md index 9e32953100bfa..ab6f0f4971f27 100644 --- a/src/lightning/fabric/CHANGELOG.md +++ b/src/lightning/fabric/CHANGELOG.md @@ -17,7 +17,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ### Changed -- +- Rename `lightning run model` to `fabric run model` ([#19442](https://github.com/Lightning-AI/pytorch-lightning/pull/19442)) - From 72f2531bc54e8be92faf49696cefabc71a3ab9e5 Mon Sep 17 00:00:00 2001 From: Justus Schock Date: Fri, 9 Feb 2024 17:13:43 +0000 Subject: [PATCH 05/20] update --- tests/tests_fabric/test_cli.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/tests_fabric/test_cli.py b/tests/tests_fabric/test_cli.py index c8e9a6bbedd57..e1a7b6f61e4fa 100644 --- a/tests/tests_fabric/test_cli.py +++ b/tests/tests_fabric/test_cli.py @@ -178,11 +178,11 @@ def test_cli_torchrun_num_processes_launched(_, devices, expected, monkeypatch, @pytest.mark.skipif("lightning.fabric" == "lightning_fabric", reason="standalone package") def test_cli_through_lightning_entry_point(): - result = subprocess.run("lightning run model --help", capture_output=True, text=True, shell=True) + result = subprocess.run("fabric run model --help", capture_output=True, text=True, shell=True) if not ModuleAvailableCache("lightning.app"): - message = "The `lightning` command requires additional dependencies" + message = "The `fabric` command requires additional dependencies" assert message in result.stdout or message in result.stderr assert result.returncode != 0 else: - message = "Usage: lightning run model [OPTIONS] SCRIPT [SCRIPT_ARGS]" + message = "Usage: fabric run model [OPTIONS] SCRIPT [SCRIPT_ARGS]" assert message in result.stdout or message in result.stderr From 39bb0b3733362b083339b26b432a0809fa236098 Mon Sep 17 00:00:00 2001 From: Justus Schock Date: Fri, 9 Feb 2024 17:37:25 +0000 Subject: [PATCH 06/20] update --- _notebooks | 1 - tests/tests_fabric/test_cli.py | 11 +++-------- 2 files changed, 3 insertions(+), 9 deletions(-) delete mode 160000 _notebooks diff --git a/_notebooks b/_notebooks deleted file mode 160000 index 543a8d8200662..0000000000000 --- a/_notebooks +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 543a8d82006620906dc9eb669eab18d06ebe6863 diff --git a/tests/tests_fabric/test_cli.py b/tests/tests_fabric/test_cli.py index e1a7b6f61e4fa..c90451e765af3 100644 --- a/tests/tests_fabric/test_cli.py +++ b/tests/tests_fabric/test_cli.py @@ -176,13 +176,8 @@ def test_cli_torchrun_num_processes_launched(_, devices, expected, monkeypatch, ) -@pytest.mark.skipif("lightning.fabric" == "lightning_fabric", reason="standalone package") def test_cli_through_lightning_entry_point(): result = subprocess.run("fabric run model --help", capture_output=True, text=True, shell=True) - if not ModuleAvailableCache("lightning.app"): - message = "The `fabric` command requires additional dependencies" - assert message in result.stdout or message in result.stderr - assert result.returncode != 0 - else: - message = "Usage: fabric run model [OPTIONS] SCRIPT [SCRIPT_ARGS]" - assert message in result.stdout or message in result.stderr + + message = "Usage: fabric run model [OPTIONS] SCRIPT [SCRIPT_ARGS]" + assert message in result.stdout or message in result.stderr From 9bdfe1b186ad012398947dfa8e8e449d60c741fc Mon Sep 17 00:00:00 2001 From: Justus Schock Date: Fri, 9 Feb 2024 17:37:49 +0000 Subject: [PATCH 07/20] update --- _notebooks | 1 + 1 file changed, 1 insertion(+) create mode 160000 _notebooks diff --git a/_notebooks b/_notebooks new file mode 160000 index 0000000000000..543a8d8200662 --- /dev/null +++ b/_notebooks @@ -0,0 +1 @@ +Subproject commit 543a8d82006620906dc9eb669eab18d06ebe6863 From e60bb0e870d287b6100ee73f435d13a607940ae8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 9 Feb 2024 17:40:34 +0000 Subject: [PATCH 08/20] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/tests_fabric/test_cli.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/tests_fabric/test_cli.py b/tests/tests_fabric/test_cli.py index c90451e765af3..61e8a68dbdd63 100644 --- a/tests/tests_fabric/test_cli.py +++ b/tests/tests_fabric/test_cli.py @@ -21,7 +21,6 @@ import pytest from lightning.fabric.cli import _get_supported_strategies, _run_model -from lightning_utilities.core.imports import ModuleAvailableCache from tests_fabric.helpers.runif import RunIf @@ -178,6 +177,6 @@ def test_cli_torchrun_num_processes_launched(_, devices, expected, monkeypatch, def test_cli_through_lightning_entry_point(): result = subprocess.run("fabric run model --help", capture_output=True, text=True, shell=True) - + message = "Usage: fabric run model [OPTIONS] SCRIPT [SCRIPT_ARGS]" assert message in result.stdout or message in result.stderr From 00c0ac499b669b39ed4e69e9299a0d85c1b7e670 Mon Sep 17 00:00:00 2001 From: Justus Schock <12886177+justusschock@users.noreply.github.com> Date: Sat, 10 Feb 2024 08:26:35 +0100 Subject: [PATCH 09/20] typo --- src/lightning_fabric/__setup__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lightning_fabric/__setup__.py b/src/lightning_fabric/__setup__.py index d21dcc6b721ca..8fe0bc0937ef5 100644 --- a/src/lightning_fabric/__setup__.py +++ b/src/lightning_fabric/__setup__.py @@ -80,7 +80,7 @@ def _setup_args() -> Dict[str, Any]: ), "entry_points": { "console_scripts": [ - "fabric = lightning_fabric.cli:main", + "fabric = lightning_fabric.cli:_main", ], }, "extras_require": _prepare_extras(), From 8905f03bfcdbcd074e56533575aeaef5683a559c Mon Sep 17 00:00:00 2001 From: Justus Schock Date: Mon, 12 Feb 2024 08:35:08 +0000 Subject: [PATCH 10/20] update legacy cli --- src/lightning/__setup__.py | 1 + src/lightning/fabric/cli.py | 18 ++++++++++++++++++ tests/tests_fabric/test_cli.py | 8 +++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/lightning/__setup__.py b/src/lightning/__setup__.py index bb620fefcdb9c..b9b19143bbe13 100644 --- a/src/lightning/__setup__.py +++ b/src/lightning/__setup__.py @@ -115,6 +115,7 @@ def _setup_args() -> Dict[str, Any]: "entry_points": { "console_scripts": [ "fabric = lightning.fabric.cli:_main", + "lightning = lightning.fabric.cli:_legacy_main", "lightning_app = lightning:_cli_entry_point", ], }, diff --git a/src/lightning/fabric/cli.py b/src/lightning/fabric/cli.py index c71921a7c358c..9b2505ab0daa0 100644 --- a/src/lightning/fabric/cli.py +++ b/src/lightning/fabric/cli.py @@ -16,6 +16,9 @@ import re from argparse import Namespace from typing import Any, List, Optional +import warnings +import sys +import subprocess from lightning_utilities.core.imports import RequirementCache from typing_extensions import get_args @@ -29,6 +32,7 @@ _log = logging.getLogger(__name__) _CLICK_AVAILABLE = RequirementCache("click") +_LIGHTNING_SDK_AVAILABLE = RequirementCache("lightning_sdk") _SUPPORTED_ACCELERATORS = ("cpu", "gpu", "cuda", "mps", "tpu") @@ -44,6 +48,20 @@ def _get_supported_strategies() -> List[str]: if _CLICK_AVAILABLE: import click + def _legacy_main(): + """legacy CLI handler for fabric. Raises deprecation warning and runs through fabric cli if necessary, else runs the entrypoint directly""" + warnings.warn("lightning run model is deprecated and will be removed in future versions." + " Please call `fabric run model` instead.", DeprecationWarning) + args = sys.argv[1:] + if args and args[0] == "run" and args[1] == "model": + # raise Deprecation Warning + subprocess.run(["fabric"]+args) + return + + if _LIGHTNING_SDK_AVAILABLE: + subprocess.run([sys.executable, "-m", "lightning_sdk.cli.entrypoint"] + args) + return + @click.group() def _main() -> None: pass diff --git a/tests/tests_fabric/test_cli.py b/tests/tests_fabric/test_cli.py index 61e8a68dbdd63..183d6208918bc 100644 --- a/tests/tests_fabric/test_cli.py +++ b/tests/tests_fabric/test_cli.py @@ -175,8 +175,14 @@ def test_cli_torchrun_num_processes_launched(_, devices, expected, monkeypatch, ) -def test_cli_through_lightning_entry_point(): +def test_cli_through_fabric_entry_point(): result = subprocess.run("fabric run model --help", capture_output=True, text=True, shell=True) message = "Usage: fabric run model [OPTIONS] SCRIPT [SCRIPT_ARGS]" assert message in result.stdout or message in result.stderr + +def test_cli_through_lightning_entry_point(): + result = subprocess.run("lightning run model --help", capture_output=True, text=True, shell=True) + + message = "Usage: fabric run model [OPTIONS] SCRIPT [SCRIPT_ARGS]" + assert message in result.stdout or message in result.stderr From fc86cb89c2431187efe6587a7bfda23d2748b68b Mon Sep 17 00:00:00 2001 From: Justus Schock Date: Mon, 12 Feb 2024 08:40:13 +0000 Subject: [PATCH 11/20] update --- _notebooks | 1 - 1 file changed, 1 deletion(-) delete mode 160000 _notebooks diff --git a/_notebooks b/_notebooks deleted file mode 160000 index 543a8d8200662..0000000000000 --- a/_notebooks +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 543a8d82006620906dc9eb669eab18d06ebe6863 From 884cf2082c6238e03dcefa350b1e23a592e118c4 Mon Sep 17 00:00:00 2001 From: Justus Schock Date: Mon, 12 Feb 2024 08:41:02 +0000 Subject: [PATCH 12/20] update --- _notebooks | 1 + 1 file changed, 1 insertion(+) create mode 160000 _notebooks diff --git a/_notebooks b/_notebooks new file mode 160000 index 0000000000000..543a8d8200662 --- /dev/null +++ b/_notebooks @@ -0,0 +1 @@ +Subproject commit 543a8d82006620906dc9eb669eab18d06ebe6863 From 8bc59a882027ce69420ba919aea823d43d1d52b0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 12 Feb 2024 08:42:07 +0000 Subject: [PATCH 13/20] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/lightning/fabric/cli.py | 14 +++++++++----- tests/tests_fabric/test_cli.py | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/lightning/fabric/cli.py b/src/lightning/fabric/cli.py index 9b2505ab0daa0..3a337211058c8 100644 --- a/src/lightning/fabric/cli.py +++ b/src/lightning/fabric/cli.py @@ -14,11 +14,11 @@ import logging import os import re +import subprocess +import sys +import warnings from argparse import Namespace from typing import Any, List, Optional -import warnings -import sys -import subprocess from lightning_utilities.core.imports import RequirementCache from typing_extensions import get_args @@ -49,13 +49,17 @@ def _get_supported_strategies() -> List[str]: import click def _legacy_main(): - """legacy CLI handler for fabric. Raises deprecation warning and runs through fabric cli if necessary, else runs the entrypoint directly""" + """Legacy CLI handler for fabric. + + Raises deprecation warning and runs through fabric cli if necessary, else runs the entrypoint directly + + """ warnings.warn("lightning run model is deprecated and will be removed in future versions." " Please call `fabric run model` instead.", DeprecationWarning) args = sys.argv[1:] if args and args[0] == "run" and args[1] == "model": # raise Deprecation Warning - subprocess.run(["fabric"]+args) + subprocess.run(["fabric"] + args) return if _LIGHTNING_SDK_AVAILABLE: diff --git a/tests/tests_fabric/test_cli.py b/tests/tests_fabric/test_cli.py index 183d6208918bc..0df02409c9921 100644 --- a/tests/tests_fabric/test_cli.py +++ b/tests/tests_fabric/test_cli.py @@ -183,6 +183,6 @@ def test_cli_through_fabric_entry_point(): def test_cli_through_lightning_entry_point(): result = subprocess.run("lightning run model --help", capture_output=True, text=True, shell=True) - + message = "Usage: fabric run model [OPTIONS] SCRIPT [SCRIPT_ARGS]" assert message in result.stdout or message in result.stderr From 9e1179dbf730fb2ba7102ee272c4a844b242c0d7 Mon Sep 17 00:00:00 2001 From: Justus Schock Date: Mon, 12 Feb 2024 08:42:53 +0000 Subject: [PATCH 14/20] update --- tests/tests_fabric/test_cli.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/tests_fabric/test_cli.py b/tests/tests_fabric/test_cli.py index 0df02409c9921..eb5eb43f489a2 100644 --- a/tests/tests_fabric/test_cli.py +++ b/tests/tests_fabric/test_cli.py @@ -181,6 +181,7 @@ def test_cli_through_fabric_entry_point(): message = "Usage: fabric run model [OPTIONS] SCRIPT [SCRIPT_ARGS]" assert message in result.stdout or message in result.stderr +@pytest.mark.skipif("lightning.fabric" == "lightning_fabric", reason="standalone package") def test_cli_through_lightning_entry_point(): result = subprocess.run("lightning run model --help", capture_output=True, text=True, shell=True) From 286509dfaaa1c986ba1304ae3b72a71e9754cd30 Mon Sep 17 00:00:00 2001 From: Justus Schock Date: Mon, 12 Feb 2024 08:59:57 +0000 Subject: [PATCH 15/20] update --- src/lightning/fabric/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lightning/fabric/cli.py b/src/lightning/fabric/cli.py index 3a337211058c8..35c133f2e21bc 100644 --- a/src/lightning/fabric/cli.py +++ b/src/lightning/fabric/cli.py @@ -48,7 +48,7 @@ def _get_supported_strategies() -> List[str]: if _CLICK_AVAILABLE: import click - def _legacy_main(): + def _legacy_main() -> None: """Legacy CLI handler for fabric. Raises deprecation warning and runs through fabric cli if necessary, else runs the entrypoint directly From 24594c8b2922c28baeb0ade32d328f1df24a7437 Mon Sep 17 00:00:00 2001 From: Justus Schock Date: Mon, 12 Feb 2024 11:02:46 +0000 Subject: [PATCH 16/20] remove subprocess invocation --- src/lightning/fabric/cli.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/lightning/fabric/cli.py b/src/lightning/fabric/cli.py index 35c133f2e21bc..fe2129079201d 100644 --- a/src/lightning/fabric/cli.py +++ b/src/lightning/fabric/cli.py @@ -16,7 +16,6 @@ import re import subprocess import sys -import warnings from argparse import Namespace from typing import Any, List, Optional @@ -54,11 +53,10 @@ def _legacy_main() -> None: Raises deprecation warning and runs through fabric cli if necessary, else runs the entrypoint directly """ - warnings.warn("lightning run model is deprecated and will be removed in future versions." - " Please call `fabric run model` instead.", DeprecationWarning) + print("`lightning run model` is deprecated and will be removed in future versions." + " Please call `fabric run model` instead.") args = sys.argv[1:] if args and args[0] == "run" and args[1] == "model": - # raise Deprecation Warning subprocess.run(["fabric"] + args) return From 1799bb40be60780db3393d107906065a557245b2 Mon Sep 17 00:00:00 2001 From: Justus Schock Date: Mon, 12 Feb 2024 11:05:05 +0000 Subject: [PATCH 17/20] update --- src/lightning/fabric/cli.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lightning/fabric/cli.py b/src/lightning/fabric/cli.py index fe2129079201d..1718c22fb266f 100644 --- a/src/lightning/fabric/cli.py +++ b/src/lightning/fabric/cli.py @@ -57,8 +57,7 @@ def _legacy_main() -> None: " Please call `fabric run model` instead.") args = sys.argv[1:] if args and args[0] == "run" and args[1] == "model": - subprocess.run(["fabric"] + args) - return + _main() if _LIGHTNING_SDK_AVAILABLE: subprocess.run([sys.executable, "-m", "lightning_sdk.cli.entrypoint"] + args) From 5fce6acdc736d05ed270948832a66699d17a2261 Mon Sep 17 00:00:00 2001 From: Justus Schock Date: Mon, 12 Feb 2024 11:23:21 +0000 Subject: [PATCH 18/20] update --- src/lightning/fabric/cli.py | 1 + tests/tests_fabric/test_cli.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lightning/fabric/cli.py b/src/lightning/fabric/cli.py index 1718c22fb266f..2805675cecf70 100644 --- a/src/lightning/fabric/cli.py +++ b/src/lightning/fabric/cli.py @@ -58,6 +58,7 @@ def _legacy_main() -> None: args = sys.argv[1:] if args and args[0] == "run" and args[1] == "model": _main() + return if _LIGHTNING_SDK_AVAILABLE: subprocess.run([sys.executable, "-m", "lightning_sdk.cli.entrypoint"] + args) diff --git a/tests/tests_fabric/test_cli.py b/tests/tests_fabric/test_cli.py index eb5eb43f489a2..1f1adcbb15856 100644 --- a/tests/tests_fabric/test_cli.py +++ b/tests/tests_fabric/test_cli.py @@ -185,5 +185,8 @@ def test_cli_through_fabric_entry_point(): def test_cli_through_lightning_entry_point(): result = subprocess.run("lightning run model --help", capture_output=True, text=True, shell=True) - message = "Usage: fabric run model [OPTIONS] SCRIPT [SCRIPT_ARGS]" + deprecation_message = ("`lightning run model` is deprecated and will be removed in future versions. " + "Please call `fabric run model` instead") + message = "Usage: lightning run model [OPTIONS] SCRIPT [SCRIPT_ARGS]" + assert deprecation_message in result.stdout assert message in result.stdout or message in result.stderr From 9efefa9b19c2b6db002833b8e7c23e84d6374b4c Mon Sep 17 00:00:00 2001 From: Justus Schock Date: Mon, 12 Feb 2024 11:23:58 +0000 Subject: [PATCH 19/20] update --- tests/tests_fabric/test_cli.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/tests_fabric/test_cli.py b/tests/tests_fabric/test_cli.py index 1f1adcbb15856..e6049ac0d9611 100644 --- a/tests/tests_fabric/test_cli.py +++ b/tests/tests_fabric/test_cli.py @@ -185,8 +185,10 @@ def test_cli_through_fabric_entry_point(): def test_cli_through_lightning_entry_point(): result = subprocess.run("lightning run model --help", capture_output=True, text=True, shell=True) - deprecation_message = ("`lightning run model` is deprecated and will be removed in future versions. " - "Please call `fabric run model` instead") + deprecation_message = ( + "`lightning run model` is deprecated and will be removed in future versions. " + "Please call `fabric run model` instead" + ) message = "Usage: lightning run model [OPTIONS] SCRIPT [SCRIPT_ARGS]" assert deprecation_message in result.stdout assert message in result.stdout or message in result.stderr From b8506f0df2f0485f28f224e84c2a261c432d1882 Mon Sep 17 00:00:00 2001 From: Justus Schock Date: Mon, 12 Feb 2024 11:24:11 +0000 Subject: [PATCH 20/20] update --- tests/tests_fabric/test_cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests_fabric/test_cli.py b/tests/tests_fabric/test_cli.py index e6049ac0d9611..596318b4b619f 100644 --- a/tests/tests_fabric/test_cli.py +++ b/tests/tests_fabric/test_cli.py @@ -187,7 +187,7 @@ def test_cli_through_lightning_entry_point(): deprecation_message = ( "`lightning run model` is deprecated and will be removed in future versions. " - "Please call `fabric run model` instead" + "Please call `fabric run model` instead" ) message = "Usage: lightning run model [OPTIONS] SCRIPT [SCRIPT_ARGS]" assert deprecation_message in result.stdout