diff --git a/astro-airflow-iris/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/__main__.py b/astro-airflow-iris/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/__main__.py index ad0a5e6d..d951412a 100644 --- a/astro-airflow-iris/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/__main__.py +++ b/astro-airflow-iris/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/__main__.py @@ -1,45 +1,16 @@ """{{ cookiecutter.project_name }} file for ensuring the package is executable as `{{ cookiecutter.repo_name }}` and `python -m {{ cookiecutter.python_package }}` """ -import importlib from pathlib import Path -from kedro.framework.cli.utils import KedroCliError, load_entry_points +from kedro.framework.cli.utils import find_run_command from kedro.framework.project import configure_project -def _find_run_command(package_name): - try: - project_cli = importlib.import_module(f"{package_name}.cli") - # fail gracefully if cli.py does not exist - except ModuleNotFoundError as exc: - if f"{package_name}.cli" not in str(exc): - raise - plugins = load_entry_points("project") - run = _find_run_command_in_plugins(plugins) if plugins else None - if run: - # use run command from installed plugin if it exists - return run - # use run command from the framework project - from kedro.framework.cli.project import run - - return run - # fail badly if cli.py exists, but has no `cli` in it - if not hasattr(project_cli, "cli"): - raise KedroCliError(f"Cannot load commands from {package_name}.cli") - return project_cli.run - - -def _find_run_command_in_plugins(plugins): - for group in plugins: - if "run" in group.commands: - return group.commands["run"] - - def main(*args, **kwargs): package_name = Path(__file__).parent.name configure_project(package_name) - run = _find_run_command(package_name) + run = find_run_command(package_name) run(*args, **kwargs) diff --git a/spaceflights-pandas-viz/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/__main__.py b/spaceflights-pandas-viz/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/__main__.py index ad0a5e6d..d951412a 100644 --- a/spaceflights-pandas-viz/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/__main__.py +++ b/spaceflights-pandas-viz/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/__main__.py @@ -1,45 +1,16 @@ """{{ cookiecutter.project_name }} file for ensuring the package is executable as `{{ cookiecutter.repo_name }}` and `python -m {{ cookiecutter.python_package }}` """ -import importlib from pathlib import Path -from kedro.framework.cli.utils import KedroCliError, load_entry_points +from kedro.framework.cli.utils import find_run_command from kedro.framework.project import configure_project -def _find_run_command(package_name): - try: - project_cli = importlib.import_module(f"{package_name}.cli") - # fail gracefully if cli.py does not exist - except ModuleNotFoundError as exc: - if f"{package_name}.cli" not in str(exc): - raise - plugins = load_entry_points("project") - run = _find_run_command_in_plugins(plugins) if plugins else None - if run: - # use run command from installed plugin if it exists - return run - # use run command from the framework project - from kedro.framework.cli.project import run - - return run - # fail badly if cli.py exists, but has no `cli` in it - if not hasattr(project_cli, "cli"): - raise KedroCliError(f"Cannot load commands from {package_name}.cli") - return project_cli.run - - -def _find_run_command_in_plugins(plugins): - for group in plugins: - if "run" in group.commands: - return group.commands["run"] - - def main(*args, **kwargs): package_name = Path(__file__).parent.name configure_project(package_name) - run = _find_run_command(package_name) + run = find_run_command(package_name) run(*args, **kwargs) diff --git a/spaceflights-pandas/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/__main__.py b/spaceflights-pandas/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/__main__.py index ad0a5e6d..d951412a 100644 --- a/spaceflights-pandas/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/__main__.py +++ b/spaceflights-pandas/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/__main__.py @@ -1,45 +1,16 @@ """{{ cookiecutter.project_name }} file for ensuring the package is executable as `{{ cookiecutter.repo_name }}` and `python -m {{ cookiecutter.python_package }}` """ -import importlib from pathlib import Path -from kedro.framework.cli.utils import KedroCliError, load_entry_points +from kedro.framework.cli.utils import find_run_command from kedro.framework.project import configure_project -def _find_run_command(package_name): - try: - project_cli = importlib.import_module(f"{package_name}.cli") - # fail gracefully if cli.py does not exist - except ModuleNotFoundError as exc: - if f"{package_name}.cli" not in str(exc): - raise - plugins = load_entry_points("project") - run = _find_run_command_in_plugins(plugins) if plugins else None - if run: - # use run command from installed plugin if it exists - return run - # use run command from the framework project - from kedro.framework.cli.project import run - - return run - # fail badly if cli.py exists, but has no `cli` in it - if not hasattr(project_cli, "cli"): - raise KedroCliError(f"Cannot load commands from {package_name}.cli") - return project_cli.run - - -def _find_run_command_in_plugins(plugins): - for group in plugins: - if "run" in group.commands: - return group.commands["run"] - - def main(*args, **kwargs): package_name = Path(__file__).parent.name configure_project(package_name) - run = _find_run_command(package_name) + run = find_run_command(package_name) run(*args, **kwargs) diff --git a/spaceflights-pyspark-viz/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/__main__.py b/spaceflights-pyspark-viz/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/__main__.py index ad0a5e6d..d951412a 100644 --- a/spaceflights-pyspark-viz/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/__main__.py +++ b/spaceflights-pyspark-viz/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/__main__.py @@ -1,45 +1,16 @@ """{{ cookiecutter.project_name }} file for ensuring the package is executable as `{{ cookiecutter.repo_name }}` and `python -m {{ cookiecutter.python_package }}` """ -import importlib from pathlib import Path -from kedro.framework.cli.utils import KedroCliError, load_entry_points +from kedro.framework.cli.utils import find_run_command from kedro.framework.project import configure_project -def _find_run_command(package_name): - try: - project_cli = importlib.import_module(f"{package_name}.cli") - # fail gracefully if cli.py does not exist - except ModuleNotFoundError as exc: - if f"{package_name}.cli" not in str(exc): - raise - plugins = load_entry_points("project") - run = _find_run_command_in_plugins(plugins) if plugins else None - if run: - # use run command from installed plugin if it exists - return run - # use run command from the framework project - from kedro.framework.cli.project import run - - return run - # fail badly if cli.py exists, but has no `cli` in it - if not hasattr(project_cli, "cli"): - raise KedroCliError(f"Cannot load commands from {package_name}.cli") - return project_cli.run - - -def _find_run_command_in_plugins(plugins): - for group in plugins: - if "run" in group.commands: - return group.commands["run"] - - def main(*args, **kwargs): package_name = Path(__file__).parent.name configure_project(package_name) - run = _find_run_command(package_name) + run = find_run_command(package_name) run(*args, **kwargs) diff --git a/spaceflights-pyspark/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/__main__.py b/spaceflights-pyspark/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/__main__.py index ad0a5e6d..d951412a 100644 --- a/spaceflights-pyspark/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/__main__.py +++ b/spaceflights-pyspark/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/__main__.py @@ -1,45 +1,16 @@ """{{ cookiecutter.project_name }} file for ensuring the package is executable as `{{ cookiecutter.repo_name }}` and `python -m {{ cookiecutter.python_package }}` """ -import importlib from pathlib import Path -from kedro.framework.cli.utils import KedroCliError, load_entry_points +from kedro.framework.cli.utils import find_run_command from kedro.framework.project import configure_project -def _find_run_command(package_name): - try: - project_cli = importlib.import_module(f"{package_name}.cli") - # fail gracefully if cli.py does not exist - except ModuleNotFoundError as exc: - if f"{package_name}.cli" not in str(exc): - raise - plugins = load_entry_points("project") - run = _find_run_command_in_plugins(plugins) if plugins else None - if run: - # use run command from installed plugin if it exists - return run - # use run command from the framework project - from kedro.framework.cli.project import run - - return run - # fail badly if cli.py exists, but has no `cli` in it - if not hasattr(project_cli, "cli"): - raise KedroCliError(f"Cannot load commands from {package_name}.cli") - return project_cli.run - - -def _find_run_command_in_plugins(plugins): - for group in plugins: - if "run" in group.commands: - return group.commands["run"] - - def main(*args, **kwargs): package_name = Path(__file__).parent.name configure_project(package_name) - run = _find_run_command(package_name) + run = find_run_command(package_name) run(*args, **kwargs)