From 19f5f922d8e76681aa76142a07fcd1602ec5bd49 Mon Sep 17 00:00:00 2001 From: thomas Date: Wed, 7 Dec 2022 15:30:19 +0000 Subject: [PATCH 01/30] update --- .storage/boring_file.txt | 5 ++++ src/lightning_app/cli/cmd_install.py | 6 ++-- src/lightning_app/cli/lightning_cli.py | 30 +++++++++++++++---- src/lightning_app/perf/pdb.py | 41 +++++++++++++++++++------- 4 files changed, 63 insertions(+), 19 deletions(-) create mode 100644 .storage/boring_file.txt diff --git a/.storage/boring_file.txt b/.storage/boring_file.txt new file mode 100644 index 0000000000000..2a8574fb54178 --- /dev/null +++ b/.storage/boring_file.txt @@ -0,0 +1,5 @@ + +Hello there! +This tab is currently an IFrame of the FastAPI Server running in `DestinationFileAndServeWork`. +Also, the content of this file was created in `SourceFileWork` and then transferred to `DestinationFileAndServeWork`. +Are you already 🤯 ? Stick with us, this is only the beginning. Lightning is 🚀. diff --git a/src/lightning_app/cli/cmd_install.py b/src/lightning_app/cli/cmd_install.py index db0467212f147..ffede1fd04491 100644 --- a/src/lightning_app/cli/cmd_install.py +++ b/src/lightning_app/cli/cmd_install.py @@ -19,7 +19,7 @@ def gallery_component(name: str, yes_arg: bool, version_arg: str, cwd: str = Non org, component = _validate_name(name, resource_type="component", example="lightning/LAI-slack-component") # resolve registry (orgs can have a private registry through their environment variables) - registry_url = _resolve_component_registry() + registry_url = _resolve_app_registry() # load the component resource component_entry = _resolve_resource(registry_url, name=name, version_arg=version_arg, resource_type="component") @@ -40,7 +40,7 @@ def non_gallery_component(gh_url: str, yes_arg: bool, cwd: str = None) -> None: _install_component(git_url) -def gallery_app(name: str, yes_arg: bool, version_arg: str, cwd: str = None, overwrite: bool = False) -> None: +def gallery_app(name: str, yes_arg: bool, version_arg: str, cwd: str = None, overwrite: bool = False) -> str: # make sure org/app-name syntax is correct org, app = _validate_name(name, resource_type="app", example="lightning/quick-start") @@ -59,6 +59,8 @@ def gallery_app(name: str, yes_arg: bool, version_arg: str, cwd: str = None, ove # run installation if requested _install_app(source_url, git_url, folder_name, cwd=cwd, overwrite=overwrite, git_sha=git_sha) + return os.path.join(os.getcwd(), folder_name, app_entry["appEntrypointFile"]) + def non_gallery_app(gh_url: str, yes_arg: bool, cwd: str = None, overwrite: bool = False) -> None: diff --git a/src/lightning_app/cli/lightning_cli.py b/src/lightning_app/cli/lightning_cli.py index 8fcf7a7f10dc1..4d23f189c7120 100644 --- a/src/lightning_app/cli/lightning_cli.py +++ b/src/lightning_app/cli/lightning_cli.py @@ -232,7 +232,10 @@ def _run_app( secret: tuple, run_app_comment_commands: bool, ) -> None: - file = _prepare_file(file) + + if not os.path.exists(file): + file = _install_app(file, True, "latest", overwrite=False) + run_app_comment_commands = True if not cloud and cluster_id is not None: raise click.ClickException("Using the flag --cluster-id in local execution is not supported.") @@ -288,7 +291,7 @@ def run() -> None: @run.command("app") -@click.argument("file", type=click.Path(exists=True)) +@click.argument("file", type=str) @click.option("--cloud", type=bool, default=False, is_flag=True) @click.option( "--cluster-id", @@ -449,6 +452,18 @@ def install() -> None: """Install a Lightning App and/or component.""" +def _install_app(name: str, yes: bool, version: str, overwrite: bool = False) -> None: + if "github.com" in name: + if version != "latest": + logger.warn( + f"The provided version {version} isn't the officially supported one. " + f"The provided version will be ignored." + ) + return cmd_install.non_gallery_app(name, yes, overwrite=overwrite) + else: + return cmd_install.gallery_app(name, yes, version, overwrite=overwrite) + + @install.command("app") @click.argument("name", type=str) @click.option( @@ -473,15 +488,19 @@ def install() -> None: help="When set, overwrite the app directory without asking if it already exists.", ) def install_app(name: str, yes: bool, version: str, overwrite: bool = False) -> None: + _install_app(name, yes, version, overwrite=overwrite) + + +def _install_component(name: str, yes: bool, version: str) -> None: if "github.com" in name: if version != "latest": logger.warn( f"The provided version {version} isn't the officially supported one. " f"The provided version will be ignored." ) - cmd_install.non_gallery_app(name, yes, overwrite=overwrite) + cmd_install.non_gallery_component(name, yes) else: - cmd_install.gallery_app(name, yes, version, overwrite=overwrite) + cmd_install.gallery_component(name, yes, version) @install.command("component") @@ -511,7 +530,6 @@ def install_component(name: str, yes: bool, version: str) -> None: else: cmd_install.gallery_component(name, yes, version) - @_main.group() def init() -> None: """Init a Lightning App and/or component.""" @@ -583,4 +601,4 @@ def _prepare_file(file: str) -> str: if exists: return file - raise FileNotFoundError(f"The provided file {file} hasn't been found.") + raise FileNotFoundError(f"The provided file {file} hasn't been found.") \ No newline at end of file diff --git a/src/lightning_app/perf/pdb.py b/src/lightning_app/perf/pdb.py index 5bd56960715e3..83637fda3a8b0 100644 --- a/src/lightning_app/perf/pdb.py +++ b/src/lightning_app/perf/pdb.py @@ -1,19 +1,38 @@ +import multiprocessing +import os import pdb import sys -from typing import Any +__all__ = ["set_trace"] +_stdin = [None] +_stdin_lock = multiprocessing.Lock() +try: + _stdin_fd = sys.stdin.fileno() +except Exception: + _stdin_fd = None + +# Taken from https://github.com/facebookresearch/metaseq/blob/main/metaseq/pdb.py class MPPdb(pdb.Pdb): - """debugger for forked programs.""" + """A Pdb wrapper that works in a multiprocessing environment. + """ + + def __init__(self): + pdb.Pdb.__init__(self, nosigint=True) - def interaction(self, *args: Any, **kwargs: Any) -> None: - _stdin = sys.stdin - try: - sys.stdin = open("/dev/stdin") - pdb.Pdb.interaction(self, *args, **kwargs) - finally: - sys.stdin = _stdin + def _cmdloop(self): + stdin_bak = sys.stdin + with _stdin_lock: + try: + if _stdin_fd is not None: + if not _stdin[0]: + _stdin[0] = os.fdopen(_stdin_fd) + sys.stdin = _stdin[0] + self.cmdloop() + finally: + sys.stdin = stdin_bak -def set_trace(*args: Any, **kwargs: Any) -> None: - MPPdb().set_trace(*args, **kwargs) +def set_trace(): + pdb = MPPdb() + pdb.set_trace(sys._getframe().f_back) From 907863e88f4f0b5246e9170c5127a66f859e787a Mon Sep 17 00:00:00 2001 From: thomas Date: Wed, 7 Dec 2022 15:30:32 +0000 Subject: [PATCH 02/30] update --- .storage/boring_file.txt | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 .storage/boring_file.txt diff --git a/.storage/boring_file.txt b/.storage/boring_file.txt deleted file mode 100644 index 2a8574fb54178..0000000000000 --- a/.storage/boring_file.txt +++ /dev/null @@ -1,5 +0,0 @@ - -Hello there! -This tab is currently an IFrame of the FastAPI Server running in `DestinationFileAndServeWork`. -Also, the content of this file was created in `SourceFileWork` and then transferred to `DestinationFileAndServeWork`. -Are you already 🤯 ? Stick with us, this is only the beginning. Lightning is 🚀. From ded18754e21203db80cec96f5d1923e386371761 Mon Sep 17 00:00:00 2001 From: thomas Date: Wed, 7 Dec 2022 15:34:51 +0000 Subject: [PATCH 03/30] update --- src/lightning_app/perf/pdb.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/lightning_app/perf/pdb.py b/src/lightning_app/perf/pdb.py index 83637fda3a8b0..fd6aa0eb4c703 100644 --- a/src/lightning_app/perf/pdb.py +++ b/src/lightning_app/perf/pdb.py @@ -14,14 +14,13 @@ # Taken from https://github.com/facebookresearch/metaseq/blob/main/metaseq/pdb.py class MPPdb(pdb.Pdb): - """A Pdb wrapper that works in a multiprocessing environment. - """ + """A Pdb wrapper that works in a multiprocessing environment""" def __init__(self): pdb.Pdb.__init__(self, nosigint=True) def _cmdloop(self): - stdin_bak = sys.stdin + stdin_back = sys.stdin with _stdin_lock: try: if _stdin_fd is not None: @@ -30,7 +29,7 @@ def _cmdloop(self): sys.stdin = _stdin[0] self.cmdloop() finally: - sys.stdin = stdin_bak + sys.stdin = stdin_back def set_trace(): From 779ca614c4e1ad90d96cdc7e04725802d70e53d0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 7 Dec 2022 15:38:13 +0000 Subject: [PATCH 04/30] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/lightning_app/cli/lightning_cli.py | 3 ++- src/lightning_app/perf/pdb.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lightning_app/cli/lightning_cli.py b/src/lightning_app/cli/lightning_cli.py index 4d23f189c7120..cc111581840c5 100644 --- a/src/lightning_app/cli/lightning_cli.py +++ b/src/lightning_app/cli/lightning_cli.py @@ -530,6 +530,7 @@ def install_component(name: str, yes: bool, version: str) -> None: else: cmd_install.gallery_component(name, yes, version) + @_main.group() def init() -> None: """Init a Lightning App and/or component.""" @@ -601,4 +602,4 @@ def _prepare_file(file: str) -> str: if exists: return file - raise FileNotFoundError(f"The provided file {file} hasn't been found.") \ No newline at end of file + raise FileNotFoundError(f"The provided file {file} hasn't been found.") diff --git a/src/lightning_app/perf/pdb.py b/src/lightning_app/perf/pdb.py index fd6aa0eb4c703..2f04c4d2e9ceb 100644 --- a/src/lightning_app/perf/pdb.py +++ b/src/lightning_app/perf/pdb.py @@ -14,7 +14,7 @@ # Taken from https://github.com/facebookresearch/metaseq/blob/main/metaseq/pdb.py class MPPdb(pdb.Pdb): - """A Pdb wrapper that works in a multiprocessing environment""" + """A Pdb wrapper that works in a multiprocessing environment.""" def __init__(self): pdb.Pdb.__init__(self, nosigint=True) From 5ac904fca5933eb9b057e01a3ce52f3f309be25e Mon Sep 17 00:00:00 2001 From: thomas Date: Wed, 7 Dec 2022 17:00:08 +0000 Subject: [PATCH 05/30] update --- src/lightning_app/cli/cmd_install.py | 32 ++++++++++++++++++++++++++ src/lightning_app/cli/lightning_cli.py | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/lightning_app/cli/cmd_install.py b/src/lightning_app/cli/cmd_install.py index ffede1fd04491..80964a97e175c 100644 --- a/src/lightning_app/cli/cmd_install.py +++ b/src/lightning_app/cli/cmd_install.py @@ -14,6 +14,37 @@ logger = Logger(__name__) +def gallery_apps_and_components(name: str, yes_arg: bool, version_arg: str, cwd: str = None, overwrite: bool = False) -> str: + + # make sure org/app-name syntax is correct + org, app_or_component = _validate_name(name, resource_type="App OR Component", example="lightning/quick-start") + + # load the app resource + app_entry = _resolve_resource(_resolve_app_registry(), name=name, version_arg=version_arg, resource_type="app") + + if app_entry: + # give the user the chance to do a manual install + source_url, git_url, folder_name, git_sha = _show_install_app_prompt( + app_entry, app_or_component, org, yes_arg, resource_type="app" + ) + + # run installation if requested + _install_app(source_url, git_url, folder_name, cwd=cwd, overwrite=overwrite, git_sha=git_sha) + + return os.path.join(os.getcwd(), app_entry["appEntrypointFile"]) + else: + # load the component resource + component_entry = _resolve_resource(_resolve_app_registry(), name=name, version_arg=version_arg, resource_type="component") + + # give the user the chance to do a manual install + git_url = _show_install_component_prompt(component_entry, app_or_component, org, yes_arg) + + # run installation if requested + _install_component(git_url) + + return os.path.join(os.getcwd(), component_entry["appEntrypointFile"]) + + def gallery_component(name: str, yes_arg: bool, version_arg: str, cwd: str = None) -> None: # make sure org/component-name name is correct org, component = _validate_name(name, resource_type="component", example="lightning/LAI-slack-component") @@ -313,6 +344,7 @@ def _resolve_resource(registry_url: str, name: str, version_arg: str, resource_t elif resource_type == "component": gallery_entries = data["components"] except requests.ConnectionError: + breakpoint() m = f""" Network connection error, could not load list of available Lightning {resource_type}s. diff --git a/src/lightning_app/cli/lightning_cli.py b/src/lightning_app/cli/lightning_cli.py index 4d23f189c7120..cc8eaa1c21139 100644 --- a/src/lightning_app/cli/lightning_cli.py +++ b/src/lightning_app/cli/lightning_cli.py @@ -234,7 +234,7 @@ def _run_app( ) -> None: if not os.path.exists(file): - file = _install_app(file, True, "latest", overwrite=False) + file = cmd_install.gallery_apps_and_components(name, True, "latest", overwrite=False) run_app_comment_commands = True if not cloud and cluster_id is not None: From 47c71f3c564f19ae28d97613c93700b09f50c03e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 7 Dec 2022 17:04:13 +0000 Subject: [PATCH 06/30] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/lightning_app/cli/cmd_install.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/lightning_app/cli/cmd_install.py b/src/lightning_app/cli/cmd_install.py index 80964a97e175c..f2e2ad6a5f7d5 100644 --- a/src/lightning_app/cli/cmd_install.py +++ b/src/lightning_app/cli/cmd_install.py @@ -14,7 +14,9 @@ logger = Logger(__name__) -def gallery_apps_and_components(name: str, yes_arg: bool, version_arg: str, cwd: str = None, overwrite: bool = False) -> str: +def gallery_apps_and_components( + name: str, yes_arg: bool, version_arg: str, cwd: str = None, overwrite: bool = False +) -> str: # make sure org/app-name syntax is correct org, app_or_component = _validate_name(name, resource_type="App OR Component", example="lightning/quick-start") @@ -34,13 +36,15 @@ def gallery_apps_and_components(name: str, yes_arg: bool, version_arg: str, cwd: return os.path.join(os.getcwd(), app_entry["appEntrypointFile"]) else: # load the component resource - component_entry = _resolve_resource(_resolve_app_registry(), name=name, version_arg=version_arg, resource_type="component") + component_entry = _resolve_resource( + _resolve_app_registry(), name=name, version_arg=version_arg, resource_type="component" + ) # give the user the chance to do a manual install git_url = _show_install_component_prompt(component_entry, app_or_component, org, yes_arg) # run installation if requested - _install_component(git_url) + _install_component(git_url) return os.path.join(os.getcwd(), component_entry["appEntrypointFile"]) From 26e74c8375442a101b504535dd5506a2c40d28ac Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 8 Dec 2022 15:13:29 +0000 Subject: [PATCH 07/30] update --- src/lightning_app/cli/cmd_install.py | 54 ++++++++++++++++++-------- src/lightning_app/cli/lightning_cli.py | 2 +- 2 files changed, 39 insertions(+), 17 deletions(-) diff --git a/src/lightning_app/cli/cmd_install.py b/src/lightning_app/cli/cmd_install.py index f2e2ad6a5f7d5..1df1fecbc3ec9 100644 --- a/src/lightning_app/cli/cmd_install.py +++ b/src/lightning_app/cli/cmd_install.py @@ -21,40 +21,37 @@ def gallery_apps_and_components( # make sure org/app-name syntax is correct org, app_or_component = _validate_name(name, resource_type="App OR Component", example="lightning/quick-start") - # load the app resource - app_entry = _resolve_resource(_resolve_app_registry(), name=name, version_arg=version_arg, resource_type="app") + entry, kind = _resolve_entry(app_or_component, version_arg) - if app_entry: + if kind == "app": # give the user the chance to do a manual install source_url, git_url, folder_name, git_sha = _show_install_app_prompt( - app_entry, app_or_component, org, yes_arg, resource_type="app" + entry, app_or_component, org, yes_arg, resource_type="app" ) - # run installation if requested _install_app(source_url, git_url, folder_name, cwd=cwd, overwrite=overwrite, git_sha=git_sha) - return os.path.join(os.getcwd(), app_entry["appEntrypointFile"]) - else: - # load the component resource - component_entry = _resolve_resource( - _resolve_app_registry(), name=name, version_arg=version_arg, resource_type="component" - ) + return os.path.join(os.getcwd(), folder_name, entry["appEntrypointFile"]) + elif kind == "component": # give the user the chance to do a manual install - git_url = _show_install_component_prompt(component_entry, app_or_component, org, yes_arg) + git_url = _show_install_component_prompt(entry, app_or_component, org, yes_arg) # run installation if requested _install_component(git_url) - return os.path.join(os.getcwd(), component_entry["appEntrypointFile"]) + return os.path.join(os.getcwd(), entry["appEntrypointFile"]) + + else: + raise Exception(f"The provided {name} doesn't exist.") -def gallery_component(name: str, yes_arg: bool, version_arg: str, cwd: str = None) -> None: +def gallery_component(name: str, yes_arg: bool, version_arg: str, cwd: str = None) -> str: # make sure org/component-name name is correct org, component = _validate_name(name, resource_type="component", example="lightning/LAI-slack-component") # resolve registry (orgs can have a private registry through their environment variables) - registry_url = _resolve_app_registry() + registry_url = _resolve_component_registry() # load the component resource component_entry = _resolve_resource(registry_url, name=name, version_arg=version_arg, resource_type="component") @@ -65,6 +62,8 @@ def gallery_component(name: str, yes_arg: bool, version_arg: str, cwd: str = Non # run installation if requested _install_component(git_url) + return os.path.join(os.getcwd(), component_entry["appEntrypointFile"]) + def non_gallery_component(gh_url: str, yes_arg: bool, cwd: str = None) -> None: @@ -336,6 +335,30 @@ def _validate_name(name: str, resource_type: str, example: str) -> Tuple[str, st return org, resource +def _resolve_entry(name, version_arg) -> Tuple[Optional[Dict], Optional[str]]: + entry = None + kind = None + + # resolve registry (orgs can have a private registry through their environment variables) + registry_url = _resolve_app_registry() + + # load the app resource + entry = _resolve_resource(registry_url, name=name, version_arg=version_arg, resource_type="app") + + if not entry: + + registry_url = _resolve_component_registry() + + # load the component resource + entry = _resolve_resource(registry_url, name=name, version_arg=version_arg, resource_type="component") + kind = "component" if entry else None + + else: + kind = "app" + + return entry, kind + + def _resolve_resource(registry_url: str, name: str, version_arg: str, resource_type: str) -> Dict[str, str]: gallery_entries = [] try: @@ -348,7 +371,6 @@ def _resolve_resource(registry_url: str, name: str, version_arg: str, resource_t elif resource_type == "component": gallery_entries = data["components"] except requests.ConnectionError: - breakpoint() m = f""" Network connection error, could not load list of available Lightning {resource_type}s. diff --git a/src/lightning_app/cli/lightning_cli.py b/src/lightning_app/cli/lightning_cli.py index 0910c3bd04c69..d205fda90d666 100644 --- a/src/lightning_app/cli/lightning_cli.py +++ b/src/lightning_app/cli/lightning_cli.py @@ -234,7 +234,7 @@ def _run_app( ) -> None: if not os.path.exists(file): - file = cmd_install.gallery_apps_and_components(name, True, "latest", overwrite=False) + file = cmd_install.gallery_apps_and_components(file, True, "latest", overwrite=False) run_app_comment_commands = True if not cloud and cluster_id is not None: From 2144412766fd0b0a81ceafd8a283387a738d70fb Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 8 Dec 2022 15:30:25 +0000 Subject: [PATCH 08/30] updarte --- src/lightning_app/cli/cmd_install.py | 94 +++++++++++++++++++++++--- src/lightning_app/cli/lightning_cli.py | 85 +---------------------- 2 files changed, 87 insertions(+), 92 deletions(-) diff --git a/src/lightning_app/cli/cmd_install.py b/src/lightning_app/cli/cmd_install.py index 1df1fecbc3ec9..eca1e929708f7 100644 --- a/src/lightning_app/cli/cmd_install.py +++ b/src/lightning_app/cli/cmd_install.py @@ -5,6 +5,7 @@ import sys from typing import Dict, Optional, Tuple +import click import requests from packaging.version import Version @@ -14,6 +15,83 @@ logger = Logger(__name__) +@click.group(name="install") +def install() -> None: + """Install Lightning AI selfresources.""" + pass + + +@install.command("app") +@click.argument("name", type=str) +@click.option( + "--yes", + "-y", + is_flag=True, + help="disables prompt to ask permission to create env and run install cmds", +) +@click.option( + "--version", + "-v", + type=str, + help="Specify the version to install. By default it uses 'latest'", + default="latest", + show_default=True, +) +@click.option( + "--overwrite", + "-f", + is_flag=True, + default=False, + help="When set, overwrite the app directory without asking if it already exists.", +) +def install_app(name: str, yes: bool, version: str, overwrite: bool = False) -> None: + _install_app_command(name, yes, version, overwrite=overwrite) + + +@install.command("component") +@click.argument("name", type=str) +@click.option( + "--yes", + "-y", + is_flag=True, + help="disables prompt to ask permission to create env and run install cmds", +) +@click.option( + "--version", + "-v", + type=str, + help="Specify the version to install. By default it uses 'latest'", + default="latest", + show_default=True, +) +def install_component(name: str, yes: bool, version: str) -> None: + _install_component_command(name, yes, version) + + +def _install_app_command(name: str, yes: bool, version: str, overwrite: bool = False) -> None: + if "github.com" in name: + if version != "latest": + logger.warn( + f"The provided version {version} isn't the officially supported one. " + f"The provided version will be ignored." + ) + return non_gallery_app(name, yes, overwrite=overwrite) + else: + return gallery_app(name, yes, version, overwrite=overwrite) + + +def _install_component_command(name: str, yes: bool, version: str, overwrite: bool = False) -> None: + if "github.com" in name: + if version != "latest": + logger.warn( + f"The provided version {version} isn't the officially supported one. " + f"The provided version will be ignored." + ) + return non_gallery_component(name, yes, overwrite=overwrite) + else: + return gallery_component(name, yes, version, overwrite=overwrite) + + def gallery_apps_and_components( name: str, yes_arg: bool, version_arg: str, cwd: str = None, overwrite: bool = False ) -> str: @@ -29,7 +107,7 @@ def gallery_apps_and_components( entry, app_or_component, org, yes_arg, resource_type="app" ) # run installation if requested - _install_app(source_url, git_url, folder_name, cwd=cwd, overwrite=overwrite, git_sha=git_sha) + _install_app_from_source(source_url, git_url, folder_name, cwd=cwd, overwrite=overwrite, git_sha=git_sha) return os.path.join(os.getcwd(), folder_name, entry["appEntrypointFile"]) @@ -38,7 +116,7 @@ def gallery_apps_and_components( git_url = _show_install_component_prompt(entry, app_or_component, org, yes_arg) # run installation if requested - _install_component(git_url) + _install_component_from_source(git_url) return os.path.join(os.getcwd(), entry["appEntrypointFile"]) @@ -60,7 +138,7 @@ def gallery_component(name: str, yes_arg: bool, version_arg: str, cwd: str = Non git_url = _show_install_component_prompt(component_entry, component, org, yes_arg) # run installation if requested - _install_component(git_url) + _install_component_from_source(git_url) return os.path.join(os.getcwd(), component_entry["appEntrypointFile"]) @@ -71,7 +149,7 @@ def non_gallery_component(gh_url: str, yes_arg: bool, cwd: str = None) -> None: git_url = _show_non_gallery_install_component_prompt(gh_url, yes_arg) # run installation if requested - _install_component(git_url) + _install_component_from_source(git_url) def gallery_app(name: str, yes_arg: bool, version_arg: str, cwd: str = None, overwrite: bool = False) -> str: @@ -91,7 +169,7 @@ def gallery_app(name: str, yes_arg: bool, version_arg: str, cwd: str = None, ove ) # run installation if requested - _install_app(source_url, git_url, folder_name, cwd=cwd, overwrite=overwrite, git_sha=git_sha) + _install_app_from_source(source_url, git_url, folder_name, cwd=cwd, overwrite=overwrite, git_sha=git_sha) return os.path.join(os.getcwd(), folder_name, app_entry["appEntrypointFile"]) @@ -102,7 +180,7 @@ def non_gallery_app(gh_url: str, yes_arg: bool, cwd: str = None, overwrite: bool repo_url, folder_name = _show_non_gallery_install_app_prompt(gh_url, yes_arg) # run installation if requested - _install_app(repo_url, repo_url, folder_name, cwd=cwd, overwrite=overwrite) + _install_app_from_source(repo_url, repo_url, folder_name, cwd=cwd, overwrite=overwrite) def _show_install_component_prompt(entry: Dict[str, str], component: str, org: str, yes_arg: bool) -> str: @@ -441,7 +519,7 @@ def _install_with_env(repo_url: str, folder_name: str, cwd: str = None) -> None: logger.info(m) -def _install_app( +def _install_app_from_source( source_url: str, git_url: str, folder_name: str, cwd: str = None, overwrite: bool = False, git_sha: str = None ) -> None: """Installing lighting app from the `git_url` @@ -518,7 +596,7 @@ def _install_app( logger.info(m) -def _install_component(git_url: str) -> None: +def _install_component_from_source(git_url: str) -> None: logger.info("⚡ RUN: pip install") out = subprocess.check_output(["pip", "install", git_url]) diff --git a/src/lightning_app/cli/lightning_cli.py b/src/lightning_app/cli/lightning_cli.py index d205fda90d666..46cd61b099278 100644 --- a/src/lightning_app/cli/lightning_cli.py +++ b/src/lightning_app/cli/lightning_cli.py @@ -364,6 +364,7 @@ def run_app( _main.add_command(get_list) _main.add_command(delete) _main.add_command(create) +_main.add_command(cmd_install.install) @_main.command("ssh") @@ -447,90 +448,6 @@ def ssh(app_name: str = None, component_name: str = None) -> None: os.execv(ssh_path, ["-tt", f"{component_id}@{ssh_endpoint}"]) -@_main.group() -def install() -> None: - """Install a Lightning App and/or component.""" - - -def _install_app(name: str, yes: bool, version: str, overwrite: bool = False) -> None: - if "github.com" in name: - if version != "latest": - logger.warn( - f"The provided version {version} isn't the officially supported one. " - f"The provided version will be ignored." - ) - return cmd_install.non_gallery_app(name, yes, overwrite=overwrite) - else: - return cmd_install.gallery_app(name, yes, version, overwrite=overwrite) - - -@install.command("app") -@click.argument("name", type=str) -@click.option( - "--yes", - "-y", - is_flag=True, - help="disables prompt to ask permission to create env and run install cmds", -) -@click.option( - "--version", - "-v", - type=str, - help="Specify the version to install. By default it uses 'latest'", - default="latest", - show_default=True, -) -@click.option( - "--overwrite", - "-f", - is_flag=True, - default=False, - help="When set, overwrite the app directory without asking if it already exists.", -) -def install_app(name: str, yes: bool, version: str, overwrite: bool = False) -> None: - _install_app(name, yes, version, overwrite=overwrite) - - -def _install_component(name: str, yes: bool, version: str) -> None: - if "github.com" in name: - if version != "latest": - logger.warn( - f"The provided version {version} isn't the officially supported one. " - f"The provided version will be ignored." - ) - cmd_install.non_gallery_component(name, yes) - else: - cmd_install.gallery_component(name, yes, version) - - -@install.command("component") -@click.argument("name", type=str) -@click.option( - "--yes", - "-y", - is_flag=True, - help="disables prompt to ask permission to create env and run install cmds", -) -@click.option( - "--version", - "-v", - type=str, - help="Specify the version to install. By default it uses 'latest'", - default="latest", - show_default=True, -) -def install_component(name: str, yes: bool, version: str) -> None: - if "github.com" in name: - if version != "latest": - logger.warn( - f"The provided version {version} isn't the officially supported one. " - f"The provided version will be ignored." - ) - cmd_install.non_gallery_component(name, yes) - else: - cmd_install.gallery_component(name, yes, version) - - @_main.group() def init() -> None: """Init a Lightning App and/or component.""" From d7bac7db18a89383a0871c9dda5c8b6616e3e609 Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 8 Dec 2022 15:31:36 +0000 Subject: [PATCH 09/30] update --- src/lightning_app/perf/pdb.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/lightning_app/perf/pdb.py b/src/lightning_app/perf/pdb.py index 18469aea00a76..f4b42f96e842d 100644 --- a/src/lightning_app/perf/pdb.py +++ b/src/lightning_app/perf/pdb.py @@ -10,8 +10,6 @@ except Exception: _stdin_fd = None -__all__ = ["set_trace"] - # Taken from https://github.com/facebookresearch/metaseq/blob/main/metaseq/pdb.py class MPPdb(pdb.Pdb): From 4bfc36cb09c714b3c7a49e53879781161d44d8ff Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 8 Dec 2022 15:33:53 +0000 Subject: [PATCH 10/30] update --- src/lightning_app/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lightning_app/CHANGELOG.md b/src/lightning_app/CHANGELOG.md index 658e047f5f2a0..1be5b9c16fc23 100644 --- a/src/lightning_app/CHANGELOG.md +++ b/src/lightning_app/CHANGELOG.md @@ -28,6 +28,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Added a `configure_layout` method to the `LightningWork` which can be used to control how the work is handled in the layout of a parent flow ([#15926](https://github.com/Lightning-AI/lightning/pull/15926)) +- Added the ability to run a Lightning App or Component directly from the Gallery using `lightning run app organization/name` ([#15941](https://github.com/Lightning-AI/lightning/pull/15941)) + ### Changed From 6416c05e5287e0d37fb21b184e1f4f956e77ec90 Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 8 Dec 2022 15:35:30 +0000 Subject: [PATCH 11/30] update --- src/lightning_app/cli/lightning_cli.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lightning_app/cli/lightning_cli.py b/src/lightning_app/cli/lightning_cli.py index 46cd61b099278..0d8bd8bcbc9ac 100644 --- a/src/lightning_app/cli/lightning_cli.py +++ b/src/lightning_app/cli/lightning_cli.py @@ -235,6 +235,8 @@ def _run_app( if not os.path.exists(file): file = cmd_install.gallery_apps_and_components(file, True, "latest", overwrite=False) + if file is None: + raise Exception(f"The provided entrypoint {file} doesn't exist.") run_app_comment_commands = True if not cloud and cluster_id is not None: From 536f581f9eb4bff90aee27d32f5ceb24e46b8245 Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 8 Dec 2022 15:46:03 +0000 Subject: [PATCH 12/30] update --- tests/tests_app/cli/test_cmd_install.py | 54 ++++++++++++++----------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/tests/tests_app/cli/test_cmd_install.py b/tests/tests_app/cli/test_cmd_install.py index aa0c34ba6ed2d..2e2086348cb58 100644 --- a/tests/tests_app/cli/test_cmd_install.py +++ b/tests/tests_app/cli/test_cmd_install.py @@ -17,19 +17,19 @@ def test_valid_org_app_name(): # assert a bad app name should fail fake_app = "fakeuser/impossible/name" - result = runner.invoke(lightning_cli.install_app, [fake_app]) + result = runner.invoke(lightning_cli.cmd_install.install_app, [fake_app]) assert "app name format must have organization/app-name" in result.output # assert a good name (but unavailable name) should work fake_app = "fakeuser/ALKKLJAUHREKJ21234KLAKJDLF" - result = runner.invoke(lightning_cli.install_app, [fake_app]) + result = runner.invoke(lightning_cli.cmd_install.install_app, [fake_app]) assert f"app: '{fake_app}' is not available on ⚡ Lightning AI ⚡" in result.output assert result.exit_code # assert a good (and availablea name) works # This should be an app that's always in the gallery real_app = "lightning/invideo" - result = runner.invoke(lightning_cli.install_app, [real_app]) + result = runner.invoke(lightning_cli.cmd_install.install_app, [real_app]) assert "Press enter to continue:" in result.output @@ -47,16 +47,16 @@ def test_valid_unpublished_app_name(): assert "WARNING" in str(e.output) # assert aborted install - result = runner.invoke(lightning_cli.install_app, [real_app], input="q") + result = runner.invoke(lightning_cli.cmd_install.install_app, [real_app], input="q") assert "Installation aborted!" in result.output # assert a bad app name should fail fake_app = "https://github.com/Lightning-AI/install-appdd" - result = runner.invoke(lightning_cli.install_app, [fake_app, "--yes"]) + result = runner.invoke(lightning_cli.cmd_install.install_app, [fake_app, "--yes"]) assert "Looks like the github url was not found" in result.output # assert a good (and availablea name) works - result = runner.invoke(lightning_cli.install_app, [real_app]) + result = runner.invoke(lightning_cli.cmd_install.install_app, [real_app]) assert "Press enter to continue:" in result.output @@ -81,17 +81,17 @@ def test_valid_org_component_name(): # assert a bad name should fail fake_component = "fakeuser/impossible/name" - result = runner.invoke(lightning_cli.install_component, [fake_component]) + result = runner.invoke(lightning_cli.cmd_install.install_component, [fake_component]) assert "component name format must have organization/component-name" in result.output # assert a good name (but unavailable name) should work fake_component = "fakeuser/ALKKLJAUHREKJ21234KLAKJDLF" - result = runner.invoke(lightning_cli.install_component, [fake_component]) + result = runner.invoke(lightning_cli.cmd_install.install_component, [fake_component]) assert f"component: '{fake_component}' is not available on ⚡ Lightning AI ⚡" in result.output # assert a good (and availablea name) works fake_component = "lightning/lit-slack-messenger" - result = runner.invoke(lightning_cli.install_component, [fake_component]) + result = runner.invoke(lightning_cli.cmd_install.install_component, [fake_component]) assert "Press enter to continue:" in result.output @@ -100,13 +100,13 @@ def test_unpublished_component_url_parsing(): # assert a bad name should fail (no git@) fake_component = "https://github.com/Lightning-AI/LAI-slack-messenger" - result = runner.invoke(lightning_cli.install_component, [fake_component]) + result = runner.invoke(lightning_cli.cmd_install.install_component, [fake_component]) assert "Error, your github url must be in the following format" in result.output # assert a good (and availablea name) works sha = "14f333456ffb6758bd19458e6fa0bf12cf5575e1" real_component = f"git+https://github.com/Lightning-AI/LAI-slack-messenger.git@{sha}" - result = runner.invoke(lightning_cli.install_component, [real_component]) + result = runner.invoke(lightning_cli.cmd_install.install_component, [real_component]) assert "Press enter to continue:" in result.output @@ -148,26 +148,26 @@ def test_prompt_actions(): runner = CliRunner() # assert that the user can cancel the command with any letter other than y - result = runner.invoke(lightning_cli.install_app, [app_to_use], input="b") + result = runner.invoke(lightning_cli.cmd_install.install_app, [app_to_use], input="b") assert "Installation aborted!" in result.output # assert that the install happens with --yes - # result = runner.invoke(lightning_cli.install_app, [app_to_use, "--yes"]) + # result = runner.invoke(lightning_cli.cmd_install.install_app, [app_to_use, "--yes"]) # assert result.exit_code == 0 # assert that the install happens with y - # result = runner.invoke(lightning_cli.install_app, [app_to_use], input='y') + # result = runner.invoke(lightning_cli.cmd_install.install_app, [app_to_use], input='y') # assert result.exit_code == 0 # # assert that the install happens with yes - # result = runner.invoke(lightning_cli.install_app, [app_to_use], input='yes') + # result = runner.invoke(lightning_cli.cmd_install.install_app, [app_to_use], input='yes') # assert result.exit_code == 0 # assert that the install happens with pressing enter - # result = runner.invoke(lightning_cli.install_app, [app_to_use]) + # result = runner.invoke(lightning_cli.cmd_install.install_app, [app_to_use]) # TODO: how to check the output when the user types ctrl+c? - # result = runner.invoke(lightning_cli.install_app, [app_to_use], input='') + # result = runner.invoke(lightning_cli.cmd_install.install_app, [app_to_use], input='') @mock.patch("lightning_app.cli.cmd_install.subprocess", mock.MagicMock()) @@ -178,7 +178,7 @@ def test_version_arg_component(tmpdir, monkeypatch): # Version does not exist component_name = "lightning/lit-slack-messenger" version_arg = "NOT-EXIST" - result = runner.invoke(lightning_cli.install_component, [component_name, f"--version={version_arg}"]) + result = runner.invoke(lightning_cli.cmd_install.install_component, [component_name, f"--version={version_arg}"]) assert f"component: 'Version {version_arg} for {component_name}' is not" in str(result.exception) assert result.exit_code == 1 @@ -186,7 +186,9 @@ def test_version_arg_component(tmpdir, monkeypatch): # This somwehow fail in test but not when you actually run it version_arg = "0.0.1" runner = CliRunner() - result = runner.invoke(lightning_cli.install_component, [component_name, f"--version={version_arg}", "--yes"]) + result = runner.invoke( + lightning_cli.cmd_install.install_component, [component_name, f"--version={version_arg}", "--yes"] + ) assert result.exit_code == 0 @@ -198,14 +200,14 @@ def test_version_arg_app(tmpdir): app_name = "lightning/invideo" version_arg = "NOT-EXIST" runner = CliRunner() - result = runner.invoke(lightning_cli.install_app, [app_name, f"--version={version_arg}"]) + result = runner.invoke(lightning_cli.cmd_install.install_app, [app_name, f"--version={version_arg}"]) assert f"app: 'Version {version_arg} for {app_name}' is not" in str(result.exception) assert result.exit_code == 1 # Version exists version_arg = "0.0.2" runner = CliRunner() - result = runner.invoke(lightning_cli.install_app, [app_name, f"--version={version_arg}", "--yes"]) + result = runner.invoke(lightning_cli.cmd_install.install_app, [app_name, f"--version={version_arg}", "--yes"]) assert result.exit_code == 0 @@ -236,7 +238,9 @@ def test_install_resolve_latest_version(mock_show_install_app_prompt, tmpdir): }, ] } - runner.invoke(lightning_cli.install_app, [app_name, "--yes"]) # no version specified so latest is installed + runner.invoke( + lightning_cli.cmd_install.install_app, [app_name, "--yes"] + ) # no version specified so latest is installed assert mock_show_install_app_prompt.called assert mock_show_install_app_prompt.call_args[0][0]["version"] == "0.0.4" @@ -274,7 +278,7 @@ def test_install_app_shows_error(tmpdir): app_folder_dir.mkdir() with pytest.raises(SystemExit, match=f"Folder {str(app_folder_dir)} exists, please delete it and try again."): - cmd_install._install_app( + cmd_install._install_app_from_source( source_url=mock.ANY, git_url=mock.ANY, folder_name=str(app_folder_dir), overwrite=False ) @@ -360,7 +364,9 @@ def test_install_app_process(subprocess_mock, source_url, git_url, git_sha, tmpd app_folder_dir = Path(tmpdir / "some_random_directory").absolute() app_folder_dir.mkdir() - cmd_install._install_app(source_url, git_url, folder_name=str(app_folder_dir), overwrite=True, git_sha=git_sha) + cmd_install._install_app_from_source( + source_url, git_url, folder_name=str(app_folder_dir), overwrite=True, git_sha=git_sha + ) assert subprocess_mock.check_output.call_args_list[0].args == (["git", "clone", git_url],) if git_sha: assert subprocess_mock.check_output.call_args_list[1].args == (["git", "checkout", git_sha],) From ace5aa10bf4a4e0d2b727aee64f6af6d057245da Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 8 Dec 2022 15:48:34 +0000 Subject: [PATCH 13/30] update --- src/lightning_app/cli/cmd_install.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lightning_app/cli/cmd_install.py b/src/lightning_app/cli/cmd_install.py index eca1e929708f7..2055ef5f9e527 100644 --- a/src/lightning_app/cli/cmd_install.py +++ b/src/lightning_app/cli/cmd_install.py @@ -94,10 +94,12 @@ def _install_component_command(name: str, yes: bool, version: str, overwrite: bo def gallery_apps_and_components( name: str, yes_arg: bool, version_arg: str, cwd: str = None, overwrite: bool = False -) -> str: +) -> Optional[str]: - # make sure org/app-name syntax is correct - org, app_or_component = _validate_name(name, resource_type="App OR Component", example="lightning/quick-start") + try: + org, app_or_component = name.split("/") + except Exception: + return None entry, kind = _resolve_entry(app_or_component, version_arg) From 30fc0b9e9a7e58f4dbeac42caf65b5053a4cce1e Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 8 Dec 2022 16:04:33 +0000 Subject: [PATCH 14/30] update --- pyproject.toml | 1 + src/lightning_app/cli/cmd_install.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 633e78e9df16b..a7520334328d9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,6 +35,7 @@ exclude = [ "src/lightning_app/cli/pl-app-template", "src/lightning_app/cli/react-ui-template", "src/lightning_app/cli/app-template", + "src/lightning_app/cli/cmd_install", "src/lightning_app/components/database", "src/lightning_app/components/multi_node", "src/lightning_app/frontend/just_py/just_py", diff --git a/src/lightning_app/cli/cmd_install.py b/src/lightning_app/cli/cmd_install.py index 2055ef5f9e527..5378436e96c71 100644 --- a/src/lightning_app/cli/cmd_install.py +++ b/src/lightning_app/cli/cmd_install.py @@ -87,9 +87,9 @@ def _install_component_command(name: str, yes: bool, version: str, overwrite: bo f"The provided version {version} isn't the officially supported one. " f"The provided version will be ignored." ) - return non_gallery_component(name, yes, overwrite=overwrite) + return non_gallery_component(name, yes) else: - return gallery_component(name, yes, version, overwrite=overwrite) + return gallery_component(name, yes, version) def gallery_apps_and_components( From 0866b8655b39e801b84382cb200bfc01a8390574 Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 8 Dec 2022 16:07:08 +0000 Subject: [PATCH 15/30] update --- src/lightning_app/cli/cmd_install.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lightning_app/cli/cmd_install.py b/src/lightning_app/cli/cmd_install.py index 5378436e96c71..30c9827ed4167 100644 --- a/src/lightning_app/cli/cmd_install.py +++ b/src/lightning_app/cli/cmd_install.py @@ -122,8 +122,7 @@ def gallery_apps_and_components( return os.path.join(os.getcwd(), entry["appEntrypointFile"]) - else: - raise Exception(f"The provided {name} doesn't exist.") + return None def gallery_component(name: str, yes_arg: bool, version_arg: str, cwd: str = None) -> str: From 981c1a02aea345cf31c73c4cef4384e7cc325c4c Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 8 Dec 2022 16:18:52 +0000 Subject: [PATCH 16/30] update --- src/lightning_app/cli/cmd_install.py | 28 +++++++++++++++++--------- src/lightning_app/cli/lightning_cli.py | 4 +++- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/lightning_app/cli/cmd_install.py b/src/lightning_app/cli/cmd_install.py index 30c9827ed4167..8693849d54d3c 100644 --- a/src/lightning_app/cli/cmd_install.py +++ b/src/lightning_app/cli/cmd_install.py @@ -422,14 +422,16 @@ def _resolve_entry(name, version_arg) -> Tuple[Optional[Dict], Optional[str]]: registry_url = _resolve_app_registry() # load the app resource - entry = _resolve_resource(registry_url, name=name, version_arg=version_arg, resource_type="app") + entry = _resolve_resource(registry_url, name=name, version_arg=version_arg, resource_type="app", raise_error=False) if not entry: registry_url = _resolve_component_registry() # load the component resource - entry = _resolve_resource(registry_url, name=name, version_arg=version_arg, resource_type="component") + entry = _resolve_resource( + registry_url, name=name, version_arg=version_arg, resource_type="component", raise_error=False + ) kind = "component" if entry else None else: @@ -438,7 +440,9 @@ def _resolve_entry(name, version_arg) -> Tuple[Optional[Dict], Optional[str]]: return entry, kind -def _resolve_resource(registry_url: str, name: str, version_arg: str, resource_type: str) -> Dict[str, str]: +def _resolve_resource( + registry_url: str, name: str, version_arg: str, resource_type: str, raise_error: bool = True +) -> Dict[str, str]: gallery_entries = [] try: response = requests.get(registry_url) @@ -466,7 +470,10 @@ def _resolve_resource(registry_url: str, name: str, version_arg: str, resource_t all_versions.append(x["version"]) if len(entries) == 0: - raise SystemExit(f"{resource_type}: '{name}' is not available on ⚡ Lightning AI ⚡") + if raise_error: + raise SystemExit(f"{resource_type}: '{name}' is not available on ⚡ Lightning AI ⚡") + else: + return None entry = None if version_arg == "latest": @@ -476,11 +483,14 @@ def _resolve_resource(registry_url: str, name: str, version_arg: str, resource_t if e["version"] == version_arg: entry = e break - if entry is None: - raise Exception( - f"{resource_type}: 'Version {version_arg} for {name}' is not available on ⚡ Lightning AI ⚡. " - f"Here is the list of all availables versions:{os.linesep}{os.linesep.join(all_versions)}" - ) + if entry is None and raise_error: + if raise_error: + raise Exception( + f"{resource_type}: 'Version {version_arg} for {name}' is not available on ⚡ Lightning AI ⚡. " + f"Here is the list of all availables versions:{os.linesep}{os.linesep.join(all_versions)}" + ) + else: + return None return entry diff --git a/src/lightning_app/cli/lightning_cli.py b/src/lightning_app/cli/lightning_cli.py index 0d8bd8bcbc9ac..1b16b583a16ce 100644 --- a/src/lightning_app/cli/lightning_cli.py +++ b/src/lightning_app/cli/lightning_cli.py @@ -234,9 +234,11 @@ def _run_app( ) -> None: if not os.path.exists(file): + original_file = file file = cmd_install.gallery_apps_and_components(file, True, "latest", overwrite=False) if file is None: - raise Exception(f"The provided entrypoint {file} doesn't exist.") + click.echo(f"The provided entrypoint `{original_file}` doesn't exist.") + sys.exit(1) run_app_comment_commands = True if not cloud and cluster_id is not None: From d3adc85bda89af059983e400a897bfaa7a271b8e Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 8 Dec 2022 16:26:02 +0000 Subject: [PATCH 17/30] update --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index a7520334328d9..e4f6f145a099a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,6 +35,7 @@ exclude = [ "src/lightning_app/cli/pl-app-template", "src/lightning_app/cli/react-ui-template", "src/lightning_app/cli/app-template", + "src/lightning_app/cli/lightning_cli", "src/lightning_app/cli/cmd_install", "src/lightning_app/components/database", "src/lightning_app/components/multi_node", From 617468e6a65e9a64d06a343f1b2c2a57f9e45acf Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 8 Dec 2022 16:27:17 +0000 Subject: [PATCH 18/30] update --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index e4f6f145a099a..53af41aad61f1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -70,6 +70,8 @@ module = [ "lightning_app.cli.commands.app_commands", "lightning_app.cli.commands.connection", "lightning_app.cli.react-ui-template.example_app", + "lightning_app.cli.commands.lightning_cli", + "lightning_app.cli.commands.cmd_install", "lightning_app.components.database.client", "lightning_app.components.database.server", "lightning_app.components.database.utilities", From 67ad41f38ed90a4badbdde0582478404341bdfcc Mon Sep 17 00:00:00 2001 From: thomas chaton Date: Thu, 8 Dec 2022 16:31:54 +0000 Subject: [PATCH 19/30] Update src/lightning_app/cli/cmd_install.py Co-authored-by: Ethan Harris --- src/lightning_app/cli/cmd_install.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lightning_app/cli/cmd_install.py b/src/lightning_app/cli/cmd_install.py index 8693849d54d3c..bad81af027161 100644 --- a/src/lightning_app/cli/cmd_install.py +++ b/src/lightning_app/cli/cmd_install.py @@ -72,8 +72,8 @@ def _install_app_command(name: str, yes: bool, version: str, overwrite: bool = F if "github.com" in name: if version != "latest": logger.warn( - f"The provided version {version} isn't the officially supported one. " - f"The provided version will be ignored." + "When installing from GitHub, only the 'latest' version is supported. " + f"The provided version ({version}) will be ignored." ) return non_gallery_app(name, yes, overwrite=overwrite) else: From 100e4c1789dcc1f1b81f1fc2636e0f3fa5f5cf05 Mon Sep 17 00:00:00 2001 From: thomas chaton Date: Thu, 8 Dec 2022 16:32:02 +0000 Subject: [PATCH 20/30] Update src/lightning_app/cli/cmd_install.py Co-authored-by: Ethan Harris --- src/lightning_app/cli/cmd_install.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lightning_app/cli/cmd_install.py b/src/lightning_app/cli/cmd_install.py index bad81af027161..cfa7c0a498210 100644 --- a/src/lightning_app/cli/cmd_install.py +++ b/src/lightning_app/cli/cmd_install.py @@ -84,8 +84,8 @@ def _install_component_command(name: str, yes: bool, version: str, overwrite: bo if "github.com" in name: if version != "latest": logger.warn( - f"The provided version {version} isn't the officially supported one. " - f"The provided version will be ignored." + "When installing from GitHub, only the 'latest' version is supported. " + f"The provided version ({version}) will be ignored." ) return non_gallery_component(name, yes) else: From aada8fb1335b940f4f699221c2f195c3f9ff99d0 Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 8 Dec 2022 16:40:58 +0000 Subject: [PATCH 21/30] update --- pyproject.toml | 2 +- src/lightning_app/cli/cmd_install.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 53af41aad61f1..c363ef9e27878 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -69,9 +69,9 @@ module = [ "lightning_app.api.request_types", "lightning_app.cli.commands.app_commands", "lightning_app.cli.commands.connection", - "lightning_app.cli.react-ui-template.example_app", "lightning_app.cli.commands.lightning_cli", "lightning_app.cli.commands.cmd_install", + "lightning_app.cli.react-ui-template.example_app", "lightning_app.components.database.client", "lightning_app.components.database.server", "lightning_app.components.database.utilities", diff --git a/src/lightning_app/cli/cmd_install.py b/src/lightning_app/cli/cmd_install.py index 8693849d54d3c..3bee6acd5ce95 100644 --- a/src/lightning_app/cli/cmd_install.py +++ b/src/lightning_app/cli/cmd_install.py @@ -141,7 +141,7 @@ def gallery_component(name: str, yes_arg: bool, version_arg: str, cwd: str = Non # run installation if requested _install_component_from_source(git_url) - return os.path.join(os.getcwd(), component_entry["appEntrypointFile"]) + return os.path.join(os.getcwd(), component_entry["entrypointFile"]) def non_gallery_component(gh_url: str, yes_arg: bool, cwd: str = None) -> None: From d88cb819b3c50c6ffa3e5f42aeb97654f4f451c5 Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 8 Dec 2022 16:52:16 +0000 Subject: [PATCH 22/30] update --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index c363ef9e27878..a110d3e8aa7fb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,6 +71,7 @@ module = [ "lightning_app.cli.commands.connection", "lightning_app.cli.commands.lightning_cli", "lightning_app.cli.commands.cmd_install", + "lightning_app.cli", "lightning_app.cli.react-ui-template.example_app", "lightning_app.components.database.client", "lightning_app.components.database.server", From 62bd1ca728c1cdccf5dcd5b9aef50bc398f030a6 Mon Sep 17 00:00:00 2001 From: Jirka Date: Thu, 8 Dec 2022 18:00:44 +0100 Subject: [PATCH 23/30] mypy --- pyproject.toml | 12 +----------- src/lightning_app/cli/lightning_cli.py | 2 +- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c363ef9e27878..505c9efa08d8a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,17 +30,6 @@ files = [ "src/lightning_lite", "src/lightning_app", ] -exclude = [ - "src/lightning_app/cli/component-template", - "src/lightning_app/cli/pl-app-template", - "src/lightning_app/cli/react-ui-template", - "src/lightning_app/cli/app-template", - "src/lightning_app/cli/lightning_cli", - "src/lightning_app/cli/cmd_install", - "src/lightning_app/components/database", - "src/lightning_app/components/multi_node", - "src/lightning_app/frontend/just_py/just_py", -] install_types = "True" non_interactive = "True" disallow_untyped_defs = "True" @@ -72,6 +61,7 @@ module = [ "lightning_app.cli.commands.lightning_cli", "lightning_app.cli.commands.cmd_install", "lightning_app.cli.react-ui-template.example_app", + "lightning_app.cli.cmd_install", "lightning_app.components.database.client", "lightning_app.components.database.server", "lightning_app.components.database.utilities", diff --git a/src/lightning_app/cli/lightning_cli.py b/src/lightning_app/cli/lightning_cli.py index 1b16b583a16ce..f06388880dfad 100644 --- a/src/lightning_app/cli/lightning_cli.py +++ b/src/lightning_app/cli/lightning_cli.py @@ -235,7 +235,7 @@ def _run_app( if not os.path.exists(file): original_file = file - file = cmd_install.gallery_apps_and_components(file, True, "latest", overwrite=False) + file = cmd_install.gallery_apps_and_components(file, True, "latest", overwrite=False) # type: ignore[assignment] if file is None: click.echo(f"The provided entrypoint `{original_file}` doesn't exist.") sys.exit(1) From d01deed997fe88b20f8b5cf36e5e07990951325c Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 8 Dec 2022 17:01:26 +0000 Subject: [PATCH 24/30] update --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index a110d3e8aa7fb..bf88a674c60bf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,6 +37,7 @@ exclude = [ "src/lightning_app/cli/app-template", "src/lightning_app/cli/lightning_cli", "src/lightning_app/cli/cmd_install", + "src/lightning_app/cli/", "src/lightning_app/components/database", "src/lightning_app/components/multi_node", "src/lightning_app/frontend/just_py/just_py", From c3a0ec8baa66acf99ff7d0d932b84f508ca4b1c4 Mon Sep 17 00:00:00 2001 From: Jirka Date: Thu, 8 Dec 2022 18:10:22 +0100 Subject: [PATCH 25/30] ex --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 505c9efa08d8a..1af078a6c8fb2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,6 +30,9 @@ files = [ "src/lightning_lite", "src/lightning_app", ] +exclude = [ + "src/lightning_app/cli/component-template", +] install_types = "True" non_interactive = "True" disallow_untyped_defs = "True" From b2f5be4210fae643f39dcd948d73c07390fe7193 Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 8 Dec 2022 17:11:03 +0000 Subject: [PATCH 26/30] update --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index bf88a674c60bf..db00e2d66f424 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,6 +37,7 @@ exclude = [ "src/lightning_app/cli/app-template", "src/lightning_app/cli/lightning_cli", "src/lightning_app/cli/cmd_install", + "src/lightning_app/cli/component-template/placeholdername", "src/lightning_app/cli/", "src/lightning_app/components/database", "src/lightning_app/components/multi_node", From ec6e66b2ee5a9216d9480098243b03c0bff0c3db Mon Sep 17 00:00:00 2001 From: Jirka Date: Thu, 8 Dec 2022 18:15:20 +0100 Subject: [PATCH 27/30] ex2 --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 1af078a6c8fb2..29f8d03c1db37 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,6 +32,7 @@ files = [ ] exclude = [ "src/lightning_app/cli/component-template", + "src/lightning_app/cli/pl-app-template", ] install_types = "True" non_interactive = "True" From 569bc108536b8c5736c94d815220f246d40c04a6 Mon Sep 17 00:00:00 2001 From: Jirka Date: Thu, 8 Dec 2022 18:16:31 +0100 Subject: [PATCH 28/30] ex2 --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 29f8d03c1db37..57f3da8dc505b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -64,7 +64,6 @@ module = [ "lightning_app.cli.commands.connection", "lightning_app.cli.commands.lightning_cli", "lightning_app.cli.commands.cmd_install", - "lightning_app.cli.react-ui-template.example_app", "lightning_app.cli.cmd_install", "lightning_app.components.database.client", "lightning_app.components.database.server", From daf43903ff0c93cd1661c9bc8a4dca8bf1e9f1ec Mon Sep 17 00:00:00 2001 From: Jirka Date: Thu, 8 Dec 2022 18:21:01 +0100 Subject: [PATCH 29/30] try * --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 57f3da8dc505b..a259d2f508618 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,7 @@ files = [ ] exclude = [ "src/lightning_app/cli/component-template", - "src/lightning_app/cli/pl-app-template", + "src/lightning_app/cli/*-template", ] install_types = "True" non_interactive = "True" From dec5843bb7c892b61884d2e04a4524e9bc52179a Mon Sep 17 00:00:00 2001 From: Jirka Date: Thu, 8 Dec 2022 18:24:48 +0100 Subject: [PATCH 30/30] folders --- pyproject.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a259d2f508618..8611ef9323deb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,9 +30,12 @@ files = [ "src/lightning_lite", "src/lightning_app", ] +# This section is for folders with "-" as they are not valid python modules exclude = [ + "src/lightning_app/cli/app-template", "src/lightning_app/cli/component-template", - "src/lightning_app/cli/*-template", + "src/lightning_app/cli/pl-app-template", + "src/lightning_app/cli/react-ui-template", ] install_types = "True" non_interactive = "True"