Repository: kedro-org/kedro
File: kedro/framework/cli/starters.py (Python)

Code before:
        config["add_ons"] = [
            NUMBER_TO_ADD_ONS_NAME[add_on]
            for add_on in _parse_add_ons_input(add_ons)  # type: ignore
        ]
        config["add_ons"] = str(config["add_ons"])

    cookiecutter_args = {
        "output_dir": config.get("output_dir", str(Path.cwd().resolve())),
        "no_input": True,
        "extra_context": config,
    }

    if checkout:
        cookiecutter_args["checkout"] = checkout
    if directory:
        cookiecutter_args["directory"] = directory

    return cookiecutter_args


def fetch_template_based_on_add_ons(template_path, cookiecutter_args: dict[str, Any]):
    extra_context = cookiecutter_args["extra_context"]
    add_ons = extra_context.get("add_ons")
    example_pipeline = extra_context.get("example_pipeline")
    starter_path = "git+https://github.com/kedro-org/kedro-starters.git"
    if example_pipeline:
        if "Pyspark" in add_ons and "Kedro Viz" in add_ons:
            # Use the spaceflights-pyspark-viz starter if both Pyspark and Kedro Viz are chosen.
            cookiecutter_args["directory"] = "spaceflights-pyspark-viz"
        elif "Pyspark" in add_ons:
            # Use the spaceflights-pyspark starter if only Pyspark is chosen.
            cookiecutter_args["directory"] = "spaceflights-pyspark"
        elif "Kedro Viz" in add_ons:
            # Use the spaceflights-pandas-viz starter if only Kedro Viz is chosen.
            cookiecutter_args["directory"] = "spaceflights-pandas-viz"
        else:
            # Use spaceflights-pandas starter for any other combinations or if "none" is chosen.
            cookiecutter_args["directory"] = "spaceflights-pandas"
    else:
        # Use the default template path if example_pipeline option was not selected.
        starter_path = template_path
    return starter_path


def _create_project(template_path: str, cookiecutter_args: dict[str, Any]):
    """Creates a new kedro project using cookiecutter.

    Args:
        template_path: The path to the cookiecutter template to create the project.
            It could either be a local directory or a remote VCS repository
            supported by cookiecutter. For more details, please see:

Review comment (suggestion):
This isn't correct. Even if the example pipeline isn't wanted, we might need to fetch from a starter template other than the default. @SajidAlamQB can probably help out here about what the flow should be. 

Code after:
    Args:
        prompts: Prompts from prompts.yml.
        cookiecutter_context: Cookiecutter context generated from cookiecutter.json.

    Returns:
        Configuration for starting a new project. This is passed as ``extra_context``
            to cookiecutter and will overwrite the cookiecutter.json defaults.
    """
    # noqa: import-outside-toplevel
    from cookiecutter.environment import StrictEnvironment
    from cookiecutter.prompt import read_user_variable, render_variable

    config: dict[str, str] = {}

    for variable_name, prompt_dict in prompts.items():
        prompt = _Prompt(**prompt_dict)

        # render the variable on the command line
        cookiecutter_variable = render_variable(
            env=StrictEnvironment(context=cookiecutter_context),
            raw=cookiecutter_context.get(variable_name),
            cookiecutter_dict=config,
        )

        # read the user's input for the variable
        user_input = read_user_variable(str(prompt), cookiecutter_variable)
        if user_input:
            prompt.validate(user_input)
            config[variable_name] = user_input
    return config


def fetch_template_based_on_add_ons(template_path, cookiecutter_args: dict[str, Any]):
    extra_context = cookiecutter_args["extra_context"]
    # If 'add_ons' or 'example_pipeline' are not specified in prompts.yml and not prompted in 'kedro new' options,
    # default options will be used instead
    add_ons = extra_context.get("add_ons", [])
    example_pipeline = extra_context.get("example_pipeline", False)
    starter_path = "git+https://github.com/kedro-org/kedro-starters.git"
    if "Pyspark" in add_ons and "Kedro Viz" in add_ons:
        # Use the spaceflights-pyspark-viz starter if both Pyspark and Kedro Viz are chosen.
        cookiecutter_args["directory"] = "spaceflights-pyspark-viz"
    elif "Pyspark" in add_ons:
        # Use the spaceflights-pyspark starter if only Pyspark is chosen.
        cookiecutter_args["directory"] = "spaceflights-pyspark"
    elif "Kedro Viz" in add_ons:
        # Use the spaceflights-pandas-viz starter if only Kedro Viz is chosen.
        cookiecutter_args["directory"] = "spaceflights-pandas-viz"
    elif example_pipeline:
        # Use spaceflights-pandas starter if example was selected, but PySpark or Viz wasn't
        cookiecutter_args["directory"] = "spaceflights-pandas"